llvm monitor: Properly raise http errors
Before we always tried to decode to json regardless,
but expected to catch a requests exception.
What actually happens is you get a json exception if
you try to decode the (preumably None) json from a response
like a 504.
Also label the bot status logging so it doesn't look like
it's saying the request failed.
Change-Id: Id5ec57dfba56fa2dc5e5cb4ad72e9640416bea04
diff --git a/monitor/bot-status.py b/monitor/bot-status.py
index e38bc59..5a54299 100755
--- a/monitor/bot-status.py
+++ b/monitor/bot-status.py
@@ -33,7 +33,9 @@
# Returns the parsed json URL or raises an exception
def wget(session, url):
- return session.get(url).json()
+ got = session.get(url)
+ got.raise_for_status()
+ return got.json()
# Returns a string with the GIT revision usesd on build BUILDID and
@@ -45,6 +47,7 @@
"{}/api/v2/builds/{}/changes"
.format(base_url, bid))
except requests.exceptions.RequestException:
+ logging.debug(" Couldn't get changes for build {}!".format(buildid))
return None
changes = contents['changes']
if changes:
@@ -147,7 +150,7 @@
status = get_bot_status(session, bot['name'], base_url, server['builder_url'],
server['build_url'])
if status is not None:
- logging.debug(" FAIL" if status['fail'] else " PASS")
+ logging.debug(" Bot status: " + ("FAIL" if status['fail'] else "PASS"))
bot_cache[bot_key] = status
return bot_cache