doit/action.py
def execute(self, out=None, err=None):
        """Execute command action

        both stdout and stderr from the command are captured and saved
        on self.out/err. Real time output is controlled by parameters
        @param out: None - no real time output
                    a file like object (has write method)
        @param err: idem

        @return failure: see CmdAction.execute
        """
        # set std stream
        old_stdout = sys.stdout
        output = StringIO()
        out_writer = Writer()
        # capture output but preserve isatty() from original stream
        out_writer.add_writer(output, old_stdout.isatty())
        if out:
            out_writer.add_writer(out)
        sys.stdout = out_writer

        old_stderr = sys.stderr
        errput = StringIO()
        err_writer = Writer()
        err_writer.add_writer(errput, old_stderr.isatty())
        if err:
            err_writer.add_writer(err)
        sys.stderr = err_writer

        kwargs = self._prepare_kwargs()

        # execute action / callable
        try:
            returned_value = self.py_callable(*self.args, **kwargs)
        except Exception as exception:
            if self.pm_pdb: # pragma: no cover
                # start post-mortem debugger
                deb = pdb.Pdb(stdin=sys.__stdin__, stdout=sys.__stdout__)
                deb.reset()
                deb.interaction(None, sys.exc_info()[2])
            return TaskError("PythonAction Error", exception)
        finally:
            # restore std streams /log captured streams
            sys.stdout = old_stdout
            sys.stderr = old_stderr
            self.out = output.getvalue()
            self.err = errput.getvalue()

        # if callable returns false. Task failed
        if returned_value is False:
            return TaskFailed("Python Task failed: '%s' returned %s" %
                              (self.py_callable, returned_value))
        elif returned_value is True or returned_value is None:
            pass
        elif isinstance(returned_value, str):
            self.result = returned_value
        elif isinstance(returned_value, dict):
            self.values = returned_value
            self.result = returned_value
        elif isinstance(returned_value, (TaskFailed, TaskError)):
            return returned_value
        else:
            return TaskError("Python Task error: '%s'. It must return:\n"
                             "False for failed task.\n"
                             "True, None, string or dict for successful task\n"
                             "returned %s (%s)" %
                             (self.py_callable, returned_value,
                              type(returned_value)))
Execute command action

        both stdout and stderr from the command are captured and saved
        on self.out/err. Real time output is controlled by parameters
        @param out: None - no real time output
                    a file like object (has write method)
        @param err: idem

        @return failure: see CmdAction.execute
        
Execute command action
both stdout and stderr from the command are captured and saved
on self.out/err. Real time output is controlled by parameters
@param out: None - no real time output
a file like object (has write method)
@param err: idem


Execute command action both stdout and stderr from the command are captured and saved on self . out / err . Real time output is controlled by parameters @param out : None - no real time output a file like object ( has write method ) @param err : idem
def execute(self, out=None, err=None):
        old_stdout = sys.stdout
        output = StringIO()
        out_writer = Writer()
        out_writer.add_writer(output, old_stdout.isatty())
        if out:
            out_writer.add_writer(out)
        sys.stdout = out_writer
        old_stderr = sys.stderr
        errput = StringIO()
        err_writer = Writer()
        err_writer.add_writer(errput, old_stderr.isatty())
        if err:
            err_writer.add_writer(err)
        sys.stderr = err_writer
        kwargs = self._prepare_kwargs()
        try:
            returned_value = self.py_callable(*self.args, **kwargs)
        except Exception as exception:
            if self.pm_pdb: 
                deb = pdb.Pdb(stdin=sys.__stdin__, stdout=sys.__stdout__)
                deb.reset()
                deb.interaction(None, sys.exc_info()[2])
            return TaskError("PythonAction Error", exception)
        finally:
            sys.stdout = old_stdout
            sys.stderr = old_stderr
            self.out = output.getvalue()
            self.err = errput.getvalue()
        if returned_value is False:
            return TaskFailed("Python Task failed: '%s' returned %s" %
                              (self.py_callable, returned_value))
        elif returned_value is True or returned_value is None:
            pass
        elif isinstance(returned_value, str):
            self.result = returned_value
        elif isinstance(returned_value, dict):
            self.values = returned_value
            self.result = returned_value
        elif isinstance(returned_value, (TaskFailed, TaskError)):
            return returned_value
        else:
            return TaskError("Python Task error: '%s'. It must return:\n"
                             "False for failed task.\n"
                             "True, None, string or dict for successful task\n"
                             "returned %s (%s)" %
                             (self.py_callable, returned_value,
                              type(returned_value)))
def execute ( self , out = None , err = None ) : old_stdout = sys . stdout output = StringIO ( ) out_writer = Writer ( ) out_writer . add_writer ( output , old_stdout . isatty ( ) ) if out : out_writer . add_writer ( out ) sys . stdout = out_writer old_stderr = sys . stderr errput = StringIO ( ) err_writer = Writer ( ) err_writer . add_writer ( errput , old_stderr . isatty ( ) ) if err : err_writer . add_writer ( err ) sys . stderr = err_writer kwargs = self . _prepare_kwargs ( ) try : returned_value = self . py_callable ( * self . args , ** kwargs ) except Exception as exception : if self . pm_pdb : deb = pdb . Pdb ( stdin = sys . __stdin__ , stdout = sys . __stdout__ ) deb . reset ( ) deb . interaction ( None , sys . exc_info ( ) [ 2 ] ) return TaskError ( "PythonAction Error" , exception ) finally : sys . stdout = old_stdout sys . stderr = old_stderr self . out = output . getvalue ( ) self . err = errput . getvalue ( ) if returned_value is False : return TaskFailed ( "Python Task failed: '%s' returned %s" % ( self . py_callable , returned_value ) ) elif returned_value is True or returned_value is None : pass elif isinstance ( returned_value , str ) : self . result = returned_value elif isinstance ( returned_value , dict ) : self . values = returned_value self . result = returned_value elif isinstance ( returned_value , ( TaskFailed , TaskError ) ) : return returned_value else : return TaskError ( "Python Task error: '%s'. It must return:\n" "False for failed task.\n" "True, None, string or dict for successful task\n" "returned %s (%s)" % ( self . py_callable , returned_value , type ( returned_value ) ) )
Execute command action
both stdout and stderr from the command are captured and saved
on self.out/err.
Execute command action both stdout and stderr from the command are captured and saved on self . out / err .
"""Execute command action

        both stdout and stderr from the command are captured and saved
        on self.out/err. Real time output is controlled by parameters
        @param out: None - no real time output
                    a file like object (has write method)
        @param err: idem

        @return failure: see CmdAction.execute
        """ # set std stream # capture output but preserve isatty() from original stream # execute action / callable # pragma: no cover # start post-mortem debugger # restore std streams /log captured streams # if callable returns false. Task failed
self
out
err