pubsub: don't swallow output of subprocess to allow debug.

Swallowing is bad. baaad.
parent 34df4cb7
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
import argparse import argparse
import csv import csv
import httplib import httplib
import os
import socket import socket
import subprocess import subprocess
import sys import sys
...@@ -32,28 +31,23 @@ def main(): ...@@ -32,28 +31,23 @@ def main():
args = parser.parse_args() args = parser.parse_args()
with open(os.devnull) as devnull: try:
command = subprocess.Popen(args.executable[0], content = subprocess.check_output(
stdin=subprocess.PIPE, args.executable[0],
stdout=devnull, stderr=subprocess.STDOUT
stderr=subprocess.PIPE, )
close_fds=True) exit_code = 0
command.stdin.flush() except subprocess.CalledProcessError as e:
command.stdin.close() content = e.output
exit_code = e.returncode
command_failed = (command.wait() != 0)
command_stderr = command.stderr.read() print content
if command_failed: content += ("\n<p>Failed with returncode <em>%d</em>.</p>"
content = ("<p>Failed with returncode <em>%d</em>.</p>" "<p>Output is: </p><pre>%s</pre>" % (
"<p>Standard error output is :</p><pre>%s</pre>") % ( exit_code,
command.poll(), content.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
command_stderr.replace('&', '&amp;')\ ))
.replace('<', '&lt;')\
.replace('>', '&gt;'),
)
else:
content = "<p>Everything went well.</p>"
with open(args.logfile[0], 'a') as file_: with open(args.logfile[0], 'a') as file_:
cvsfile = csv.writer(file_) cvsfile = csv.writer(file_)
...@@ -64,9 +58,8 @@ def main(): ...@@ -64,9 +58,8 @@ def main():
'slapos:%s' % uuid.uuid4(), 'slapos:%s' % uuid.uuid4(),
]) ])
if command_failed: if exit_code != 0:
sys.stderr.write('%s\n' % command_stderr) sys.exit(exit_code)
sys.exit(1)
print 'Fetching %s feed...' % args.feed_url[0] print 'Fetching %s feed...' % args.feed_url[0]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment