Move pickl_window function

This commit is contained in:
tomkat83 2017-09-10 15:06:46 +02:00
parent 0c20716c9b
commit cb39dbd19d
3 changed files with 23 additions and 28 deletions

View file

@ -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

View file

@ -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

View file

@ -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