def _execute_action(self): from resources.lib.modules.globals import g g.init_globals(["", 0, self.next_action]) from resources.lib.modules import router router.dispatch(g.REQUEST_PARAMS)
# -*- coding: utf-8 -*- import sys import time from resources.lib.common import tools from resources.lib.modules import router if __name__ == '__main__': try: url = dict(tools.parse_qsl(sys.argv[2].replace('?', ''))) except: url = {} start = time.time() router.dispatch(url) tools.log('Processing Time - %s: %s' % (url.get('action', ''), time.time() - start))
# -*- coding: utf-8 -*- from __future__ import absolute_import, division, unicode_literals import sys from resources.lib.common import tools if tools.is_stub(): # noinspection PyUnresolvedReferences from mock_kodi import MOCK from resources.lib.modules import router from resources.lib.modules.globals import g from resources.lib.modules.timeLogger import TimeLogger g.init_globals(sys.argv) try: with TimeLogger('{}'.format(g.REQUEST_PARAMS.get('action', ''))): router.dispatch(g.REQUEST_PARAMS) finally: g.deinit()
def closeDirectory(self): if UNIT_TEST_MODE: return print('OUTER LOOP') while True: print('loop') print('-------------------------------') print('-1) Back') print(' 0) Home') print('-------------------------------') for idx, item in enumerate(self.items): print(' %s) %s' % (idx + 1, item[0])) try: print('') print("Enter Action Number") try: action = raw_input() except: action = input() sys.argv = ['', 0, None] try: print(action) action = int(action) - 1 if action == -2: if len(self.history) > 0: sys.argv = ['', 0, self.history.pop(-1)] self.last_action = '' return elif action == -1: sys.argv = ['', 0, ''] else: print(self.items[action][1]) sys.argv = ['', 0, self.items[action][1]] except: action = str(action) get_context_check = re.findall(r'c(\d*)', action) get_context_check = [ i for i in get_context_check if i != '' ] if len(get_context_check) == 1: item = self.items[int(get_context_check[0]) - 1] self.items = [] for context_item in item[0].cm: self.items.append( (context_item[0], re.findall(r'.*?\((.*?)\)', context_item[1])[0])) continue print('STRING ACTION') print(action) if action.startswith('action'): try: action = re.findall(r'action (.*?)$', action)[0] sys.argv = ['', 0, 'action=%s' % action] except: print('failed') elif action == 'shell': print('RUN SHELL') import code variables = globals().copy() variables.update(locals()) try: shell = code.InteractiveConsole(variables) shell.interact() except: self.items = [] self.history.append(self.last_action) execfile( os.path.abspath( os.path.join(os.getcwd(), 'seren.py'))) else: raise Exception break except: import traceback traceback.print_exc() import time time.sleep(10) print('Please enter a valid entry') self.items = [] if self.last_action != '': self.history.append(self.last_action) self.last_action = sys.argv[2] router.dispatch(dict(parse_qsl(sys.argv[2].replace('?', '')))) # execfile(os.path.abspath(os.path.join(os.getcwd(), 'seren.py'))) sys.argv = ['', 0, '']