From aac8229f9ba3c71737eeaf54d1351eb71962716f Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Fri, 7 Sep 2018 03:22:08 -0500 Subject: [PATCH] Plug in dynamic packages For now, Kodi will need to be restarted to load from the dynamic package every time there is an update to the package. --- context.py | 2 ++ context_play.py | 2 ++ default.py | 2 ++ resources/lib/entrypoint/__init__.py | 15 --------------- resources/lib/entrypoint/service.py | 5 ++++- service.py | 7 +++++++ 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/context.py b/context.py index 75288ff8..1b81c554 100644 --- a/context.py +++ b/context.py @@ -11,6 +11,8 @@ import xbmcaddon ################################################################################################# +cache = xbmc.translatePath('special://temp/emby').decode('utf-8') +sys.path.insert(0, cache) __addon__ = xbmcaddon.Addon(id='plugin.video.emby').getAddonInfo('path').decode('utf-8') __base__ = xbmc.translatePath(os.path.join(__addon__, 'resources', 'lib')).decode('utf-8') sys.path.append(__base__) diff --git a/context_play.py b/context_play.py index 32b00287..3d86657c 100644 --- a/context_play.py +++ b/context_play.py @@ -11,6 +11,8 @@ import xbmcaddon ################################################################################################# +cache = xbmc.translatePath('special://temp/emby').decode('utf-8') +sys.path.insert(0, cache) __addon__ = xbmcaddon.Addon(id='plugin.video.emby').getAddonInfo('path').decode('utf-8') __base__ = xbmc.translatePath(os.path.join(__addon__, 'resources', 'lib')).decode('utf-8') sys.path.append(__base__) diff --git a/default.py b/default.py index 23073229..00b92ad9 100644 --- a/default.py +++ b/default.py @@ -11,6 +11,8 @@ import xbmcaddon ################################################################################################# +cache = xbmc.translatePath('special://temp/emby').decode('utf-8') +sys.path.insert(0, cache) __addon__ = xbmcaddon.Addon(id='plugin.video.emby').getAddonInfo('path').decode('utf-8') __base__ = xbmc.translatePath(os.path.join(__addon__, 'resources', 'lib')).decode('utf-8') sys.path.append(__base__) diff --git a/resources/lib/entrypoint/__init__.py b/resources/lib/entrypoint/__init__.py index 4f2d9405..7bac52d8 100644 --- a/resources/lib/entrypoint/__init__.py +++ b/resources/lib/entrypoint/__init__.py @@ -3,12 +3,10 @@ ################################################################################################# import logging -import sys import xbmc import xbmcvfs -import objects from helper import loghandler from emby import Emby @@ -20,19 +18,6 @@ LOG = logging.getLogger('EMBY.entrypoint') ################################################################################################# -try: - temp = xbmc.translatePath('special://temp/emby').decode('utf-8') - - if not xbmcvfs.exists(temp): - xbmcvfs.mkdir(temp) - - sys.path.insert(0, temp) - reload(objects) -except Exception as error: - - LOG.error(error) - LOG.warn('No objects not found, using default.') - from default import Events from service import Service from context import Context diff --git a/resources/lib/entrypoint/service.py b/resources/lib/entrypoint/service.py index 337c71a6..9f0b1efe 100644 --- a/resources/lib/entrypoint/service.py +++ b/resources/lib/entrypoint/service.py @@ -131,7 +131,7 @@ class Service(xbmc.Monitor): ''' Check for objects build version and compare. This pulls a dict that contains all the information for the build needed. ''' - LOG.info("--[ check updates ]") + LOG.info("--[ check updates/%s ]", objects.version) kodi = xbmc.getInfoLabel('System.BuildVersion') url = "https://sheets.googleapis.com/v4/spreadsheets/1cKWQCVL0lVONulO2KyGzBilzhGvsyuSjFvrqe8g6nJw/values/A2:B?key=AIzaSyAP-1mcBglk9zIofJlqGpvKXkff3GRMhdI" @@ -152,6 +152,9 @@ class Service(xbmc.Monitor): get_objects(zipfile, label + '.zip') except Exception as error: LOG.info(error) + + dialog("ok", heading="{emby}", line1=_(33135)) + xbmc.executebuiltin('RestartApp') def onNotification(self, sender, method, data): diff --git a/service.py b/service.py index a57ef191..a22e0579 100644 --- a/service.py +++ b/service.py @@ -7,10 +7,17 @@ import os import sys import xbmc +import xbmcvfs import xbmcaddon ################################################################################################# +cache = xbmc.translatePath('special://temp/emby').decode('utf-8') + +if not xbmcvfs.exists(cache): + xbmcvfs.mkdir(cache) + +sys.path.insert(0, cache) __addon__ = xbmcaddon.Addon(id='plugin.video.emby').getAddonInfo('path').decode('utf-8') __base__ = xbmc.translatePath(os.path.join(__addon__, 'resources', 'lib')).decode('utf-8') sys.path.append(__base__)