|
|
|
@ -3,6 +3,23 @@
|
|
|
|
|
import zmq, msgpack, time, psutil, yaml, os, subprocess
|
|
|
|
|
from collections import namedtuple
|
|
|
|
|
|
|
|
|
|
# Horrible hack to make check_output exist in 2.6
|
|
|
|
|
# http://stackoverflow.com/a/13160748/1332715
|
|
|
|
|
if "check_output" not in dir( subprocess ): # duck punch it in!
|
|
|
|
|
def f(*popenargs, **kwargs):
|
|
|
|
|
if 'stdout' in kwargs:
|
|
|
|
|
raise ValueError('stdout argument not allowed, it will be overridden.')
|
|
|
|
|
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
|
|
|
|
|
output, unused_err = process.communicate()
|
|
|
|
|
retcode = process.poll()
|
|
|
|
|
if retcode:
|
|
|
|
|
cmd = kwargs.get("args")
|
|
|
|
|
if cmd is None:
|
|
|
|
|
cmd = popenargs[0]
|
|
|
|
|
raise subprocess.CalledProcessError(retcode, cmd)
|
|
|
|
|
return output
|
|
|
|
|
subprocess.check_output = f
|
|
|
|
|
|
|
|
|
|
ctx = zmq.Context()
|
|
|
|
|
|
|
|
|
|
sock = ctx.socket(zmq.PUSH)
|
|
|
|
|