summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFathi Boudra <fathi.boudra@linaro.org>2012-04-23 19:48:31 +0300
committerFathi Boudra <fathi.boudra@linaro.org>2012-04-23 19:48:31 +0300
commite1d1cf18aba26819d35eab3894d169b7e3a78194 (patch)
tree6d38cacdd5145a34ae227252d481985bee273218
parent23e2ba017e5b81b6887c4db3879df848bc467456 (diff)
downloadsnowball-binary-update-e1d1cf18aba26819d35eab3894d169b7e3a78194.tar.gz
Obfuscate HTTP credentials present in URL shown by xmlrpclib in error messages.
-rwxr-xr-xpost-build-lava.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/post-build-lava.py b/post-build-lava.py
index 41cb4aa..d85c78b 100755
--- a/post-build-lava.py
+++ b/post-build-lava.py
@@ -1,10 +1,14 @@
-#!/usr/bin/env python
+#!/usr/bin/python
import os
import sys
import json
import xmlrpclib
import urllib2
+import re
+
+def obfuscate_credentials(s):
+ return re.sub(r"([^ ]:).+?(@)", r"\1xxx\2", s)
def main():
"""Script entry point: return some JSON based on calling args.
@@ -128,8 +132,13 @@ def main():
skip_lava = os.environ.get("SKIP_LAVA")
if skip_lava == None:
- server = xmlrpclib.ServerProxy("https://{lava_user:>s}:{lava_token:>s}@{lava_server:>s}".format(lava_user=lava_user, lava_token=lava_token, lava_server=lava_server))
- lava_job_id = server.scheduler.submit_job(config)
+ try:
+ server = xmlrpclib.ServerProxy("https://{lava_user:>s}:{lava_token:>s}@{lava_server:>s}".format(lava_user=lava_user, lava_token=lava_token, lava_server=lava_server))
+ lava_job_id = server.scheduler.submit_job(config)
+ except xmlrpclib.ProtocolError, e:
+ print "Error making a LAVA request:", obfuscate_credentials(str(e))
+ sys.exit(1)
+
print "LAVA Job Id: %s, URL: http://%s/scheduler/job/%s" % (lava_job_id, lava_server_root, lava_job_id)
json.dump({'lava_url': "http://" + lava_server_root,
'job_id': lava_job_id},