Example #1
0
class StepCall(StepBase):
    def __init__(self, name, application, step_type, step_subtype, step_content, shared_lock):
        super(StepCall, self).__init__(name, application, step_type, step_subtype, step_content, shared_lock)
        self.call_chain_name=step_subtype
        self.pycode      = PyCode(self.name, 'inline(StepCall)', self.content[0]['value'])


    def run(self, runtime_context):
        assert(CTX_PAYLOAD in runtime_context)
        runtime_context[CTX_LOCK] = self.shared_lock

        chain = self.application.get_chain(self.call_chain_name)
        if not chain:
            raise SyntaxError('Chain "%s" does not exist!' % (self.call_chain_name,))

        exception_queue = Queue.Queue()
        self.pycode.run( exception_queue, runtime_context)
        try:
            exception_info = exception_queue.get(block=False)
            raise RuntimeError(exception_info)
        except Queue.Empty:
            pass

        chain.run( runtime_context, False )
        self.logger.info("StepCall runtime_contex[payload] %s", runtime_context[CTX_PAYLOAD])
Example #2
0
class StepExceptionHandler(StepBase):
    def __init__(self, name, application, step_type, step_subtype, step_content, shared_lock):
        super(StepExceptionHandler, self).__init__(name, application, step_type, step_subtype, step_content, shared_lock)
        self.is_exception_handler   = True
        self.call = None
        for instruction in step_content:
            if instruction['subtype'] == 'code':
                self.pycode = PyCode(self.name, 'inline', instruction['value'])
            elif instruction['subtype'] == 'gosub':
                self.call = instruction['value']

    def run(self, runtime_context):
        self.logger.info('Executing ExceptionHandler "%s".', self.name)

        runtime_context[CTX_LOCK] = self.shared_lock
        exception_queue           = Queue.Queue()
        self.pycode.run(exception_queue, runtime_context)
        try:
            exc_type, exc_obj, exc_trace = exception_queue.get(block=False)
            self.logger.error("%s Exception Info: %r", self.name, exc_obj)
            raise exc_obj
        except Queue.Empty:
            pass
        if self.call is not None:
            call_chain = self.application.get_chain(self.call)
            if not call_chain:
                raise SyntaxError('Chain "%s" does not exist!' % (self.call,))
            call_chain.run( runtime_context, False )
Example #3
0
    def __init__(self, name, application, step_type, step_subtype, step_content, shared_lock):
        super(StepEntrypoint, self).__init__(name, application, step_type, step_subtype, step_content, shared_lock)
        self.logger        = logging.getLogger('maaps.ep')
        self.is_entrypoint = True
        self.instance      = None

        atexit.register(self.shutdown)

        self.apply_assignements_to_context()

        if self.sub_stype == 'HttpListener':
            self.logger   = logging.getLogger('maaps.ep.httplistener')
            self.instance = EPHttpListener(self.local_context, self.name)
        elif self.sub_stype == 'LOOP':
            self.logger = logging.getLogger('maaps.ep.loop')

            assert('code' in self.local_context)

            source_code = PyCode.tidy_source_code(self.local_context['code'])
            if not source_code:
                raise SyntaxError("%s: No CODE/CONTEXT block in LOOP statement!", self.name)

            self.local_context[CTX_LOCK] = self.shared_lock

            self.instance = EPLoop(self.local_context, self.name, source_code)

        else:
            raise TypeError('%s: unknown entrypoint-type "%s"' % (self.name, self.sub_stype,))
Example #4
0
 def __init__(self, name, application, step_type, step_subtype, step_content, shared_lock):
     super(StepExceptionHandler, self).__init__(name, application, step_type, step_subtype, step_content, shared_lock)
     self.is_exception_handler   = True
     self.call = None
     for instruction in step_content:
         if instruction['subtype'] == 'code':
             self.pycode = PyCode(self.name, 'inline', instruction['value'])
         elif instruction['subtype'] == 'gosub':
             self.call = instruction['value']
Example #5
0
 def __init__(self, name, application, step_type, step_subtype, step_content, shared_lock):
     super(StepCall, self).__init__(name, application, step_type, step_subtype, step_content, shared_lock)
     self.call_chain_name=step_subtype
     self.pycode      = PyCode(self.name, 'inline(StepCall)', self.content[0]['value'])