Пример #1
0
class Executer(object):
    def __init__(self, command, working_dir=None):
        self.command = command
        self.working_dir = working_dir
    
    def execute(self):
        self.result = ExecuteResult(command=self.command)
        self.result.status = Status.running
        self.process = Popen (self.command, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
    
    def poll(self):
        exit_code = self.process.poll()
        self.result.log += recv_some(self.process, e=0)

        if exit_code is None:
            return False
        
        if int(exit_code) > 0:
            self.result.status = Status.fail

        if int(exit_code) == 0:
            self.result.status = Status.success

        self.result.exit_code = exit_code
        last_log = self.process.communicate()[0]
        self.result.log = last_log and last_log or self.result.log
        return exit_code is not None
Пример #2
0
 def execute(self):
     self.result = ExecuteResult(command=self.command)
     self.result.status = Status.running
     self.process = Popen (self.command, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT)