Пример #1
0
 def execute_moves(self, moves, req_attrib):
     if moves is None or len(moves) == 0:
         logging.getLogger().debug('No moves found for execution, return now.')
         return
     else:
         logging.getLogger().debug('total moves to be executed: %s' % (len(moves)))
         modelMap = {}
         for move in moves:
             logging.getLogger().debug('move to be executed: %s.%s' % (move.module, move.function))
             module = importlib.import_module(move.module, self._addon_path)
             function = getattr(module, move.function)
             """Each function call returns True or False or None value to indicate if the process can proceed with next move execution"""
             proceed_ind = None
             try:
                 proceed_ind = function(req_attrib, modelMap)
             except Exception,e:
                 modelMap['error-occurred'] = True
                 modelMap['error'] = e
                 proceed_ind = False
             
             if move.view_id is not None:
                 logging.getLogger().debug('move has a view: %s' % (move.view_id))
                 self._dispatch_view(move.view_id, modelMap)
             if proceed_ind is not None:
                 if proceed_ind is False:
                     logging.getLogger().error('received not to proceed indicator from last move: %s.%s' % (move.module, move.function))
                     break
                 elif proceed_ind.startswith('redirect:'):
                     self._redirect_action_func(proceed_ind.replace('redirect:', '', 1), req_attrib)
                     break
             
         return modelMap
 def __init__(self, snapper_Tag, addon_path):
     modulePath = snapper_Tag.attrib['module']
     functionName = snapper_Tag.attrib['function']
     self.__video_id_regex_list = []
     for video_id_elem in snapper_Tag.getchildren():
         self.__video_id_regex_list.append(video_id_elem.attrib['regex'])
     self.__is_playlist = False
     if snapper_Tag.attrib.has_key('playlist') and snapper_Tag.attrib['playlist'] == 'true':
         self.__is_playlist = True
     
     self.__snapper_module = importlib.import_module(modulePath, addon_path)
     self.__snapper_modulepath = modulePath
     self.__getVideoInfo = getattr(self.__snapper_module, functionName)
     self.getVideoHostingInfo = getattr(self.__snapper_module, 'getVideoHost')
     logging.getLogger().debug('Snapper loaded = ' + modulePath)
Пример #3
0
 def render(self, view, modelMap):
     """Invokes service response builder that prepares map of key-value pairs to be returned in response."""
     module = importlib.import_module(view.module, self._addon_path)
     function = getattr(module, view.function)
     self._current_view = view
     """Delete temporary controls created using python in last view. Example ControlImage created in python... """
     controls_to_delete = CacheManager().remove('controls_to_be_deleted')
     if controls_to_delete is not None:
         logging.getLogger().debug('List of controls to remove size : %s' % str(len(controls_to_delete)))
         self._addon_window.removeControls(controls_to_delete)
         del controls_to_delete
         CacheManager().put('controls_to_be_deleted', [])
     
     """Each function call returns Service Response map"""
     function(modelMap, self._addon_window)
Пример #4
0
 def handle_event(self, intent, control_id=0):
     logging.getLogger().debug('handling an event for intent : %s on control : %s' % (intent, str(control_id)))
     req_attr_map = None
     action_id = None
     for event in self._current_view.events:
         if((event.intent == intent and (event.control_id == str(control_id) or event.control_id == '')) or event.intent == ''):
             """Invokes service response builder that prepares map of key-value pairs to be returned in response."""
             if event.module is not None:
                 logging.getLogger().debug('Executing module : %s.%s' % (event.module, event.function))
                 module = importlib.import_module(event.module, self._addon_path)
                 function = getattr(module, event.function)
                 """Each function call returns Service Response map"""
                 req_attr_map = function(self._addon_window, control_id)
             action_id = event.action_id
     if action_id is not None:
         self._do_action_func(action_id, req_attr_map)
Пример #5
0
    def __init__(self, snapper_Tag, addon_path):
        modulePath = snapper_Tag.attrib['module']
        functionName = snapper_Tag.attrib['function']
        self.__video_id_regex_list = []
        for video_id_elem in snapper_Tag.getchildren():
            self.__video_id_regex_list.append(video_id_elem.attrib['regex'])
        self.__is_playlist = False
        if snapper_Tag.attrib.has_key(
                'playlist') and snapper_Tag.attrib['playlist'] == 'true':
            self.__is_playlist = True

        self.__snapper_module = importlib.import_module(modulePath, addon_path)
        self.__snapper_modulepath = modulePath
        self.__getVideoInfo = getattr(self.__snapper_module, functionName)
        self.getVideoHostingInfo = getattr(self.__snapper_module,
                                           'getVideoHost')
        logging.getLogger().debug('Snapper loaded = ' + modulePath)
Пример #6
0
    def execute_moves(self, moves, req_attrib):
        if moves is None or len(moves) == 0:
            logging.getLogger().debug(
                'No moves found for execution, return now.')
            return
        else:
            logging.getLogger().debug('total moves to be executed: %s' %
                                      (len(moves)))
            modelMap = {}
            for move in moves:
                logging.getLogger().debug('move to be executed: %s.%s' %
                                          (move.module, move.function))
                module = importlib.import_module(move.module, self._addon_path)
                function = getattr(module, move.function)
                """Each function call returns True or False or None value to indicate if the process can proceed with next move execution"""
                proceed_ind = None
                try:
                    proceed_ind = function(req_attrib, modelMap)
                except Exception, e:
                    modelMap['error-occurred'] = True
                    modelMap['error'] = e
                    proceed_ind = False

                if move.view_id is not None:
                    logging.getLogger().debug('move has a view: %s' %
                                              (move.view_id))
                    self._dispatch_view(move.view_id, modelMap)
                if proceed_ind is not None:
                    if proceed_ind is False:
                        logging.getLogger().error(
                            'received not to proceed indicator from last move: %s.%s'
                            % (move.module, move.function))
                        break
                    elif proceed_ind.startswith('redirect:'):
                        self._redirect_action_func(
                            proceed_ind.replace('redirect:', '', 1),
                            req_attrib)
                        break

            return modelMap