Exemplo n.º 1
0
    def __init__(self, args):
        CmdBase.__init__(self, args)

        glist = sr.groups.list()

        for gname in glist:
            if re.match( "^college-[0-9]+$", gname ) == None:
                continue

            g = sr.group(gname)

            if hasattr(g, "desc"):
                desc = g.desc
            else:
                desc = "(no description)"

            print "%s: %s" % (gname, desc)
            print "\t %i members." % len(g.members)

            teams = set()
            for uname in g.members:
                u = sr.user(uname)
                assert u.in_db

                for gname in u.groups():
                    if re.match( "^team[0-9]+$", gname ) != None:
                        teams.add(gname)

            print "\t %i teams: %s" % (len(teams),
                                    ", ".join([x[4:] for x in teams]) )
            print
Exemplo n.º 2
0
    def addusers(self, args):
        """Add users to a group
Usage:
	group addusers GROUPNAME USERS"""
        
        if len(args) < 2:
            print self.addusers.__doc__
            return

        gname = args[0]
        users = args[1:]

        g = sr.group(gname)

        if not g.in_db:
            print "Group '%s' not found." % ( gname )
            return

        f = g.user_add( users )

        if len(f) > 0:
            print "WARNING: The following users were not found and so were not added:"
            print ", ".join(f)

        g.save()
Exemplo n.º 3
0
    def addusers(self, args):
        """Add users to a group
Usage:
	group addusers GROUPNAME USERS"""

        if len(args) < 2:
            print(self.addusers.__doc__)
            return

        gname = args[0]
        users = args[1:]

        g = sr.group(gname)

        if not g.in_db:
            print("Group '%s' not found." % (gname))
            return

        f = g.user_add(users)

        if len(f) > 0:
            print(
                "WARNING: The following users were not found and so were not added:"
            )
            print(", ".join(f))

        g.save()
Exemplo n.º 4
0
    def __init__(self, args):
        CmdBase.__init__(self, args)

        glist = sr.groups.list()

        for gname in glist:
            if re.match("^college-[0-9]+$", gname) == None:
                continue

            g = sr.group(gname)

            if hasattr(g, "desc"):
                desc = g.desc
            else:
                desc = "(no description)"

            print "%s: %s" % (gname, desc)
            print "\t %i members." % len(g.members)

            teams = set()
            for uname in g.members:
                u = sr.user(uname)
                assert u.in_db

                for gname in u.groups():
                    if re.match("^team[0-9]+$", gname) != None:
                        teams.add(gname)

            print "\t %i teams: %s" % (len(teams), ", ".join(
                [x[4:] for x in teams]))
            print
Exemplo n.º 5
0
    def delete(self, args):
        """Delete a user.
Usage:
	user rm USERNAME(S)"""
        if len(args) < 1:
            print self.delete.__doc__
            return

        for username in args:
            u = sr.users.user( username )
            groups = u.groups()

            if not u.in_db:
                print "User '%s' doesn't exist" % ( username )
                continue

            if u.delete():
                print "User '%s' deleted" % (username)

                for group in groups:
                    g = sr.group(group)
                    g.user_rm(username)
                    g.save()

            else:
                print "Error: User '%s' could not be deleted"
Exemplo n.º 6
0
    def delete(self, args):
        """Delete a user.
Usage:
	user rm USERNAME(S)"""
        if len(args) < 1:
            print self.delete.__doc__
            return

        for username in args:
            u = self._get_user( username )
            groups = u.groups()

            if not u.in_db:
                print "User '%s' doesn't exist" % ( username )
                continue

            if u.delete():
                print "User '%s' deleted" % (username)

                for group in groups:
                    g = sr.group(group)
                    g.user_rm(u.username)
                    g.save()

            else:
                print "Error: User '%s' could not be deleted"
