def run(self):
     """The primary workhorse. Runs/executes the active activity processors."""
     
     loggers.debug('run():')
     
     # If no active activity processor pairs, process them all
     if len(self.active_activity_processor_pairs) == 0:
         self.active_activity_processor_pairs = self.manager.get_activity_processor_pairs()
     
     for (key, activity_processor) in self.active_activity_processor_pairs.items():  
         attr = activity_processor[activity_processor.rfind('.')+1:]
         path = activity_processor.split('.')[:-1]
         
         loggers.debug('callable: ' + attr)
         loggers.debug('location: %s' % path)
         
         # Try to import the module by importing module N-1 from the path (the Nth is the function/attr node of the path). If that doesn't work, try importing the submodule of the N-1 path and keep going util the base module.
         module, function = None, None
         
         for i in reversed(range(1, len(path)+1)):
             try:
                 loggers.debug('import \'' + '.'.join(path[:i]) + '\'?')
                 module = self.import_module('.'.join(path[:i]))
                 loggers.debug(module)
             except ImportError:
                 loggers.debug('no.')
                 loggers.debug(traceback.format_exc())
                 continue
             
             if module is not None:
                 while True:
                     try:
                         loggers.debug('sub-import \'' + '.'.join(path[1:i+1]) + '\'?')
                         tmp = getattr(module, '.'.join(path[1:i+1]))
                         module = tmp
                         loggers.debug('yes.')
                     except AttributeError:
                         loggers.debug('no.')
                         #loggers.debug(traceback.format_exc())
                         break
                 
                 if module is not None:
                     try:
                         loggers.debug('get attr \'' + attr + '\' in ' + str(module) + '?')
                         function = getattr(module, attr)
                         loggers.debug('yes.')
                         break
                     except AttributeError:
                         loggers.debug('no.')
                         loggers.debug(traceback.format_exc())
         
         # Execute the function
         if function is not None:
             loggers.debug('running...')
             function()
         else:
             raise exceptions.SidewalkMethodDoesNotExist(module='.'.join(path), method=attr)
Beispiel #2
0
def hello():
    """Simply print hello world back to the console."""

    loggers.debug('hello world', verbose=True)
Beispiel #3
0
def import_test():
    """Import the core sidewalk module to check against a defined value."""

    import sidewalk
    loggers.debug('sidewalk == %s' % (sidewalk.__title__), verbose=True)
Beispiel #4
0
    def run(self):
        """The primary workhorse. Runs/executes the active activity processors."""

        loggers.debug('run():')

        # If no active activity processor pairs, process them all
        if len(self.active_activity_processor_pairs) == 0:
            self.active_activity_processor_pairs = self.manager.get_activity_processor_pairs(
            )

        for (key, activity_processor
             ) in self.active_activity_processor_pairs.items():
            attr = activity_processor[activity_processor.rfind('.') + 1:]
            path = activity_processor.split('.')[:-1]

            loggers.debug('callable: ' + attr)
            loggers.debug('location: %s' % path)

            # Try to import the module by importing module N-1 from the path (the Nth is the function/attr node of the path). If that doesn't work, try importing the submodule of the N-1 path and keep going util the base module.
            module, function = None, None

            for i in reversed(range(1, len(path) + 1)):
                try:
                    loggers.debug('import \'' + '.'.join(path[:i]) + '\'?')
                    module = self.import_module('.'.join(path[:i]))
                    loggers.debug(module)
                except ImportError:
                    loggers.debug('no.')
                    loggers.debug(traceback.format_exc())
                    continue

                if module is not None:
                    while True:
                        try:
                            loggers.debug('sub-import \'' +
                                          '.'.join(path[1:i + 1]) + '\'?')
                            tmp = getattr(module, '.'.join(path[1:i + 1]))
                            module = tmp
                            loggers.debug('yes.')
                        except AttributeError:
                            loggers.debug('no.')
                            #loggers.debug(traceback.format_exc())
                            break

                    if module is not None:
                        try:
                            loggers.debug('get attr \'' + attr + '\' in ' +
                                          str(module) + '?')
                            function = getattr(module, attr)
                            loggers.debug('yes.')
                            break
                        except AttributeError:
                            loggers.debug('no.')
                            loggers.debug(traceback.format_exc())

            # Execute the function
            if function is not None:
                loggers.debug('running...')
                function()
            else:
                raise exceptions.SidewalkMethodDoesNotExist(
                    module='.'.join(path), method=attr)
Beispiel #5
0
def hello():
    """Simply print hello world back to the console."""
    
    loggers.debug('hello world', verbose=True)
Beispiel #6
0
def import_test():
    """Import the core sidewalk module to check against a defined value."""
    
    import sidewalk
    loggers.debug('sidewalk == %s' % (sidewalk.__title__), verbose=True)