mirror of https://github.com/dirtbags/moth.git
Various changes to tanks run scripts.
This commit is contained in:
parent
06fd1a2c87
commit
adca40f63e
|
@ -24,7 +24,7 @@ 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
|
||||
ln -s /var/lib/tanks/results 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/
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
import time
|
||||
import optparse
|
||||
import shutil
|
||||
import time
|
||||
from tanks import Pflanzarr
|
||||
|
||||
T = 60*5
|
||||
MAX_HIST = 30
|
||||
HIST_STEP = 100
|
||||
|
||||
parser = optparse.OptionParser('DATA_DIR easy|medium|hard MAX_TURNS')
|
||||
opts, args = parser.parse_args()
|
||||
|
@ -20,6 +23,21 @@ while True:
|
|||
p = Pflanzarr.Pflanzarr(args[0], args[1])
|
||||
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
|
||||
if diff - T > 0:
|
||||
time.sleep( diff - T )
|
||||
|
|
|
@ -28,22 +28,28 @@ except:
|
|||
|
||||
if not games:
|
||||
print "<p>No games have occurred yet."
|
||||
|
||||
gameNums = []
|
||||
for game in games:
|
||||
try:
|
||||
num = int(game)
|
||||
path = os.path.join( 'results', game, 'results.html')
|
||||
if os.path.exists( path ):
|
||||
gameNums.append( int(num) )
|
||||
else:
|
||||
continue
|
||||
|
||||
gameNums.append( int(game) )
|
||||
except:
|
||||
continue
|
||||
|
||||
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:
|
||||
print '<p>%d - ' % num,
|
||||
print '<a href="results/%d/game.avi">v</a>' % num,
|
||||
print '<a href="results/%d/results.html">r</a>' % num
|
||||
|
||||
print '</body></html>'
|
||||
|
|
|
@ -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
|
|
@ -0,0 +1,3 @@
|
|||
#! /bin/sh
|
||||
|
||||
exec logger -t tanksFlagger
|
|
@ -0,0 +1,5 @@
|
|||
#! /bin/sh
|
||||
|
||||
[ -f /var/lib/ctf/disabled/tanks ] && exit 0
|
||||
|
||||
exec envuidgid ctf python3 report_score.py 2>&1
|
Loading…
Reference in New Issue