Exemplo n.º 7
0
    def __init__(self, args):
        CmdBase.__init__(self, args)

        tg = get_team(int(args[0]))
        if not tg.in_db:
            print "Team %i do not exist" % int(args[0])
            sys.exit(1)

        # Group people into teachers, students, mentors and misc:
        g = ["teachers", "students", "mentors"]
        groups = {}
        team_grouped = {}

        for gname in g:
            groups[gname] = sr.group(gname)
            team_grouped[gname] = []

        for uname in tg.members:
            for gname, g in groups.iteritems():
                if uname in g.members:
                    team_grouped[gname].append(uname)

        if hasattr(tg, "desc"):
            print "Team %i: %s" % (int(args[0]), tg.desc)
        else:
            print "Team", int(args[0]), "(no description)"
        print

        for status, ulist in team_grouped.iteritems():
            if len(ulist):
                print len(ulist), "%s:" % status
                ulist.sort()

                for u in ulist:
                    print "\t%s" % u
                print
            else:
                print "No %s." % status

        # Work out what college they're from
        college_gnames = set()

        for uname in team_grouped["students"] + team_grouped["teachers"]:
            u = sr.user(uname)
            assert u.in_db

            for gname in u.groups():
                if re.match("^college-[0-9]+$", gname) != None:
                    college_gnames.add(gname)

        college_gnames = list(college_gnames)
        college_gnames.sort()
        if len(college_gnames):
            print "Colleges:"
            for gname in college_gnames:
                print "\t%s" % gname
        else:
            print "No associated college."
Exemplo n.º 8
0
    def __init__(self, args):
        CmdBase.__init__(self, args)
        CDESC, CSV_FNAME = args[0], args[1]

        college_group = college_find(CDESC)
        newusers = self.form_new_users(CSV_FNAME, college_group)

        print
        print "Will create %i users" % len(newusers)

        disp = [["username", "fname", "lname", "email"]]
        disp += [[u.username, u.cname, u.sname, u.email] for u in newusers]
        print_table(disp)

        teamno = None
        lang = "english"

        for arg in args[2:]:
            name, val = arg.split("=")

            if name == "team":
                teamno = int(val)
            elif name == "lang":
                lang = val
            else:
                raise Exception("Unsupported argument \"%s\"", arg)

        if teamno == None:
            teamno = new_team()

        print
        print "They will form team %i." % teamno
        print "And will be associated with %s: %s." % (college_group.name,
                                                       college_group.desc)

        students_group = sr.group("students")
        team_group = get_team(teamno)

        print "Is this OK? (yes/no)",
        resp = raw_input()
        resp = resp.lower().strip()

        if resp == "yes":
            print "Creating users..."

            for u in newusers:
                print "\t", u.username
                passwd = sr.users.GenPasswd()
                # Password has to be set after user is in db
                u.save()
                u.set_passwd(new=passwd)
                u.set_lang(lang)
                mailer.send_template("welcome", u, {"PASSWORD": passwd})

            print "Saving groups."
            for g in students_group, team_group, college_group:
                g.user_add(newusers)
                g.save()
Exemplo n.º 9
0
    def __init__(self, args):
        CmdBase.__init__(self, args)

        tg = get_team(int(args[0]))
        if not tg.in_db:
            print "Team %i do not exist" % int(args[0])
            sys.exit(1)

        # Group people into teachers, students, mentors and misc:
        g = ["teachers", "students", "mentors"]
        groups = {}
        team_grouped = {}

        for gname in g:
            groups[gname] = sr.group(gname)
            team_grouped[gname] = []

        for uname in tg.members:
            for gname, g in groups.iteritems():
                if uname in g.members:
                    team_grouped[gname].append(uname)

        if hasattr(tg, "desc"):
            print "Team %i: %s" % (int(args[0]), tg.desc)
        else:
            print "Team", int(args[0]), "(no description)"
        print

        for status, ulist in team_grouped.iteritems():
            if len(ulist):
                print len(ulist), "%s:" % status
                ulist.sort()

                for u in ulist:
                    print "\t%s" % u
                print
            else:
                print "No %s." % status

        # Work out what college they're from
        college_gnames = set()

        for uname in team_grouped["students"] + team_grouped["teachers"]:
            u = sr.user(uname)
            assert u.in_db

            for gname in u.groups():
                if re.match( "^college-[0-9]+$", gname ) != None:
                    college_gnames.add( gname )

        college_gnames = list(college_gnames)
        college_gnames.sort()
        if len(college_gnames):
            print "Colleges:"
            for gname in college_gnames:
                print  "\t%s" % gname
        else:
            print "No associated college."
