Twiddled run_tanks.py (don't hurt me, Paul)

This commit is contained in:
Neale Pickett 2009-10-07 21:22:16 -06:00
parent 42153af67f
commit 62006499e3
4 changed files with 22 additions and 19 deletions

View File

@ -4,6 +4,6 @@
# No problem, traceroute can send a UDP packet too. # No problem, traceroute can send a UDP packet too.
while true; do while true; do
# Apparently traceroute adds 1 to the base port (-p) # 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 sleep 10
done done

View File

@ -24,12 +24,14 @@ target:
$(INSTALL) -d target/usr/lib/www/tanks/ $(INSTALL) -d target/usr/lib/www/tanks/
$(INSTALL) www/* 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) -d target/usr/lib/python2.6/site-packages/tanks/
$(INSTALL) lib/* 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) -d target/var/service/tanks
$(INSTALL) run run_tanks.py target/var/service/tanks/ $(INSTALL) run run_tanks.py target/var/service/tanks/
$(INSTALL) -d target/var/service/tanks/log/ $(INSTALL) -d target/var/service/tanks/log/
$(INSTALL) log.run target/var/service/tanks/log/run $(INSTALL) log.run target/var/service/tanks/log/run

View File

@ -2,7 +2,5 @@
[ -f /var/lib/ctf/disabled/tanks ] && exit 0 [ -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 #envuidgid ctf report_score.py 2>&1

31
tanks/run_tanks.py Normal file → Executable file
View File

@ -1,22 +1,25 @@
#! /usr/bin/python
import time import time
import optparse
from tanks import Pflanzarr from tanks import Pflanzarr
import sys
T = 60*5 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: try:
while 1: turns = int(args[2])
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 )
except: except:
import traceback parser.error('Invalid number of turns')
traceback.print_exc()
print 'Usage: python2.6 run_tanks.py data_dir easy|medium|hard max_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 )