Commit 5ecc34b2 authored by Marco Mariani's avatar Marco Mariani

bubble up errors from subprocesses

parent d4c77c66
......@@ -40,11 +40,14 @@ def main():
command.stdin.flush()
command.stdin.close()
if command.wait() != 0:
command_failed = (command.wait() != 0)
command_stderr = command.stderr.read()
if command_failed:
content = ("<p>Failed with returncode <em>%d</em>.</p>"
"<p>Standard error output is :</p><pre>%s</pre>") % (
command.poll(),
command.stderr.read().replace('&', '&amp;')\
command_stderr.replace('&', '&amp;')\
.replace('<', '&lt;')\
.replace('>', '&gt;'),
)
......@@ -60,10 +63,14 @@ def main():
'slapos:%s' % uuid.uuid4(),
])
if command_failed:
sys.stderr.write('%s\n' % command_stderr)
sys.exit(1)
feed = urllib2.urlopen(args.feed_url[0])
body = feed.read()
failed = False
some_notification_failed = False
for notif_url in args.notification_url:
notification_url = urlparse.urlparse(notif_url)
notification_port = notification_url.port
......@@ -79,9 +86,9 @@ def main():
if not (200 <= response.status < 300):
sys.stderr.write("The remote server at %s didn't send a successful reponse.\n" % notif_url)
sys.stderr.write("Its response was %r\n" % response.reason)
failed = True
some_notification_failed = True
if failed:
if some_notification_failed:
sys.exit(1)
if __name__ == '__main__':
......
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