Exemplo n.º 10
0
    def __init__(self, args):
        CmdBase.__init__(self, args)
        CDESC, CSV_FNAME = args[0], args[1]

        college_group = college_find( CDESC )
        newusers = self.form_new_users( CSV_FNAME )

        print
        print "Will create %i users" % len(newusers)

        disp = [["username", "fname", "lname", "email"]]
        disp += [ [u.username, u.cname, u.sname, u.email] for u in newusers ]
        print_table( disp )

        teamno = None
        lang = "english"

        for arg in args[2:]:
            name, val = arg.split("=")

            if name == "team":
                teamno = int(val)
            elif name == "lang":
                lang = val
            else:
                raise Exception("Unsupported argument \"%s\"", arg)

        if teamno == None:
            teamno = new_team()

        print
        print "They will form team %i." % teamno
        print "And will be associated with %s: %s." % ( college_group.name, college_group.desc )

        students_group = sr.group("students")
        team_group = get_team(teamno)

        print "Is this OK? (yes/no)",
        resp = raw_input()
        resp = resp.lower().strip()

        if resp == "yes":
            print "Creating users..."

            for u in newusers:
                print "\t", u.username
                passwd = sr.users.GenPasswd()
                # Password has to be set after user is in db
                u.save()
                u.set_passwd( new = passwd )
                u.set_lang( lang )
                mailer.send_template( "welcome", u, { "PASSWORD": passwd } )

            print "Saving groups."
            for g in students_group, team_group, college_group:
                g.user_add(newusers)
                g.save()
Exemplo n.º 11
0
    def __init__(self, args):
        CmdBase.__init__(self, args)

        tid = args[0]
        tg = get_team(tid)
        if not tg.in_db:
            print "Team '%s' do not exist" % tid
            sys.exit(1)

        # Group people into teachers, students, mentors and misc:
        g = ["teachers", "students", "mentors"]
        groups = {}
        team_grouped = {}

        for gname in g:
            groups[gname] = sr.group(gname)
            team_grouped[gname] = []

        for uname in tg.members:
            for gname, g in groups.iteritems():
                if uname in g.members:
                    team_grouped[gname].append(uname)

        print "Team", tid
        print

        for status, ulist in team_grouped.iteritems():
            if len(ulist):
                print len(ulist), "%s:" % status
                ulist.sort()

                for u in ulist:
                    print "\t%s" % u
                print
            else:
                print "No %s." % status

        # Work out what college they're from
        college_gnames = set()

        for uname in team_grouped["students"] + team_grouped["teachers"]:
            u = sr.user(uname)
            assert u.in_db

            for gname in u.groups():
                if re.match(COLLEGE_PATTERN, gname) != None:
                    college_gnames.add(gname)

        college_gnames = list(college_gnames)
        college_gnames.sort()
        if len(college_gnames):
            print "Colleges:"
            for gname in college_gnames:
                print "\t%s" % gname
        else:
            print "No associated college."
