diff --git a/default.py b/default.py index 43b7bfc6..ec25242f 100644 --- a/default.py +++ b/default.py @@ -32,9 +32,9 @@ sys_path.append(_base_resource) ############################################################################### import entrypoint -from utils import window, pickl_window, reset, passwordsXML, language as lang,\ - dialog, plex_command -from pickler import unpickle_me +from utils import window, reset, passwordsXML, language as lang, dialog, \ + plex_command +from pickler import unpickle_me, pickl_window from PKC_listitem import convert_PKC_to_listitem import variables as v diff --git a/resources/lib/pickler.py b/resources/lib/pickler.py index 9bd73bec..1d6baee6 100644 --- a/resources/lib/pickler.py +++ b/resources/lib/pickler.py @@ -1,13 +1,26 @@ # -*- coding: utf-8 -*- ############################################################################### -import logging -import cPickle as Pickle +from logging import getLogger +from cPickle import dumps, loads -from utils import pickl_window +from xbmcgui import Window +############################################################################### +log = getLogger("PLEX."+__name__) +WINDOW = Window(10000) ############################################################################### -log = logging.getLogger("PLEX."+__name__) -############################################################################### + +def pickl_window(property, value=None, clear=False): + """ + Get or set window property - thread safe! For use with Pickle + Property and value must be string + """ + if clear: + WINDOW.clearProperty(property) + elif value is not None: + WINDOW.setProperty(property, value) + else: + return WINDOW.getProperty(property) def pickle_me(obj, window_var='plex_result'): @@ -20,7 +33,7 @@ def pickle_me(obj, window_var='plex_result'): functions won't work. See the Pickle documentation """ log.debug('Start pickling: %s' % obj) - pickl_window(window_var, value=Pickle.dumps(obj)) + pickl_window(window_var, value=dumps(obj)) log.debug('Successfully pickled') @@ -32,7 +45,7 @@ def unpickle_me(window_var='plex_result'): result = pickl_window(window_var) pickl_window(window_var, clear=True) log.debug('Start unpickling') - obj = Pickle.loads(result) + obj = loads(result) log.debug('Successfully unpickled: %s' % obj) return obj diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 3c24a36f..eddc8e7f 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -59,24 +59,6 @@ def window(property, value=None, clear=False, windowid=10000): return tryDecode(win.getProperty(property)) -def pickl_window(property, value=None, clear=False, windowid=10000): - """ - Get or set window property - thread safe! For use with Pickle - Property and value must be string - """ - if windowid != 10000: - win = xbmcgui.Window(windowid) - else: - win = WINDOW - - if clear: - win.clearProperty(property) - elif value is not None: - win.setProperty(property, value) - else: - return win.getProperty(property) - - def plex_command(key, value): """ Used to funnel states between different Python instances. NOT really thread