Makefile - transfer .py files instead of .pyc

histogram.py - now locks the histogram file before making a new one.
puzzler.py - fixed name error
mkpuzzles.py - now handles subdirectories
This commit is contained in:
Paul S. Ferrell 2009-10-15 15:22:07 -06:00
parent 72b6c9766d
commit cb7f0cc055
4 changed files with 28 additions and 16 deletions

View File

@ -1,21 +1,18 @@
DESTDIR = target DESTDIR = target
PYCDIR = $(DESTDIR)/usr/lib/python3.1/site-packages PYDIR = $(DESTDIR)/usr/lib/python3.1/site-packages
CTFDIR = $(DESTDIR)/usr/lib/ctf CTFDIR = $(DESTDIR)/usr/lib/ctf
WWWDIR = $(DESTDIR)/usr/lib/www WWWDIR = $(DESTDIR)/usr/lib/www
FAKE = fakeroot -s fake -i fake FAKE = fakeroot -s fake -i fake
INSTALL = $(FAKE) install INSTALL = $(FAKE) install
PYC = __init__.pyc
PYC += config.pyc points.pyc teams.pyc
PYC += register.pyc scoreboard.pyc puzzler.pyc
PYC += flagd.pyc pointsd.pyc pointscli.pyc
PYC += histogram.pyc irc.pyc
all: ctf.tce all: ctf.tce
target: $(PYC) push: ctf.tce
netcat -l -q 0 -p 3333 < ctf.tce
target:
$(INSTALL) -d --mode=0755 --owner=100 $(DESTDIR)/var/lib/ctf $(INSTALL) -d --mode=0755 --owner=100 $(DESTDIR)/var/lib/ctf
$(INSTALL) -d --mode=0755 --owner=100 $(DESTDIR)/var/lib/ctf/survey $(INSTALL) -d --mode=0755 --owner=100 $(DESTDIR)/var/lib/ctf/survey
@ -23,8 +20,8 @@ target: $(PYC)
$(INSTALL) -d $(DESTDIR)/var/lib/ctf/disabled $(INSTALL) -d $(DESTDIR)/var/lib/ctf/disabled
touch $(DESTDIR)/var/lib/ctf/disabled/survey touch $(DESTDIR)/var/lib/ctf/disabled/survey
$(INSTALL) -d $(PYCDIR)/ctf $(INSTALL) -d $(PYDIR)/ctf
$(INSTALL) $(PYC) $(PYCDIR)/ctf $(INSTALL) ctf/*.py $(PYDIR)/ctf
$(INSTALL) -d $(DESTDIR)/usr/lib/python2.6/site-packages/ctf $(INSTALL) -d $(DESTDIR)/usr/lib/python2.6/site-packages/ctf
$(INSTALL) ctf/__init__.py $(DESTDIR)/usr/lib/python2.6/site-packages/ctf $(INSTALL) ctf/__init__.py $(DESTDIR)/usr/lib/python2.6/site-packages/ctf
@ -55,7 +52,7 @@ ctf.tce: target
clean: clean:
rm -rf target rm -rf target
rm -f fake ctf.tce $(PYC) rm -f fake ctf.tce
ctf/%.pyc: ctf/%.py ctf/%.pyc: ctf/%.py
python3 -c 'from ctf import $(notdir $*)' python3 -c 'from ctf import $(notdir $*)'

View File

@ -1,5 +1,6 @@
#! /usr/bin/env python3 #! /usr/bin/env python3
import fcntl
import time import time
import os import os
import tempfile import tempfile
@ -64,8 +65,18 @@ plot %(plot)s\n''' % {'plot': ','.join(plotparts),
'pngout': pngout}) 'pngout': pngout})
instructions.flush() instructions.flush()
gp = os.system('gnuplot %s 2>/dev/null </dev/null' % instructions.name) lock = open('%s,lock' % pngout, 'a')
os.rename("%s,tmp" % pngout, pngout) try:
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
except:
return
try:
gp = os.system('gnuplot %s 2>/dev/null </dev/null' % instructions.name)
os.rename("%s,tmp" % pngout, pngout)
finally:
fcntl.flock(lock, fcntl.LOCK_UN)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -157,7 +157,7 @@ def main():
# Show available puzzles in category # Show available puzzles in category
show_puzzles(cat, cat_dir) show_puzzles(cat, cat_dir)
else: else:
thekeys = get_key(cat, points) thekey = get_key(cat, points)
if not teams.chkpasswd(team, passwd): if not teams.chkpasswd(team, passwd):
start_html('Wrong password') start_html('Wrong password')
end_html() end_html()

View File

@ -3,7 +3,7 @@
import os import os
import shutil import shutil
import optparse import optparse
import config from ctf import config
p = optparse.OptionParser() p = optparse.OptionParser()
p.add_option('-p', '--puzzles', dest='puzzles', default='puzzles', p.add_option('-p', '--puzzles', dest='puzzles', default='puzzles',
@ -83,7 +83,11 @@ for cat in os.listdir(opts.puzzles):
if files: if files:
f.write('<ul>\n') f.write('<ul>\n')
for fn, path in files: for fn, path in files:
shutil.copy(path, outdir) if os.path.isdir(path):
shutil.copytree(path, os.path.join(outdir, fn))
else:
shutil.copy(path, outdir)
if not fn.startswith(','): if not fn.startswith(','):
f.write('<li><a href="%s">%s</a></li>\n' % (fn, fn)) f.write('<li><a href="%s">%s</a></li>\n' % (fn, fn))
f.write('</ul>\n') f.write('</ul>\n')