While the following code works great to call a python script and get the output:
s = spawn 'python', ['-u', 'foo.py']
s.stdout.on 'data', (data) -> msg.send data.toString()
s.stderr.on 'data', (data) -> msg.send data.toString()
foo.py returns many different responses (it returns updates as it runs).
For instance:
def function1():
print "Function 1 complete"
def function2():
print "Function 2 complete"
function1()
function2()
Hubot does not display those results in a consistent order. I know this can happen if msg.send
is called multiple times.
While I know I could re-write foo.py to behave differently, other processes depend on foo.py and I can't alter its behavior.
I was wondering what the process might be to collect the responses as they come and send a single msg.send
in hopes that a single call to msg.send will preserve the order of the process outputs.