Beispiel #1
0
class example(BaseRecipe):
    inputs = {
        'executable':
        ExecField('--executable', help="Command to run", default="/bin/ls")
    }

    outputs = {'stdout': StringField()}

    def go(self):
        self.logger.info("Starting example recipe run")
        super(example, self).go()

        self.logger.info("This is a log message")

        my_process = subprocess.Popen([self.inputs['executable']],
                                      stdout=subprocess.PIPE,
                                      stderr=subprocess.PIPE)
        sout, serr = communicate_returning_strings(my_process)
        self.outputs['stdout'] = sout
        log_process_output(self.inputs['executable'], sout, serr, self.logger)

        if my_process.returncode == 0:
            return 0
        else:
            self.logger.warn("Return code (%d) is not 0." %
                             my_process.returncode)
            return 1
Beispiel #2
0
 def setUp(self):
     from lofarpipe.support.lofaringredient import ExecField
     self.execfield = ExecField(default='/bin/ls')