def send_output_buffer(self): '''sends the processes (partial) stdout/stderr output to an AMQP server''' msg = AirMessage(payload=AirProcessOutput(stdout=True, stderr=True, streamfragment=self.buffer)) self.sender.proc_dispatch(proc_id=self.runid, output_id="output", body=msg.as_json_string()) self.last_send = time.time() return True #implement false case in case sending fails!
except amqp.AMQPException, ex: root_logger.error("AMQP connection error: "+options.amqp_host+": "+str(ex)+utils.get_traceback()) sys.exit(70) # BSD EX_SOFTWARE try: oldstate = None if not options.capture_stdout and not options.capture_stderr: p = subprocess.Popen(cmdline) elif options.capture_stdout and not options.capture_stderr: p = subprocess.Popen(cmdline, stdout=subprocess.PIPE) elif not options.capture_stdout and options.capture_stderr: p = subprocess.Popen(cmdline, stderr=subprocess.PIPE) elif options.capture_stdout and options.capture_stderr: p = subprocess.Popen(cmdline, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) m = AirMessage(payload=AirProcessStateChange(oldstate="NONE", newstate="RUNNING")) sender.proc_dispatch(proc_id=options.proc_id, output_id="state", body=m.as_json_string()) oldstate = "RUNNING" except OSError, ex: logger = logging.getLogger() logger.error("Error running "+str(cmdline)+": "+str(ex)+get_traceback()) msg = "Error running {!r}: {!r} {!r}".format(str(cmdline), str(ex), get_traceback(ENENABLE_TRACEBACKS)) #lm = AirMessage(payload=AirLogevent()