platypush/procedure/__init__.py
def execute(self, n_tries=1, __stack__=None, **context):
        """
        Execute the requests in the procedure
        Params:
            n_tries -- Number of tries in case of failure before raising a RuntimeError
        """
        if not __stack__:
            __stack__ = [self]
        else:
            __stack__.append(self)

        if self.args:
            args = self.args.copy()
            for k, v in args.items():
                v = Request.expand_value_from_context(v, **context)
                args[k] = v
                context[k] = v
            logger.info('Executing procedure {} with arguments {}'.format(self.name, args))
        else:
            logger.info('Executing procedure {}'.format(self.name))

        response = Response()
        token = Config.get('token')

        for request in self.requests:
            if callable(request):
                response = request(**context)
                continue

            if isinstance(request, Statement):
                if request == Statement.RETURN:
                    self._should_return = True
                    for proc in __stack__:
                        proc._should_return = True
                    break

                if request in [Statement.BREAK, Statement.CONTINUE]:
                    loop = self._find_nearest_loop(__stack__)
                    if request == Statement.BREAK:
                        loop._should_break = True
                    else:
                        loop._should_continue = True
                    break

            if isinstance(self, LoopProcedure):
                if self._should_continue or self._should_break:
                    if self._should_continue:
                        # noinspection PyAttributeOutsideInit
                        self._should_continue = False

                    break

            if token:
                request.token = token

            context['_async'] = self._async
            context['n_tries'] = n_tries
            response = request.execute(__stack__=__stack__, **context)

            if not self._async and response:
                if isinstance(response.output, dict):
                    for k, v in response.output.items():
                        context[k] = v

                context['output'] = response.output
                context['errors'] = response.errors

            if self._should_return:
                break

        return response or Response()

        Execute the requests in the procedure
        Params:
            n_tries -- Number of tries in case of failure before raising a RuntimeError
        
Execute the requests in the procedure
Params:
n_tries -- Number of tries in case of failure before raising a RuntimeError
Execute the requests in the procedure Params : n_tries -- Number of tries in case of failure before raising a RuntimeError
def execute(self, n_tries=1, __stack__=None, **context):
        if not __stack__:
            __stack__ = [self]
        else:
            __stack__.append(self)
        if self.args:
            args = self.args.copy()
            for k, v in args.items():
                v = Request.expand_value_from_context(v, **context)
                args[k] = v
                context[k] = v
            logger.info('Executing procedure {} with arguments {}'.format(self.name, args))
        else:
            logger.info('Executing procedure {}'.format(self.name))
        response = Response()
        token = Config.get('token')
        for request in self.requests:
            if callable(request):
                response = request(**context)
                continue
            if isinstance(request, Statement):
                if request == Statement.RETURN:
                    self._should_return = True
                    for proc in __stack__:
                        proc._should_return = True
                    break
                if request in [Statement.BREAK, Statement.CONTINUE]:
                    loop = self._find_nearest_loop(__stack__)
                    if request == Statement.BREAK:
                        loop._should_break = True
                    else:
                        loop._should_continue = True
                    break
            if isinstance(self, LoopProcedure):
                if self._should_continue or self._should_break:
                    if self._should_continue:
                        self._should_continue = False
                    break
            if token:
                request.token = token
            context['_async'] = self._async
            context['n_tries'] = n_tries
            response = request.execute(__stack__=__stack__, **context)
            if not self._async and response:
                if isinstance(response.output, dict):
                    for k, v in response.output.items():
                        context[k] = v
                context['output'] = response.output
                context['errors'] = response.errors
            if self._should_return:
                break
        return response or Response()
def execute ( self , n_tries = 1 , __stack__ = None , ** context ) : if not __stack__ : __stack__ = [ self ] else : __stack__ . append ( self ) if self . args : args = self . args . copy ( ) for k , v in args . items ( ) : v = Request . expand_value_from_context ( v , ** context ) args [ k ] = v context [ k ] = v logger . info ( 'Executing procedure {} with arguments {}' . format ( self . name , args ) ) else : logger . info ( 'Executing procedure {}' . format ( self . name ) ) response = Response ( ) token = Config . get ( 'token' ) for request in self . requests : if callable ( request ) : response = request ( ** context ) continue if isinstance ( request , Statement ) : if request == Statement . RETURN : self . _should_return = True for proc in __stack__ : proc . _should_return = True break if request in [ Statement . BREAK , Statement . CONTINUE ] : loop = self . _find_nearest_loop ( __stack__ ) if request == Statement . BREAK : loop . _should_break = True else : loop . _should_continue = True break if isinstance ( self , LoopProcedure ) : if self . _should_continue or self . _should_break : if self . _should_continue : self . _should_continue = False break if token : request . token = token context [ '_async' ] = self . _async context [ 'n_tries' ] = n_tries response = request . execute ( __stack__ = __stack__ , ** context ) if not self . _async and response : if isinstance ( response . output , dict ) : for k , v in response . output . items ( ) : context [ k ] = v context [ 'output' ] = response . output context [ 'errors' ] = response . errors if self . _should_return : break return response or Response ( )
Execute the requests in the procedure
Params:
n_tries -- Number of tries in case of failure before raising a RuntimeError
Execute the requests in the procedure Params : n_tries -- Number of tries in case of failure before raising a RuntimeError
"""
        Execute the requests in the procedure
        Params:
            n_tries -- Number of tries in case of failure before raising a RuntimeError
        """ # noinspection PyAttributeOutsideInit
self
n_tries
__stack__