mirror of https://github.com/dirtbags/moth.git
teams.py now writes the team color to file.
This commit is contained in:
parent
aa3e660ae6
commit
00de19c078
14
ctf/teams.py
14
ctf/teams.py
|
@ -28,9 +28,7 @@ def build_teams():
|
||||||
f = open(passwdfn)
|
f = open(passwdfn)
|
||||||
for line in f:
|
for line in f:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
team, passwd = [unquote(v) for v in line.strip().split('\t')]
|
team, passwd, color = map(unquote, line.strip().split('\t'))
|
||||||
color = team_colors.pop(0)
|
|
||||||
team_colors.append(color)
|
|
||||||
teams[team] = (passwd, color)
|
teams[team] = (passwd, color)
|
||||||
except IOError:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
|
@ -53,10 +51,15 @@ def exists(team):
|
||||||
return team in teams
|
return team in teams
|
||||||
|
|
||||||
def add(team, passwd):
|
def add(team, passwd):
|
||||||
|
build_teams()
|
||||||
|
color = team_colors[len(teams)%len(team_colors)]
|
||||||
|
|
||||||
|
assert team not in teams, "Team already exists."
|
||||||
|
|
||||||
f = open(passwdfn, 'a')
|
f = open(passwdfn, 'a')
|
||||||
fcntl.lockf(f, fcntl.LOCK_EX)
|
fcntl.lockf(f, fcntl.LOCK_EX)
|
||||||
f.seek(0, 2)
|
f.seek(0, 2)
|
||||||
f.write('%s\t%s\n' % (quote(team), quote(passwd)))
|
f.write('%s\t%s\t%s\n' % (quote(team), quote(passwd), quote(color)))
|
||||||
|
|
||||||
def color(team):
|
def color(team):
|
||||||
t = teams.get(team)
|
t = teams.get(team)
|
||||||
|
@ -66,6 +69,3 @@ def color(team):
|
||||||
if not t:
|
if not t:
|
||||||
return '888888'
|
return '888888'
|
||||||
return t[1]
|
return t[1]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue