Various changes to tanks run scripts.

This commit is contained in:
Paul S. Ferrell 2009-10-08 09:04:07 -06:00
parent 06fd1a2c87
commit adca40f63e
7 changed files with 61 additions and 9 deletions

View File

@ -24,7 +24,7 @@ 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 ln -s /var/lib/tanks/results 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/

View File

@ -1,10 +1,13 @@
#! /usr/bin/python #! /usr/bin/python
import time
import optparse import optparse
import shutil
import time
from tanks import Pflanzarr from tanks import Pflanzarr
T = 60*5 T = 60*5
MAX_HIST = 30
HIST_STEP = 100
parser = optparse.OptionParser('DATA_DIR easy|medium|hard MAX_TURNS') parser = optparse.OptionParser('DATA_DIR easy|medium|hard MAX_TURNS')
opts, args = parser.parse_args() opts, args = parser.parse_args()
@ -20,6 +23,21 @@ while True:
p = Pflanzarr.Pflanzarr(args[0], args[1]) p = Pflanzarr.Pflanzarr(args[0], args[1])
p.run(turns) p.run(turns)
path = os.path.join(args[0], 'results')
files = os.listdir(path)
gameNums = []
for file in files:
try:
gameNums.append( int(file) )
except:
continue
gameNums.sort(reverse=True)
highest = gameNums[0]
for num in gameNums:
if highest - MAX_HIST > num and not (num % HIST_STEP == 0):
shutil.rmtree(os.path.join(path, num))
diff = time.time() - start diff = time.time() - start
if diff - T > 0: if diff - T > 0:
time.sleep( diff - T ) time.sleep( diff - T )

View File

@ -28,22 +28,28 @@ except:
if not games: if not games:
print "<p>No games have occurred yet." print "<p>No games have occurred yet."
gameNums = [] gameNums = []
for game in games: for game in games:
try: try:
num = int(game) gameNums.append( int(game) )
path = os.path.join( 'results', game, 'results.html')
if os.path.exists( path ):
gameNums.append( int(num) )
else:
continue
except: except:
continue continue
gameNums.sort(reverse=True) gameNums.sort(reverse=True)
# Don't include games that haven't completed
i = 0
num = str(gameNums[i])
for i in range(len(gameNums)):
path = os.path.join( 'results', str(gameNums[i]), 'results.html') )
if os.path.exists( path ):
break
gameNums = gameNums[i:]
for num in gameNums: for num in gameNums:
print '<p>%d - ' % num, print '<p>%d - ' % num,
print '<a href="results/%d/game.avi">v</a>' % num, print '<a href="results/%d/game.avi">v</a>' % num,
print '<a href="results/%d/results.html">r</a>' % num print '<a href="results/%d/results.html">r</a>' % num
print '</body></html>'

20
tanksFlagger/Makefile Normal file
View File

@ -0,0 +1,20 @@
FAKE = fakeroot -s fake -i fake
INSTALL = $(FAKE) install -o 100
all: tanksFlagger.tce
push: tanksFlagger.tce
netcat -l -q 0 -p 3333 < tanksFlagger.tce
tanksFlagger.tce: target
$(FAKE) sh -c 'cd target && tar -czf - .' > $@
target:
$(INSTALL) -d target/var/service/tanksFlagger
$(INSTALL) run report_score.py target/var/service/tanksFlagger/
$(INSTALL) -d target/var/service/tanksFlagger/log/
$(INSTALL) log.run target/var/service/tanksFlagger/log/run
clean:
rm -rf target tanksFlagger.tce fake

3
tanksFlagger/log.run Executable file
View File

@ -0,0 +1,3 @@
#! /bin/sh
exec logger -t tanksFlagger

5
tanksFlagger/run Executable file
View File

@ -0,0 +1,5 @@
#! /bin/sh
[ -f /var/lib/ctf/disabled/tanks ] && exit 0
exec envuidgid ctf python3 report_score.py 2>&1