From fdf76ed8471dcd6906b08ec16e0e57c938b88dfb Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Fri, 9 Oct 2009 08:55:51 -0600 Subject: [PATCH] Pollster does much quicker HTML updates now --- new-contest | 2 ++ pollster/pollster.py | 20 +++++--------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/new-contest b/new-contest index 2325e44..55e8afc 100755 --- a/new-contest +++ b/new-contest @@ -13,6 +13,8 @@ rotate /var/lib/ctf/scores.dat rotate /var/lib/ctf/passwd rm -f /var/lib/ctf/flags/* || true +sv restart /var/service/ctf + echo "Things you may want to tweak:" find /var/lib/ctf/disabled find /var/lib/kevin/tokens diff --git a/pollster/pollster.py b/pollster/pollster.py index 395e5a8..baa3128 100755 --- a/pollster/pollster.py +++ b/pollster/pollster.py @@ -2,6 +2,7 @@ import os import re +import io import sys import time import socket @@ -146,22 +147,9 @@ while True: t_start = time.time() # gather the list of IPs to poll - try: - ips = os.listdir(IP_DIR) - except Exception as e: - print('pollster: could not list dir %s (%s)' % (IP_DIR, e)) - traceback.print_exc() - - try: - os.remove(REPORT_PATH) - except Exception as e: - pass - - try: - out = open(REPORT_PATH, 'w') - except Exception as e: - out = None + ips = os.listdir(IP_DIR) + out = io.StringIO() out.write(config.start_html('Team Service Availability')) for ip in ips: # check file name format is ip @@ -213,6 +201,8 @@ while True: out.write(config.end_html()) out.close() + open(REPORT_PATH, 'w').write(out.getvalue()) + # sleep until its time to poll again time.sleep(sleep_time)