From b76fef912c134e7c555c3ef50659e26e0f12caab Mon Sep 17 00:00:00 2001 From: mac12m99 Date: Sat, 3 Aug 2019 15:14:09 +0200 Subject: [PATCH] fix e migliorie per l'updater --- channelselector.py | 2 +- platformcode/config.py | 32 +++++++++++++++++++------------- platformcode/launcher.py | 3 +-- platformcode/updater.py | 8 ++++---- specials/setting.py | 7 +++---- videolibrary_service.py | 5 +---- 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/channelselector.py b/channelselector.py index f610c705..dfc099b7 100644 --- a/channelselector.py +++ b/channelselector.py @@ -78,7 +78,7 @@ def getmainlist(view="thumb_"): thumbnail=get_thumb(thumb_setting, view), category=config.get_localized_string(30100), viewmode="list")) - itemlist.append(Item(title=config.get_localized_string(30104) + " (" + config.get_localized_string(20000) +" " + config.get_addon_version(with_fix=False) + ")", channel="help", action="mainlist", + itemlist.append(Item(title=config.get_localized_string(30104) + " (v" + config.get_addon_version(with_fix=True) + ")", channel="help", action="mainlist", thumbnail=get_thumb("help.png", view), category=config.get_localized_string(30104), viewmode="list")) return itemlist diff --git a/platformcode/config.py b/platformcode/config.py index 0cb811c5..12da69e1 100644 --- a/platformcode/config.py +++ b/platformcode/config.py @@ -17,26 +17,32 @@ __language__ = __settings__.getLocalizedString def get_addon_core(): return __settings__ + def get_addon_version(with_fix=True): ''' - Devuelve el número de versión del addon, y opcionalmente número de fix si lo hay + Trova la versione dell'addon, senza usare le funzioni di kodi perchè non si aggiornano fino al riavvio ''' + info = open(os.path.join(get_runtime_path(), 'addon.xml')).read() + ver = re.search('plugin.video.kod.*?version="([^"]+)"', info).group(1) + if with_fix: - return __settings__.getAddonInfo('version') + get_addon_version_fix() + return ver + " " + get_addon_version_fix() else: - return __settings__.getAddonInfo('version') + return ver + def get_addon_version_fix(): - try: - last_fix_json = os.path.join(get_runtime_path(), 'last_fix.json') # información de la versión fixeada del usuario - if os.path.exists(last_fix_json): - with open(last_fix_json, 'r') as f: data=f.read(); f.close() - fix = re.findall('"fix_version"\s*:\s*(\d+)', data) - if fix: - return '.fix%s' % fix[0] - except: - pass - return '' + if not dev_mode(): + sha = open(os.path.join(get_runtime_path(), 'last_commit.txt')).readline() + return sha[:8] + else: + return 'DEV' + + +def dev_mode(): + r = os.path.isdir(get_runtime_path() + '/.git') + return r + def get_platform(full_version=False): """ diff --git a/platformcode/launcher.py b/platformcode/launcher.py index 961ba39c..9107cdd9 100644 --- a/platformcode/launcher.py +++ b/platformcode/launcher.py @@ -72,8 +72,7 @@ def run(item=None): else: item = Item(channel="channelselector", action="getmainlist", viewmode="movie") if not config.get_setting('show_once'): - if not os.path.isdir(config.get_runtime_path() + '/.git'): - logger.info("DEV MODE OFF") + if not config.dev_mode(): from platformcode import updater updater.calcCurrHash() from platformcode import xbmc_videolibrary diff --git a/platformcode/updater.py b/platformcode/updater.py index 789bdff2..788faa9a 100644 --- a/platformcode/updater.py +++ b/platformcode/updater.py @@ -89,8 +89,7 @@ def check_addon_init(): text = "" try: localFile = open(addonDir + file["filename"], 'r+') - for line in localFile: - text += line + text = localFile.read() except IOError: # nuovo file localFile = open(addonDir + file["filename"], 'w') @@ -105,12 +104,13 @@ def check_addon_init(): else: # nel caso ci siano stati problemi logger.info('lo sha non corrisponde, scarico il file') downloadtools.downloadfile(file['raw_url'], addonDir + file['filename'], - silent=True, continuar=True) + silent=True, continuar=True, resumir=False) else: # è un file NON testuale, lo devo scaricare # se non è già applicato if not (filetools.isfile(addonDir + file['filename']) and getSha( filetools.read(addonDir + file['filename']) == file['sha'])): - downloadtools.downloadfile(file['raw_url'], addonDir + file['filename'], silent=True, continuar=True) + downloadtools.downloadfile(file['raw_url'], addonDir + file['filename'], silent=True, + continuar=True, resumir=False) alreadyApplied = False elif file['status'] == 'removed': try: diff --git a/specials/setting.py b/specials/setting.py index ba3cb11b..eca3acd3 100644 --- a/specials/setting.py +++ b/specials/setting.py @@ -342,12 +342,11 @@ def submenu_tools(item): def check_quickfixes(item): logger.info() - if not os.path.isfile(config.get_runtime_path() + '/.dev'): - logger.info("DEV MODE OFF") + if not config.dev_mode(): from platformcode import updater - return updater.check_addon_updates(verbose=True) + return updater.check_addon_init() else: - logger.info("DEV MODE ON") + return False def update_quasar(item): diff --git a/videolibrary_service.py b/videolibrary_service.py index 24c0ced2..113715f4 100644 --- a/videolibrary_service.py +++ b/videolibrary_service.py @@ -355,13 +355,10 @@ if __name__ == "__main__": # Verificar quick-fixes al abrirse Kodi, y dejarlo corriendo como Thread - if not os.path.isdir(config.get_runtime_path() + '/.git'): - logger.info("DEV MODE OFF") + if not config.dev_mode(): from platformcode import updater updater.check_addon_init() # get_channel_json() -> disabilitato, lo si fa con l'updater - else: - logger.info("DEV MODE ON") # Copia Custom code a las carpetas de Alfa desde la zona de Userdata from platformcode import custom_code