Пример #1
0
 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!
Пример #2
0
  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()
    #sender.proc_dispatch(proc_id=self.runid, output_id="log",  
    #                     body=msg)