-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdump-backup.py
More file actions
executable file
·48 lines (39 loc) · 1.77 KB
/
dump-backup.py
File metadata and controls
executable file
·48 lines (39 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from __future__ import with_statement
import sys,os, random, logging, re, time, codecs
from ConfigParser import ConfigParser
sys.path.append(os.path.join(os.path.dirname(__file__), "lib"))
from users import *
from questserver import QuestServer
from dispatcher import SmartDecoder
def DumpBackup():
configurator = ConfigParser()
assert "questserver.cfg" in configurator.read("questserver.cfg")
srv = QuestServer(configurator, True)
auth = srv.authorizer
out = codecs.lookup("utf-8")[3](sys.stdout)
for authstring, username in auth.users.iteritems():
user = auth.objects[username]
print >>out, "teamID: %s, user: %s\trole: %s\tauthstring: %s" \
% (user.profile.GetProperty("teamID").GetValue(), user.name, user.profile.GetProperty("role").GetValue(), authstring)
if isinstance(user, LegalUser):
userScore = srv.tracker.GetTeamScore(user.name)
print >>out, "\tscore: %s\n\tTask actions:" % userScore
qi = srv.tracker.teamActions.get(user.name, {})
for qId in sorted(qi):
act = qi[qId]
print >>out, "\t\ttask '%s' [%s]" % (qId, act.status)
for sol in sorted(act.solutions, key = lambda sol: sol.timeStamp):
try:
msg = "\t\t\t[%s]\tanswer: %s\tverdict: %s, %s" % (time.ctime(sol.timeStamp),
sol.actionString, sol.status, SmartDecoder.decode(sol.verdict))
if unicode(msg):
print >>out, msg
except:
logging.exception("")
def main():
logging.getLogger().setLevel(logging.DEBUG)
DumpBackup()
if __name__ == "__main__":
main()