From 00de19c0784940269236670e58ff7d54bef666ee Mon Sep 17 00:00:00 2001 From: "Paul S. Ferrell" Date: Wed, 7 Oct 2009 12:28:33 -0600 Subject: [PATCH] teams.py now writes the team color to file. --- ctf/teams.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ctf/teams.py b/ctf/teams.py index 29ed25b..90b6216 100755 --- a/ctf/teams.py +++ b/ctf/teams.py @@ -28,9 +28,7 @@ def build_teams(): f = open(passwdfn) for line in f: line = line.strip() - team, passwd = [unquote(v) for v in line.strip().split('\t')] - color = team_colors.pop(0) - team_colors.append(color) + team, passwd, color = map(unquote, line.strip().split('\t')) teams[team] = (passwd, color) except IOError: pass @@ -53,10 +51,15 @@ def exists(team): return team in teams 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') fcntl.lockf(f, fcntl.LOCK_EX) 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): t = teams.get(team) @@ -66,6 +69,3 @@ def color(team): if not t: return '888888' return t[1] - - -