Funnel commands to main Python instance
This commit is contained in:
parent
10942558cc
commit
73ce4eeacb
3 changed files with 42 additions and 5 deletions
16
default.py
16
default.py
|
@ -137,7 +137,7 @@ class Main():
|
|||
window('plex_runLibScan', value='del_textures')
|
||||
|
||||
elif mode == 'chooseServer':
|
||||
entrypoint.chooseServer()
|
||||
self.__exec('function=choose_server')
|
||||
|
||||
elif mode == 'refreshplaylist':
|
||||
log.info('Requesting playlist/nodes refresh')
|
||||
|
@ -172,8 +172,7 @@ class Main():
|
|||
# Put the request into the 'queue'
|
||||
while window('plex_command'):
|
||||
sleep(50)
|
||||
window('plex_command',
|
||||
value='play_%s' % argv[2])
|
||||
window('plex_command', value='play_%s' % argv[2])
|
||||
# Wait for the result
|
||||
while not pickl_window('plex_result'):
|
||||
sleep(50)
|
||||
|
@ -190,6 +189,17 @@ class Main():
|
|||
listitem = convert_PKC_to_listitem(result.listitem)
|
||||
setResolvedUrl(HANDLE, True, listitem)
|
||||
|
||||
@staticmethod
|
||||
def __exec(command):
|
||||
"""
|
||||
Used to funnel commands to the main PKC python instance (like play())
|
||||
"""
|
||||
# Put the request into the 'queue'
|
||||
while window('plex_command'):
|
||||
sleep(50)
|
||||
window('plex_command', value='exec_%s' % command)
|
||||
# No need to wait for the result
|
||||
|
||||
def deviceid(self):
|
||||
deviceId_old = window('plex_client_Id')
|
||||
from clientinfo import getDeviceId
|
||||
|
|
|
@ -3,11 +3,13 @@
|
|||
import logging
|
||||
from threading import Thread
|
||||
from Queue import Queue
|
||||
from urlparse import parse_qsl
|
||||
|
||||
from xbmc import sleep
|
||||
|
||||
from utils import window, thread_methods
|
||||
import state
|
||||
import entrypoint
|
||||
|
||||
###############################################################################
|
||||
log = logging.getLogger("PLEX."+__name__)
|
||||
|
@ -32,6 +34,29 @@ class Monitor_Window(Thread):
|
|||
self.playback_queue = Queue()
|
||||
Thread.__init__(self)
|
||||
|
||||
@staticmethod
|
||||
def __execute(value):
|
||||
"""
|
||||
Kick off with new threads. Pass in a string with the information url-
|
||||
encoded:
|
||||
function=<function-name in entrypoint.py>
|
||||
params=<function parameters> (optional)
|
||||
"""
|
||||
values = dict(parse_qsl(value))
|
||||
function = values.get('function')
|
||||
params = values.get('params')
|
||||
log.debug('Execution called for function %s with parameters %s'
|
||||
% (function, params))
|
||||
function = getattr(entrypoint, function)
|
||||
try:
|
||||
if params is not None:
|
||||
function(params)
|
||||
else:
|
||||
function()
|
||||
except:
|
||||
log.error('Failed to execute function %s with params %s'
|
||||
% (function, params))
|
||||
|
||||
def run(self):
|
||||
thread_stopped = self.thread_stopped
|
||||
queue = self.playback_queue
|
||||
|
@ -42,7 +67,9 @@ class Monitor_Window(Thread):
|
|||
window('plex_command', clear=True)
|
||||
if value.startswith('play_'):
|
||||
queue.put(value)
|
||||
|
||||
elif value.startswith('exec_'):
|
||||
t = Thread(target=self.__execute, args=(value[5:], ))
|
||||
t.start()
|
||||
elif value == 'SUSPEND_LIBRARY_THREAD-True':
|
||||
state.SUSPEND_LIBRARY_THREAD = True
|
||||
elif value == 'SUSPEND_LIBRARY_THREAD-False':
|
||||
|
|
|
@ -31,7 +31,7 @@ except IndexError:
|
|||
###############################################################################
|
||||
|
||||
|
||||
def chooseServer():
|
||||
def choose_server():
|
||||
"""
|
||||
Lets user choose from list of PMS
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue