bot-status.py: Handle missing bots
Bots are a bit of a mess right now which is the
perfect time to add this code.
Just put a single cell saying that the bot is offline.
Change-Id: I23d149030173021b245ee92781c3fbb801608fa3
diff --git a/monitor/bot-status.py b/monitor/bot-status.py
index a603c02..0a3bf27 100755
--- a/monitor/bot-status.py
+++ b/monitor/bot-status.py
@@ -137,8 +137,9 @@
logging.debug(' Parsing bot {}...'.format(bot['name']))
status = get_bot_status(session, bot['name'], base_url, server['builder_url'],
server['build_url'])
- logging.debug(" FAIL" if status['fail'] else " PASS")
- bot_cache[bot_key] = status
+ if status is not None:
+ logging.debug(" FAIL" if status['fail'] else " PASS")
+ bot_cache[bot_key] = status
return bot_cache
@@ -166,7 +167,12 @@
"<th>Failing steps</th></tr>\n")
for bot in builder['bots']:
temp.write("<tr>\n")
- status = bots_status[(base_url, bot['name'])]
+ try:
+ status = bots_status[(base_url, bot['name'])]
+ except KeyError:
+ temp.write(" <td>{} is offline!</td>".format(bot['name']))
+ continue
+
found_failure |= status['fail']
url = "{}/#/{}/{}".format(base_url, builder_url, status['builderid'])
temp.write(" <td><a href='{}'>{}</a></td>\n".format(url, bot['name']))