From 5496cb066744c4b5f28fed8cad0319a0aff20338 Mon Sep 17 00:00:00 2001 From: xnappo Date: Thu, 10 Sep 2015 21:27:36 -0500 Subject: [PATCH] Switch to local code for version check --- addon.xml | 2 +- resources/lib/LibrarySync.py | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/addon.xml b/addon.xml index 64c403d0..4672d746 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/resources/lib/LibrarySync.py b/resources/lib/LibrarySync.py index 46235165..0cfeee2e 100644 --- a/resources/lib/LibrarySync.py +++ b/resources/lib/LibrarySync.py @@ -12,7 +12,6 @@ import inspect import threading import urllib from datetime import datetime, timedelta, time -from distutils.version import LooseVersion, StrictVersion from itertools import chain import urllib2 import os @@ -1018,7 +1017,19 @@ class LibrarySync(threading.Thread): return True return False - + + def checkDBVersion(self, currVersion, minVersion): + currMajor, currMinor, currPatch = currVersion.split(".") + minMajor, minMinor, minPatch = minVersion.split(".") + if currMajor > minMajor: + return True + elif currMajor == minMajor and currMinor > minMinor: + return True + elif currMajor == minMajor and currMinor == minMinor and currPatch >= minPatch: + return True + else: + return False + def run(self): clientInfo = ClientInformation() self.logMsg("--- Starting Library Sync Thread ---", 0) @@ -1040,16 +1051,21 @@ class LibrarySync(threading.Thread): # START TEMPORARY CODE # Only get in here for a while, can be removed later if utils.settings("dbCreatedWithVersion")=="" and utils.settings("SyncInstallRunDone") == "true": + self.logMsg("Unknown DB version", 0) return_value = xbmcgui.Dialog().yesno("DB Version", "Can't detect version of Emby for Kodi the DB was created with.\nWas it at least version " + WINDOW.getProperty('minDBVersion') + "?") if return_value == 0: utils.settings("dbCreatedWithVersion","0.0.0") + self.logMsg("DB version out of date according to user", 0) else: - utils.settings("dbCreatedWithVersion",WINDOW.getProperty('minDBVersion')) + utils.settings("dbCreatedWithVersion",WINDOW.getProperty('minDBVersion')) + self.logMsg("DB version okay according to user", 0) # END TEMPORARY CODE - - if (utils.settings("SyncInstallRunDone") == "true" and LooseVersion(utils.settings("dbCreatedWithVersion")) < LooseVersion(WINDOW.getProperty('minDBVersion'))) and WINDOW.getProperty('minDBVersionCheck') != "true": + self.logMsg("DB Version: " + utils.settings("dbCreatedWithVersion"), 0) + if (utils.settings("SyncInstallRunDone") == "true" and self.checkDBVersion(utils.settings("dbCreatedWithVersion"), WINDOW.getProperty('minDBVersion'))==False and WINDOW.getProperty('minDBVersionCheck') != "true"): + self.logMsg("DB version out of date according to check", 0) return_value = xbmcgui.Dialog().yesno("DB Version", "Detected the DB needs to be recreated for\nthis version of Emby for Kodi.\nProceed?") if return_value == 0: + self.logMsg("DB version out of date !!! USER IGNORED !!!", 0) xbmcgui.Dialog().ok("Emby for Kodi","Emby for Kodi may not work\ncorrectly until the database is reset.\n") WINDOW.setProperty('minDBVersionCheck', "true") else: