bot-status.py: Simplify favicon handling
We were treating the favicon as a per server thing
but there's only one per page.
Also correct the parameter name of bot_status.
config_file was never used and the function only worked
because it got config from the globals.
Change-Id: I77465a839c6203742870696f43bb55933d916dad
diff --git a/monitor/bot-status.py b/monitor/bot-status.py
index 25ca4fe..9ca4092 100755
--- a/monitor/bot-status.py
+++ b/monitor/bot-status.py
@@ -116,7 +116,7 @@
return status
-def bot_status(config_file, output_file):
+def bot_status(config, output_file):
temp = tempfile.NamedTemporaryFile(mode='w+', delete=False)
today = "{}\n".format(datetime.today().ctime())
@@ -125,6 +125,9 @@
# Get status for all bots
bot_cache = {}
+ # Whether we should show the fail favicon
+ found_failure = False
+
for server in filter(not_ignored, config):
base_url = server['base_url']
builder_url = server['builder_url']
@@ -140,18 +143,19 @@
status = get_bot_status(session, bot['name'], base_url, builder_url,
build_url)
if not_ignored(bot):
- fail = 'fail' in status
+ found_failure |= status['fail']
logging.debug(" FAIL" if status['fail'] else " PASS")
bot_cache[bot_key] = status
+ temp.write("<link rel=\"shortcut icon\" href=\"{}\" "
+ "type=\"image/x-icon\"/>\n".format(
+ 'fail.ico' if found_failure else 'ok.ico'))
+
# Dump all servers / bots
for server in filter(not_ignored, config):
base_url = server['base_url']
builder_url = server['builder_url']
build_url = server['build_url']
- favicon = 'fail.ico' if fail else 'ok.ico'
- temp.write("<link rel=\"shortcut icon\" href=\"{}\" "
- "type=\"image/x-icon\"/>\n".format(favicon))
temp.write("<table cellspacing=1 cellpadding=2>\n")
temp.write("<tr><td colspan=5> </td><tr>\n")
temp.write("<tr><th colspan=5>{} @ {}</td><tr>\n"