Exemplo n.º 12
0
    def __init__(self, args):
        CmdBase.__init__(self, args)

        tid = args[0]
        tg = get_team(tid)
        if not tg.in_db:
            print "Team '%s' do not exist" % tid
            sys.exit(1)

        # Group people into teachers, students, mentors and misc:
        g = ["teachers", "students", "mentors"]
        groups = {}
        team_grouped = {}

        for gname in g:
            groups[gname] = sr.group(gname)
            team_grouped[gname] = []

        for uname in tg.members:
            for gname, g in groups.iteritems():
                if uname in g.members:
                    team_grouped[gname].append(uname)

        print "Team", tid
        print

        for status, ulist in team_grouped.iteritems():
            if len(ulist):
                print len(ulist), "%s:" % status
                ulist.sort()

                for u in ulist:
                    print "\t%s" % u
                print
            else:
                print "No %s." % status

        # Work out what college they're from
        college_gnames = set()

        for uname in team_grouped["students"] + team_grouped["teachers"]:
            u = sr.user(uname)
            assert u.in_db

            for gname in u.groups():
                if re.match( COLLEGE_PATTERN, gname ) != None:
                    college_gnames.add( gname )

        college_gnames = list(college_gnames)
        college_gnames.sort()
        if len(college_gnames):
            print "Colleges:"
            for gname in college_gnames:
                print  "\t%s" % gname
        else:
            print "No associated college."
Exemplo n.º 13
0
def search_colleges(s):
    "Search through the colleges to find one with s its name"
    groups = list_groups_with_prefix(COLLEGE_PREFIX)

    res = []

    for gname in groups:
        group = sr.group(gname)

        if s.upper() in group.desc.upper():
            res.append(group)

    return res
Exemplo n.º 14
0
def search_colleges(s):
    "Search through the colleges to find one with s its name"
    groups = sr.groups.list("college-*")

    res = []

    for gname in groups:
        group = sr.group(gname)

        if s.upper() in group.desc.upper():
            res.append(group)

    return res
Exemplo n.º 15
0
def search_colleges(s):
    "Search through the colleges to find one with s its name"
    groups = list_groups_with_prefix(COLLEGE_PREFIX)

    res = []

    for gname in groups:
        group = sr.group(gname)

        if s.upper() in group.desc.upper():
            res.append(group)

    return res
Exemplo n.º 16
0
def search_colleges(s):
    "Search through the colleges to find one with s its name"
    groups = sr.groups.list("college-*")

    res = []

    for gname in groups:
        group = sr.group(gname)

        if s.upper() in group.desc.upper():
            res.append(group)

    return res    
Exemplo n.º 17
0
    def __init__(self, args):
        CmdList.__init__(self, args)

        names = self.get_names(COLLEGE_PREFIX, COLLEGE_PATTERN)

        for gname in names:
            g = sr.group(gname)

            if hasattr(g, "desc"):
                desc = g.desc
            else:
                desc = "(no description)"

            print "%s: %s" % (gname, desc)
Exemplo n.º 18
0
    def __init__(self, args):
        CmdList.__init__(self, args)

        names = self.get_names(COLLEGE_PREFIX, COLLEGE_PATTERN)

        for gname in names:
            g = sr.group(gname)

            if hasattr(g, "desc"):
                desc = g.desc
            else:
                desc = "(no description)"

            print "%s: %s" % (gname, desc)
Exemplo n.º 19
0
def create_all(team_source):
    students_group = sr.group('students')

    passwds = {}

    for tla, college_name in team_source:
        tu = create_team_user(tla.lower(), college_name)
        passwds[tu.username] = set_password(tu)

        ensure_college(tla, college_name, tu)
        ensure_team(tla, tu)
        students_group.user_add(tu)

    students_group.save()
    return passwds
Exemplo n.º 20
0
    def members(self, args):
        """Display group members.
Usage:
	group members USERNAME"""

        if len(args) < 1:
            print self.members.__doc__
            return

        g = sr.group( args[0] )

        if not g.in_db:
            print "Group '%s' not found\n" % (args[0])
        else:
            print " ".join(g.members)
