Example #1
0
def main(argv):
    global app
    parser = argparse.ArgumentParser(description='A minimalistic programming contest environment.')
    parser.add_argument('contest', help='the contest directory')
    parser.add_argument('-p', '--port', default=31415, type=int, help='the port to listen on')
    parser.add_argument('-H', '--host', default='', help='the host to listen on')
    parser.add_argument('-d', '--debug', default=False, action='store_true', help='run in debug mode')
    parser.add_argument('--prefix', default=None, help='run under prefix')
    parser.add_argument('--server_name', default=None, help='server name')
    # parser.add_argument('--hostname', default=None, help='run with the specified hostname')
    parser.add_argument('--droptables', default=False, action='store_true', help='drop database tables and exit')
    opts = app.opts = parser.parse_args(argv)
    contest = app.contest = Contest.load(opts.contest)
    app.config['SQLALCHEMY_DATABASE_URI'] = contest.db
    if opts.prefix:
        # app.config['APPLICATION_ROOT'] = opts.prefix
        app.wsgi_app = ReverseProxied(app.wsgi_app, opts.prefix)
    if opts.server_name:
        app.config['SERVER_NAME'] = opts.server_name
    models.set_contest_id(contest.id)

    db.init_app(app)

    if opts.droptables:
        print('You are about to drop the database tables for contest %s!!!' % contest.id)
        if input('Are you sure you want to continue? (y/N) ').lower() == 'y':
            db.drop_all(app=app)

        return 0

    db.create_all(app=app)
    app.run(host=opts.host, port=opts.port, debug=opts.debug)
Example #2
0
def _register_team(name, password):
    global opts
    global contest

    with open(os.path.join(app.opts.contest, 'teams.yml'), 'r') as f:
        inp = f.read()

    with open(os.path.join(app.opts.contest, 'teams.yml'), 'w') as f:
        for line in inp.strip().split('\n'):
            f.write(line + '\n')
            if line.strip() == 'teams:':
                f.write('    "%s": {pass: "******", location: unknown, groups:[all]}\n' % (name, password))

    app.contest = Contest.load(app.opts.contest)
Example #3
0
def main(argv):
    global app
    parser = argparse.ArgumentParser(
        description='A minimalistic programming contest environment.')
    parser.add_argument('contest', help='the contest directory')
    parser.add_argument('-p',
                        '--port',
                        default=31415,
                        type=int,
                        help='the port to listen on')
    parser.add_argument('-H',
                        '--host',
                        default='',
                        help='the host to listen on')
    parser.add_argument('-d',
                        '--debug',
                        default=False,
                        action='store_true',
                        help='run in debug mode')
    parser.add_argument('--prefix', default=None, help='run under prefix')
    parser.add_argument('--server_name', default=None, help='server name')
    # parser.add_argument('--hostname', default=None, help='run with the specified hostname')
    parser.add_argument('--droptables',
                        default=False,
                        action='store_true',
                        help='drop database tables and exit')
    opts = app.opts = parser.parse_args(argv)
    contest = app.contest = Contest.load(opts.contest)
    app.config['SQLALCHEMY_DATABASE_URI'] = contest.db
    if opts.prefix:
        # app.config['APPLICATION_ROOT'] = opts.prefix
        app.wsgi_app = ReverseProxied(app.wsgi_app, opts.prefix)
    if opts.server_name:
        app.config['SERVER_NAME'] = opts.server_name
    models.set_contest_id(contest.id)

    db.init_app(app)

    if opts.droptables:
        print('You are about to drop the database tables for contest %s!!!' %
              contest.id)
        if input('Are you sure you want to continue? (y/N) ').lower() == 'y':
            db.drop_all(app=app)

        return 0

    db.create_all(app=app)
    app.run(host=opts.host, port=opts.port, debug=opts.debug)
Example #4
0
def reload():
    app.contest = Contest.load(app.opts.contest)
    return redirect(url_for('judge.index'))
Example #5
0
def reload():
    app.contest = Contest.load(app.opts.contest)
    return redirect(url_for('judge.index'))