From 62006499e3a6cf53e70c9259ec88d203cdaf6407 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Wed, 7 Oct 2009 21:22:16 -0600 Subject: [PATCH] Twiddled run_tanks.py (don't hurt me, Paul) --- heartbeatd/run.heartbeat | 2 +- tanks/Makefile | 4 +++- tanks/run | 4 +--- tanks/run_tanks.py | 31 +++++++++++++++++-------------- 4 files changed, 22 insertions(+), 19 deletions(-) mode change 100644 => 100755 tanks/run_tanks.py diff --git a/heartbeatd/run.heartbeat b/heartbeatd/run.heartbeat index 3e4f37e..f7704d8 100755 --- a/heartbeatd/run.heartbeat +++ b/heartbeatd/run.heartbeat @@ -4,6 +4,6 @@ # No problem, traceroute can send a UDP packet too. while true; do # Apparently traceroute adds 1 to the base port (-p) - traceroute -m 2 -q 1 -p 8 10.0.0.1 + traceroute -m 2 -q 1 -p 8 10.0.0.1 2>/dev/null >/dev/null sleep 10 done diff --git a/tanks/Makefile b/tanks/Makefile index 26715cd..1310b71 100644 --- a/tanks/Makefile +++ b/tanks/Makefile @@ -24,12 +24,14 @@ target: $(INSTALL) -d target/usr/lib/www/tanks/ $(INSTALL) www/* target/usr/lib/www/tanks/ + ln -s /var/lib/tanks target/usr/lib/www/tanks/results + $(INSTALL) -d target/usr/lib/python2.6/site-packages/tanks/ $(INSTALL) lib/* target/usr/lib/python2.6/site-packages/tanks/ $(INSTALL) -d target/var/service/tanks $(INSTALL) run run_tanks.py target/var/service/tanks/ - + $(INSTALL) -d target/var/service/tanks/log/ $(INSTALL) log.run target/var/service/tanks/log/run diff --git a/tanks/run b/tanks/run index 25540a2..5a5b932 100755 --- a/tanks/run +++ b/tanks/run @@ -2,7 +2,5 @@ [ -f /var/lib/ctf/disabled/tanks ] && exit 0 -ln -s /var/lib/tanks /usr/lib/www/tanks/results - -exec envuidgid ctf python2.6 run_tanks.py /var/lib/tanks/ easy 100 2>&1 & +exec envuidgid ctf python2.6 run_tanks.py /var/lib/tanks/ easy 100 2>&1 #envuidgid ctf report_score.py 2>&1 diff --git a/tanks/run_tanks.py b/tanks/run_tanks.py old mode 100644 new mode 100755 index 47b31ed..11c792a --- a/tanks/run_tanks.py +++ b/tanks/run_tanks.py @@ -1,22 +1,25 @@ +#! /usr/bin/python + import time +import optparse from tanks import Pflanzarr -import sys T = 60*5 +parser = optparse.OptionParser('DATA_DIR easy|medium|hard MAX_TURNS') +opts, args = parser.parse_args() +if (len(args) != 3) or (args[1] not in ('easy', 'medium', 'hard')): + parser.error('Wrong number of arguments') try: - while 1: - start = time.time() - p = Pflanzarr.Pflanzarr(sys.argv[1], sys.argv[2]) - p.run(int(sys.argv[3])) - - diff = time.time() - start - if diff - T > 0: - time.sleep( diff - T ) - + turns = int(args[2]) except: - import traceback - traceback.print_exc() - print 'Usage: python2.6 run_tanks.py data_dir easy|medium|hard max_turns' + parser.error('Invalid number of turns') - +while True: + start = time.time() + p = Pflanzarr.Pflanzarr(args[0], args[1]) + p.run(turns) + + diff = time.time() - start + if diff - T > 0: + time.sleep( diff - T )