Exemplo n.º 21
0
def create_all(team_source):
    students_group = sr.group('students')

    passwds = {}

    for tla, college_name in team_source:
        tu = create_team_user(tla.lower(), college_name)
        passwds[tu.username] = set_password(tu)

        ensure_college(tla, college_name, tu)
        ensure_team(tla, tu)
        students_group.user_add(tu)

    students_group.save()
    return passwds
Exemplo n.º 22
0
    def members(self, args):
        """Display group members.
Usage:
	group members GROUPNAME"""

        if len(args) < 1:
            print(self.members.__doc__)
            return

        g = sr.group(args[0])

        if not g.in_db:
            print("Group '%s' not found\n" % (args[0]))
        else:
            print(" ".join(g.members))
Exemplo n.º 23
0
    def delete(self, args):
        """Delete a group
Usage:
	group rm GROUPNAME"""
        if len(args) < 1:
            print self.delete.__doc__
            return

        g = sr.group(args[0])

        if not g.in_db:
            print "Group '%s' doesn't exist" % (args[0])
            return

        g.rm()
        print "Group '%s' deleted." % (args[0])
Exemplo n.º 24
0
    def delete(self, args):
        """Delete a group
Usage:
	group rm GROUPNAME"""
        if len(args) < 1:
            print self.delete.__doc__
            return

        for gname in args:
            g = sr.group( gname )

            if not g.in_db:
                print "Group '%s' doesn't exist" % ( gname )
                continue

            g.rm()
            print "Group '%s' deleted." % ( gname )
Exemplo n.º 25
0
    def delete(self, name):
        """
        Delete a user.
        @param name (string): The username of the user to be deleted.
        """
        assert type(name) is StringType, 'Can only remove by string'

        u = self._get_user(name)
        groups = u.groups()

        if not u.delete():
            raise Exception("Could not remove user '%s'." % name)

        for group in groups:
            g = sr.group(group)
            g.user_rm(name)
            g.save()
Exemplo n.º 26
0
    def delete(self, args):
        """Delete a group
Usage:
	group rm GROUPNAME"""
        if len(args) < 1:
            print(self.delete.__doc__)
            return

        for gname in args:
            g = sr.group(gname)

            if not g.in_db:
                print("Group '%s' doesn't exist" % (gname))
                continue

            g.rm()
            print("Group '%s' deleted." % (gname))
Exemplo n.º 27
0
    def delusers(self, args):
        """Remove users from a group
Usage:
	group delusers GROUPNAME USERS"""

        if len(args) < 2:
            print self.addusers.__doc__
            return

        gname = args[0]
        users = args[1:]

        g = sr.group(gname)

        if not g.in_db:
            print "Group '%s' not found." % ( gname )
            return

        g.user_rm( users )
        g.save()
Exemplo n.º 28
0
    def delusers(self, args):
        """Remove users from a group
Usage:
	group delusers GROUPNAME USERS"""

        if len(args) < 2:
            print self.addusers.__doc__
            return

        gname = args[0]
        users = args[1:]

        g = sr.group(gname)

        if not g.in_db:
            print "Group '%s' already exists" % (gname)
            return

        g.user_rm(users)
        g.save()
Exemplo n.º 29
0
    def create(self, args):
        """Create a group.
Usage:
	group create GROUP_NAME [USERS]"""

        if len(args) < 1:
            print self.create.__doc__
            return

        g = sr.group( args[0] )

        if g.in_db:
            print "Group '%s' already exists" % (args[0] )
            return

        if len(args) > 1:
            users = args[1:]
            g.user_add(users)

        g.save()
Exemplo n.º 30
0
    def create(self, args):
        """Create a group.
Usage:
	group create GROUP_NAME [USERS]"""

        if len(args) < 1:
            print(self.create.__doc__)
            return

        g = sr.group(args[0])

        if g.in_db:
            print("Group '%s' already exists" % (args[0]))
            return

        if len(args) > 1:
            users = args[1:]
            g.user_add(users)

        g.save()
