def run(self, commands): """ A static method that will execute the given list of commands in parallel and will return the list of command results. """ # Gather the results (in parallel) results = [] for index in range(len(commands)): tag = '%s:%d' % (str(self.id), index) # Store the result result = CommandResult(tag) result.command = common.humanify_command(commands[index]) results.append(result) # Run the command instance.send_command(result, 'mon', '', json.dumps(commands[index]), tag) return results
def run(self, commands): """ A static method that will execute the given list of commands in parallel and will return the list of command results. """ # Gather the results (in parallel) results = [] for index in range(len(commands)): tag = '%s:%d' % (str(self.id), index) # Store the result result = CommandResult(tag) result.command = common.humanify_command(commands[index]) results.append(result) # Run the command instance.send_command(result, 'mon', '', json.dumps(commands[index]), tag) return results
def __json__(self): return { 'id': self.id, 'running': map( lambda x: { 'command': x.command, 'outs': x.outs, 'outb': x.outb, }, self.running ), 'finished': map( lambda x: { 'command': x.command, 'outs': x.outs, 'outb': x.outb, }, self.finished ), 'waiting': map( lambda x: map( lambda y: common.humanify_command(y), x ), self.waiting ), 'failed': map( lambda x: { 'command': x.command, 'outs': x.outs, 'outb': x.outb, }, self.failed ), 'is_waiting': self.is_waiting(), 'is_finished': self.is_finished(), 'has_failed': self.has_failed(), 'state': self.get_state(), }
def __json__(self): return { 'id': self.id, 'running': map( lambda x: { 'command': x.command, 'outs': x.outs, 'outb': x.outb, }, self.running), 'finished': map( lambda x: { 'command': x.command, 'outs': x.outs, 'outb': x.outb, }, self.finished), 'waiting': map(lambda x: map(lambda y: common.humanify_command(y), x), self.waiting), 'failed': map( lambda x: { 'command': x.command, 'outs': x.outs, 'outb': x.outb, }, self.failed), 'is_waiting': self.is_waiting(), 'is_finished': self.is_finished(), 'has_failed': self.has_failed(), 'state': self.get_state(), }