Exemplo n.º 31
0
    def delete(self, args):
        """Delete a user.
Usage:
	user rm USERNAME"""
        if len(args) < 1:
            print self.delete.__doc__
            return

        u = sr.users.user( args[0] )
        groups = u.groups()

        if u.delete():
            print "User '%s' deleted" % (args[0])

            for group in groups:
                g = sr.group(group)
                g.user_rm(args[0])
                g.save()

        else:
            print "Error: User '%s' could not be deleted"
Exemplo n.º 32
0
    def delusers(self, args):
        """Remove users from a group
Usage:
	group delusers GROUPNAME USERS"""

        if len(args) < 2:
            print self.addusers.__doc__
            return

        gname = args[0]
        users = args[1:]

        g = sr.group(gname)

        if not g.in_db:
            print "Group '%s' not found." % (gname)
            return

        not_members = g.user_rm(users)
        g.save()

        for uname in not_members:
            print "Unable to remove non-member '%s' from '%s'" % (gname, uname)
Exemplo n.º 33
0
    def delusers(self, args):
        """Remove users from a group
Usage:
	group delusers GROUPNAME USERS"""

        if len(args) < 2:
            print self.addusers.__doc__
            return

        gname = args[0]
        users = args[1:]

        g = sr.group(gname)

        if not g.in_db:
            print "Group '%s' not found." % (gname)
            return

        not_members = g.user_rm(users)
        g.save()

        for uname in not_members:
            print "Unable to remove non-member '%s' from '%s'" % (gname, uname)
Exemplo n.º 34
0
    "csv_file",
    type=argparse.FileType(mode='r'),
    help="CSV file with columns '{}'.".format(
        "', '".join(REQUIRED_COLUMNS)
    ),
)
parser.add_argument(
    "--no-emails",
    action='store_true',
    help="Don't send emails to the mentors",
)
args = parser.parse_args()

# Grab a useful group

mentors = sr.group('mentors')
if not mentors.in_db:
    print("Group {0} doesn't exist".format('mentors'), file=sys.stderr)
    exit(1)


# Check all rows have the required data
errors = []
mentors_infos = []
for line_no, info in enumerate(csv.DictReader(args.csv_file), start=1):
    for col in REQUIRED_COLUMNS:
        if not info.get(col):
            errors.append("Line {} is missing a {}".format(line_no, col))

    if '@' not in info['email']:
        errors.append("Invalid email {!r} on line {}".format(info['email'], line_no))
Exemplo n.º 35
0
#!/usr/bin/env python

from __future__ import print_function

import sr
from c_teams import CmdList, print_table, TEAM_PREFIX, TEAM_PATTERN

team_leaders = set(sr.group('teachers').members)

rows = [
    ('Team', 'Leaders', 'Competitors')
]

for team_name in CmdList(()).get_names(TEAM_PREFIX, TEAM_PATTERN):
    team = sr.group(team_name)

    num_team_leaders = 0
    num_competitors = 0

    for member in team.members:
        if member in team_leaders:
            num_team_leaders += 1
        else:
            num_competitors += 1

    rows.append((
        team_name[len(TEAM_PREFIX):],
        str(num_team_leaders),
        str(num_competitors),
    ))
Exemplo n.º 36
0
def get_team(num):
    return sr.group("team%i" % num)
Exemplo n.º 37
0
import c_teams
import mailer

if len(sys.argv) != 2:
    print >>sys.stderr, "Usage: importusers.py users.csv"
    sys.exit(1)

for row in csv.reader(open(sys.argv[1], 'r')):
    print repr(row)
    newname = sr.new_username(row[2], row[3], row[4])
    u =sr.users.user(newname)
    if u.in_db:
        print >>sys.stderr, "User {0} already exists".format(newname)
        sys.exit(1)

    college = sr.group(row[2])
    if not college.in_db:
        print >>sys.stderr, "Group {0} doesn't exist".format(row[2])
        sys.exit(1)

    team = sr.group(row[6])
    if not team.in_db:
        print >>sys.stderr, "Group {0} doesn't exist".format(row[2])
        sys.exit(1)

    students = sr.group('students')
    if not students.in_db:
        print >>sys.stderr, "Group {0} doesn't exist".format('students')
        sys.exit(1)

    # NB: strange save order because I encountered some pyenv error without the
Exemplo n.º 38
0
            sys.exit(1)
        teams = []
        for teamname in y['teams']:
            assert(isinstance(teamname, basestring))
            teams.append(teamname)

        # First team name gets used as the college name too...
        if re.match("^[A-Z]+$", teams[0]) == None:
            print >>sys.stderr, "Team name \"{0}\" is not the conventional format".format(teams[0])
            sys.exit(1)

        return (the_contact, teams[0], teams)

# Grab a useful group

teachers = sr.group('teachers')
if not teachers.in_db:
    print >>sys.stderr, "Group {0} doesn't exist".format('teachers')
    sys.exit(1)

# Iterate through teams, fetch data, and create accounts.

count = 0
skipped = 0

for team_dot_yaml in team_yaml:
    the_contact, college_tla, teams = read_team_data(team_dot_yaml)

    # Does the desired college / team already exist?

    college = c_teams.get_college(college_tla)
Exemplo n.º 39
0
def get_college(cid):
    return sr.group( COLLEGE_PREFIX + str(cid) )
Exemplo n.º 40
0
def get_college(num):
    return sr.group( "college-%i" % num )
Exemplo n.º 41
0
def get_college(num):
    return sr.group("college-%i" % num)
Exemplo n.º 42
0
def get_team(num):
    return sr.group( "team%i" % num )
Exemplo n.º 43
0
#!/usr/bin/env python3

from __future__ import print_function

import sr
from c_teams import CmdList, print_table, TEAM_PREFIX, TEAM_PATTERN

team_leaders = set(sr.group('teachers').members)

rows = [
    ('Team', 'Leaders', 'Competitors')
]

for team_name in CmdList(()).get_names(TEAM_PREFIX, TEAM_PATTERN):
    team = sr.group(team_name)

    num_team_leaders = 0
    num_competitors = 0

    for member in team.members:
        if member in team_leaders:
            num_team_leaders += 1
        else:
            num_competitors += 1

    rows.append((
        team_name[len(TEAM_PREFIX):],
        str(num_team_leaders),
        str(num_competitors),
    ))
Exemplo n.º 44
0
def get_team(tid):
    return sr.group( TEAM_PREFIX + str(tid) )
Exemplo n.º 45
0
        teams = []
        for teamname in y['teams']:
            assert(isinstance(teamname, basestring))
            teams.append(teamname)

        # First team name gets used as the college name too...
        if re.match("^[A-Z]+$", teams[0]) == None:
            print >>sys.stderr, "Team name \"{0}\" is not the conventional format".format(teams[0])
            sys.exit(1)

        return (the_contact, teams[0], teams, y['name'])

# Grab a useful group

teachers = sr.group('teachers')
if not teachers.in_db:
    print >>sys.stderr, "Group {0} doesn't exist".format('teachers')
    sys.exit(1)

# Iterate through teams, fetch data, and create accounts.

count = 0
skipped = 0

for team_dot_yaml in team_yaml:
    team_leader, college_tla, teams, team_name = read_team_data(team_dot_yaml)

    # Does the desired college / team already exist?

    college = c_teams.get_college(college_tla)
Exemplo n.º 46
0
def get_college(cid):
    return sr.group(COLLEGE_PREFIX + str(cid))
Exemplo n.º 47
0
def get_team(tid):
    return sr.group(TEAM_PREFIX + str(tid))