Beispiel #1
0
def main():
    """Parse arguments and launch process."""

    parser = argparse.ArgumentParser(
        description="Import a new dataset for an existing task in CMS.",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter)

    parser.add_argument("-L",
                        "--loader",
                        action="store",
                        type=utf8_decoder,
                        default=None,
                        help="use the specified loader (default: autodetect)")
    parser.add_argument(
        "target",
        action="store",
        type=utf8_decoder,
        help="target file/directory from where to import the dataset")

    args = parser.parse_args()

    args.description = input("Enter a description: ")

    loader_class = choose_loader(args.loader, args.target, parser.error)

    importer = DatasetImporter(path=args.target,
                               description=args.description,
                               loader_class=loader_class)
    success = importer.do_import()
    return 0 if success is True else 1
Beispiel #2
0
def main():
    """Parse arguments and launch process."""

    parser = argparse.ArgumentParser(
        description="Create a new task in CMS.",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter
    )

    parser.add_argument(
        "-L", "--loader",
        action="store", type=utf8_decoder,
        default=None,
        help="use the specified loader (default: autodetect)"
    )
    parser.add_argument(
        "target",
        action="store", type=utf8_decoder,
        help="target file/directory from where to import task(s)"
    )

    args = parser.parse_args()

    loader_class = choose_loader(
        args.loader,
        args.target,
        parser.error
    )

    TaskImporter(
        path=args.target,
        loader_class=loader_class
    ).do_import()
Beispiel #3
0
def main():
    """Parse arguments and launch process."""

    parser = argparse.ArgumentParser(
        description="Import a new dataset for an existing task in CMS.",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )

    parser.add_argument(
        "-L",
        "--loader",
        action="store",
        type=utf8_decoder,
        default=None,
        help="use the specified loader (default: autodetect)",
    )
    parser.add_argument(
        "target", action="store", type=utf8_decoder, help="target file/directory from where to import the dataset"
    )

    args = parser.parse_args()

    args.description = raw_input("Enter a description: ")

    loader_class = choose_loader(args.loader, args.target, parser.error)

    DatasetImporter(path=args.target, description=args.description, loader_class=loader_class).do_import()
Beispiel #4
0
def main():
    """Parse arguments and launch process."""

    parser = argparse.ArgumentParser(
        description="Import a new task or update an existing one in CMS.",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter)

    parser.add_argument("-L",
                        "--loader",
                        action="store",
                        type=utf8_decoder,
                        default=None,
                        help="use the specified loader (default: autodetect)")
    parser.add_argument("-u",
                        "--update",
                        action="store_true",
                        help="update an existing task")
    parser.add_argument("-S",
                        "--no-statement",
                        action="store_true",
                        help="do not import / update task statement")
    parser.add_argument("-c",
                        "--contest-id",
                        action="store",
                        type=int,
                        help="id of the contest the task will be attached to")
    parser.add_argument("-p",
                        "--prefix",
                        action="store",
                        type=utf8_decoder,
                        help="the prefix to be added before the task name")
    parser.add_argument("-n",
                        "--name",
                        action="store",
                        type=utf8_decoder,
                        help="the new name that will override the task name")
    parser.add_argument(
        "target",
        action="store",
        type=utf8_decoder,
        help="target file/directory from where to import task(s)")

    args = parser.parse_args()

    loader_class = choose_loader(args.loader, args.target, parser.error)

    importer = TaskImporter(path=args.target,
                            update=args.update,
                            no_statement=args.no_statement,
                            contest_id=args.contest_id,
                            prefix=args.prefix,
                            override_name=args.name,
                            loader_class=loader_class)
    success = importer.do_import()
    return 0 if success is True else 1
Beispiel #5
0
def main():
    """Parse arguments and launch process.

    """
    parser = argparse.ArgumentParser(
        description="Import a user to the database.",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter
    )

    parser.add_argument(
        "-L", "--loader",
        action="store", type=utf8_decoder,
        default=None,
        help="use the specified loader (default: autodetect)"
    )
    parser.add_argument(
        "target",
        action="store", type=utf8_decoder, nargs="?",
        default=os.getcwd(),
        help="target file/directory from where to import user(s)"
    )
    parser.add_argument(
        "-A", "--all",
        action="store_true",
        help="try to import all users inside target"
    )
    parser.add_argument(
        "-c", "--contest-id",
        action="store", type=int,
        help="id of the contest the users will be attached to"
    )
    parser.add_argument(
        "-u", "--update",
        action="store_true",
        help="update an existing team",
    )

    args = parser.parse_args()

    def get_loader(path):
        return choose_loader(args.loader, path, parser.error)

    importer = UserImporter(
        path=args.target,
        contest_id=args.contest_id,
        loader_class=get_loader(args.target),
        update=args.update,
    )

    if args.all:
        success = importer.do_import_all(args.target, get_loader)
    else:
        success = importer.do_import()
    return 0 if success is True else 1
Beispiel #6
0
def main():
    """Parse arguments and launch process."""

    parser = argparse.ArgumentParser(
        description="Import a contest from disk",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter
    )

    group = parser.add_mutually_exclusive_group()

    group.add_argument(
        "-z", "--zero-time",
        action="store_true",
        help="set to zero contest start and stop time"
    )
    group.add_argument(
        "-t", "--test",
        action="store_true",
        help="setup a contest for testing "
             "(times: 1970, 2100; ips: unset, passwords: a)"
    )
    parser.add_argument(
        "-n", "--user-number",
        action="store", type=int,
        help="put N random users instead of importing them"
    )
    parser.add_argument(
        "-L", "--loader",
        action="store", type=utf8_decoder,
        default=None,
        help="use the specified loader (default: autodetect)"
    )
    parser.add_argument(
        "import_directory",
        action="store", type=utf8_decoder,
        help="source directory from where import"
    )

    args = parser.parse_args()

    loader_class = choose_loader(
        args.loader,
        args.import_directory,
        parser.error
    )

    ContestImporter(
        path=args.import_directory,
        test=args.test,
        zero_time=args.zero_time,
        user_number=args.user_number,
        loader_class=loader_class
    ).do_import()
Beispiel #7
0
def main():
    """Parse arguments and launch process."""

    parser = argparse.ArgumentParser(
        description="Create a new or update an existing task in CMS.",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter
    )

    parser.add_argument(
        "-L", "--loader",
        action="store", type=utf8_decoder,
        default=None,
        help="use the specified loader (default: autodetect)"
    )
    parser.add_argument(
        "-u", "--update",
        action="store_true",
        help="update an existing task"
    )
    parser.add_argument(
        "-S", "--no-statement",
        action="store_true",
        help="do not import / update task statement"
    )
    parser.add_argument(
        "-c", "--contest-id",
        action="store", type=int,
        help="id of the contest the task will be attached to"
    )
    parser.add_argument(
        "target",
        action="store", type=utf8_decoder,
        help="target file/directory from where to import task(s)"
    )

    args = parser.parse_args()

    loader_class = choose_loader(
        args.loader,
        args.target,
        parser.error
    )

    TaskImporter(
        path=args.target,
        update=args.update,
        no_statement=args.no_statement,
        contest_id=args.contest_id,
        loader_class=loader_class
    ).do_import()
Beispiel #8
0
def main():
    """Parse arguments and launch process.

    """
    parser = argparse.ArgumentParser(
        description="Import a user to the database.",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter
    )

    parser.add_argument(
        "-L", "--loader",
        action="store", type=utf8_decoder,
        default=None,
        help="use the specified loader (default: autodetect)"
    )
    parser.add_argument(
        "target",
        action="store", type=utf8_decoder, nargs="?",
        default=os.getcwd(),
        help="target file/directory from where to import user(s)"
    )
    parser.add_argument(
        "-A", "--all",
        action="store_const", const="a",
        default=None,
        help="try to import all users inside target"
    )
    parser.add_argument(
        "-c", "--contest-id",
        action="store", type=int,
        help="id of the contest the users will be attached to"
    )

    args = parser.parse_args()

    def get_loader(path):
        return choose_loader(args.loader, path, parser.error)

    importer = UserImporter(
        path=args.target,
        contest_id=args.contest_id,
        loader_class=get_loader(args.target)
    )

    if args.all:
        success = importer.do_import_all(args.target, get_loader)
    else:
        success = importer.do_import()
    return 0 if success is True else 1
Beispiel #9
0
def main():
    """Parse arguments and launch process.

    """
    parser = argparse.ArgumentParser(
        description="Import a team to the database.",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter
    )

    parser.add_argument(
        "-L", "--loader",
        action="store", type=utf8_decoder,
        default=None,
        help="use the specified loader (default: autodetect)"
    )
    parser.add_argument(
        "target",
        action="store", type=utf8_decoder, nargs="?",
        default=os.getcwd(),
        help="target file/directory from where to import team(s)"
    )
    parser.add_argument(
        "-A", "--all",
        action="store_const", const="a",
        default=None,
        help="try to import the needed teams inside target (not "
             "necessarily all of them)"
    )

    args = parser.parse_args()

    def get_loader(path):
        return choose_loader(args.loader, path, parser.error)

    importer = TeamImporter(
        path=args.target,
        loader_class=get_loader(args.target)
    )

    if args.all:
        success = importer.do_import_all(args.target, get_loader)
    else:
        success = importer.do_import()
    return 0 if success is True else 1
Beispiel #10
0
def main():
    """Parse arguments and launch process.

    """
    parser = argparse.ArgumentParser(
        description="Import a team to the database.",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter
    )

    parser.add_argument(
        "-L", "--loader",
        action="store", type=utf8_decoder,
        default=None,
        help="use the specified loader (default: autodetect)"
    )
    parser.add_argument(
        "target",
        action="store", type=utf8_decoder, nargs="?",
        default=os.getcwd(),
        help="target file/directory from where to import team(s)"
    )
    parser.add_argument(
        "-A", "--all",
        action="store_true",
        help="try to import the needed teams inside target (not "
             "necessarily all of them)"
    )

    args = parser.parse_args()

    def get_loader(path):
        return choose_loader(args.loader, path, parser.error)

    importer = TeamImporter(
        path=args.target,
        loader_class=get_loader(args.target)
    )

    if args.all:
        success = importer.do_import_all(args.target, get_loader)
    else:
        success = importer.do_import()
    return 0 if success is True else 1
Beispiel #11
0
def main():
    """Parse arguments and launch process.

    """
    parser = argparse.ArgumentParser(
        description="Add a user to a contest in CMS.",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter
    )

    parser.add_argument(
        "-L", "--loader",
        action="store", type=utf8_decoder,
        default=None,
        help="use the specified loader (default: autodetect)"
    )
    parser.add_argument(
        "target",
        action="store", type=utf8_decoder, nargs="?",
        default=os.getcwd(),
        help="target file/directory from where to import user(s)"
    )
    parser.add_argument(
        "-A", "--all",
        action="store_const", const="a",
        default=None,
        help="try to import all users inside target"
    )

    args = parser.parse_args()

    def get_loader(path):
        return choose_loader(args.loader, path, parser.error)

    importer = UserImporter(
        path=args.target,
        loader_class=get_loader(args.target)
    )

    if args.all:
        importer.do_import_all(args.target, get_loader)
    else:
        importer.do_import()
Beispiel #12
0
def main():
    """Parse arguments and launch process."""

    parser = argparse.ArgumentParser(
        description="Create a new or update an existing task in CMS.",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter)

    parser.add_argument("-L",
                        "--loader",
                        action="store",
                        type=utf8_decoder,
                        default=None,
                        help="use the specified loader (default: autodetect)")
    parser.add_argument("-u",
                        "--update",
                        action="store_true",
                        help="update an existing task")
    parser.add_argument("-S",
                        "--no-statement",
                        action="store_true",
                        help="do not import / update task statement")
    parser.add_argument("-c",
                        "--contest-id",
                        action="store",
                        type=int,
                        help="id of the contest the task will be attached to")
    parser.add_argument(
        "target",
        action="store",
        type=utf8_decoder,
        help="target file/directory from where to import task(s)")

    args = parser.parse_args()

    loader_class = choose_loader(args.loader, args.target, parser.error)

    TaskImporter(path=args.target,
                 update=args.update,
                 no_statement=args.no_statement,
                 contest_id=args.contest_id,
                 loader_class=loader_class).do_import()
Beispiel #13
0
def main():
    """Parse arguments and launch process.

    """
    parser = argparse.ArgumentParser(
        description="Add a user to the database.",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter)

    parser.add_argument("-L",
                        "--loader",
                        action="store",
                        type=utf8_decoder,
                        default=None,
                        help="use the specified loader (default: autodetect)")
    parser.add_argument(
        "target",
        action="store",
        type=utf8_decoder,
        nargs="?",
        default=os.getcwd(),
        help="target file/directory from where to import user(s)")
    parser.add_argument("-A",
                        "--all",
                        action="store_const",
                        const="a",
                        default=None,
                        help="try to import all users inside target")

    args = parser.parse_args()

    def get_loader(path):
        return choose_loader(args.loader, path, parser.error)

    importer = UserImporter(path=args.target,
                            loader_class=get_loader(args.target))

    if args.all:
        importer.do_import_all(args.target, get_loader)
    else:
        importer.do_import()
Beispiel #14
0
def main():
    """Parse arguments and launch process."""

    parser = argparse.ArgumentParser(
        description="Import a new task or update an existing one in CMS.",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter
    )

    parser.add_argument(
        "-L", "--loader",
        action="store", type=utf8_decoder,
        default=None,
        help="use the specified loader (default: autodetect)"
    )
    parser.add_argument(
        "-u", "--update",
        action="store_true",
        help="update an existing task"
    )
    parser.add_argument(
        "-S", "--no-statement",
        action="store_true",
        help="do not import / update task statement"
    )
    parser.add_argument(
        "-c", "--contest-id",
        action="store", type=int,
        help="id of the contest the task will be attached to"
    )
    parser.add_argument(
        "-p", "--prefix",
        action="store", type=utf8_decoder,
        help="the prefix to be added before the task name"
    )
    parser.add_argument(
        "-n", "--name",
        action="store", type=utf8_decoder,
        help="the new name that will override the task name"
    )
    parser.add_argument(
        "target",
        action="store", type=utf8_decoder,
        help="target file/directory from where to import task(s)"
    )

    args = parser.parse_args()

    loader_class = choose_loader(
        args.loader,
        args.target,
        parser.error
    )

    importer = TaskImporter(path=args.target,
                            update=args.update,
                            no_statement=args.no_statement,
                            contest_id=args.contest_id,
                            prefix=args.prefix,
                            override_name=args.name,
                            loader_class=loader_class)
    success = importer.do_import()
    return 0 if success is True else 1
Beispiel #15
0
def main():
    """Parse arguments and launch process."""

    parser = argparse.ArgumentParser(
        description="Import a contest from disk",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter
    )

    group = parser.add_mutually_exclusive_group()

    group.add_argument(
        "-z", "--zero-time",
        action="store_true",
        help="set to zero contest start and stop time"
    )
    group.add_argument(
        "-t", "--test",
        action="store_true",
        help="setup a contest for testing "
             "(times: 1970, 2100; ips: unset, passwords: a)"
    )
    parser.add_argument(
        "-n", "--user-number",
        action="store", type=int,
        help="put N random users instead of importing them"
    )
    parser.add_argument(
        "-L", "--loader",
        action="store", type=utf8_decoder,
        default=None,
        help="use the specified loader (default: autodetect)"
    )
    parser.add_argument(
        "-i", "--import-tasks",
        action="store_true",
        help="import tasks if they do not exist"
    )
    parser.add_argument(
        "-r", "--import-users",
        action="store_true",
        help="import users if they do not exist"
    )
    parser.add_argument(
        "-u", "--update-contest",
        action="store_true",
        help="update an existing contest"
    )
    parser.add_argument(
        "-U", "--update-tasks",
        action="store_true",
        help="update existing tasks"
    )
    parser.add_argument(
        "-S", "--no-statements",
        action="store_true",
        help="do not import / update task statements"
    )
    parser.add_argument(
        "import_directory",
        action="store", type=utf8_decoder,
        help="source directory from where import"
    )

    args = parser.parse_args()

    loader_class = choose_loader(
        args.loader,
        args.import_directory,
        parser.error
    )

    importer = ContestImporter(path=args.import_directory,
                               test=args.test,
                               zero_time=args.zero_time,
                               user_number=args.user_number,
                               import_tasks=args.import_tasks,
                               import_users=args.import_users,
                               update_contest=args.update_contest,
                               update_tasks=args.update_tasks,
                               no_statements=args.no_statements,
                               loader_class=loader_class)
    success = importer.do_import()
    return 0 if success is True else 1
Beispiel #16
0
def main():
    """Parse arguments and launch process."""

    parser = argparse.ArgumentParser(
        description="""\
Import a contest from disk

If updating a contest already in the DB:
- tasks attached to the contest in the DB but not to the contest to be imported
  will be detached;
- participations attached to the contest in the DB but not to the contest to be
  imported will be retained, this to avoid deleting submissions.

""",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter
    )

    parser.add_argument(
        "-y", "--yes",
        action="store_true",
        help="don't ask for confirmation before deleting data"
    )
    parser.add_argument(
        "-z", "--zero-time",
        action="store_true",
        help="set to zero contest start and stop time"
    )
    parser.add_argument(
        "-L", "--loader",
        action="store", type=utf8_decoder,
        default=None,
        help="use the specified loader (default: autodetect)"
    )
    parser.add_argument(
        "-i", "--import-tasks",
        action="store_true",
        help="import tasks if they do not exist"
    )
    parser.add_argument(
        "-u", "--update-contest",
        action="store_true",
        help="update an existing contest"
    )
    parser.add_argument(
        "-U", "--update-tasks",
        action="store_true",
        help="update existing tasks"
    )
    parser.add_argument(
        "-S", "--no-statements",
        action="store_true",
        help="do not import / update task statements"
    )
    parser.add_argument(
        "--delete-stale-participations",
        action="store_true",
        help="when updating a contest, delete the participations not in the "
        "new contest, including their submissions and other data"
    )
    parser.add_argument(
        "import_directory",
        action="store", type=utf8_decoder,
        help="source directory from where import"
    )

    args = parser.parse_args()

    loader_class = choose_loader(
        args.loader,
        args.import_directory,
        parser.error
    )

    importer = ContestImporter(
        path=args.import_directory,
        yes=args.yes,
        zero_time=args.zero_time,
        import_tasks=args.import_tasks,
        update_contest=args.update_contest,
        update_tasks=args.update_tasks,
        no_statements=args.no_statements,
        delete_stale_participations=args.delete_stale_participations,
        loader_class=loader_class)
    success = importer.do_import()
    return 0 if success is True else 1
Beispiel #17
0
def main():
    """Parse arguments and launch process."""

    parser = argparse.ArgumentParser(
        description="""\
Import a contest from disk

If updating a contest already in the DB:
- tasks attached to the contest in the DB but not to the contest to be imported
  will be detached;
- participations attached to the contest in the DB but not to the contest to be
  imported will be retained, this to avoid deleting submissions.

""",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter)

    group = parser.add_mutually_exclusive_group()

    group.add_argument("-z",
                       "--zero-time",
                       action="store_true",
                       help="set to zero contest start and stop time")
    parser.add_argument("-L",
                        "--loader",
                        action="store",
                        type=utf8_decoder,
                        default=None,
                        help="use the specified loader (default: autodetect)")
    parser.add_argument("-i",
                        "--import-tasks",
                        action="store_true",
                        help="import tasks if they do not exist")
    parser.add_argument("-u",
                        "--update-contest",
                        action="store_true",
                        help="update an existing contest")
    parser.add_argument("-U",
                        "--update-tasks",
                        action="store_true",
                        help="update existing tasks")
    parser.add_argument("-S",
                        "--no-statements",
                        action="store_true",
                        help="do not import / update task statements")
    parser.add_argument("import_directory",
                        action="store",
                        type=utf8_decoder,
                        help="source directory from where import")

    args = parser.parse_args()

    loader_class = choose_loader(args.loader, args.import_directory,
                                 parser.error)

    importer = ContestImporter(path=args.import_directory,
                               zero_time=args.zero_time,
                               import_tasks=args.import_tasks,
                               update_contest=args.update_contest,
                               update_tasks=args.update_tasks,
                               no_statements=args.no_statements,
                               loader_class=loader_class)
    success = importer.do_import()
    return 0 if success is True else 1
Beispiel #18
0
def main():
    """Parse arguments and launch process."""

    parser = argparse.ArgumentParser(
        description="Import a contest from disk",
        epilog=build_epilog(),
        formatter_class=argparse.RawDescriptionHelpFormatter)

    group = parser.add_mutually_exclusive_group()

    group.add_argument("-z",
                       "--zero-time",
                       action="store_true",
                       help="set to zero contest start and stop time")
    group.add_argument("-t",
                       "--test",
                       action="store_true",
                       help="setup a contest for testing "
                       "(times: 1970, 2100; ips: unset, passwords: a)")
    parser.add_argument("-n",
                        "--user-number",
                        action="store",
                        type=int,
                        help="put N random users instead of importing them")
    parser.add_argument("-L",
                        "--loader",
                        action="store",
                        type=utf8_decoder,
                        default=None,
                        help="use the specified loader (default: autodetect)")
    parser.add_argument("-i",
                        "--import-tasks",
                        action="store_true",
                        help="import tasks if they do not exist")
    parser.add_argument("-u",
                        "--update-contest",
                        action="store_true",
                        help="update an existing contest")
    parser.add_argument("-U",
                        "--update-tasks",
                        action="store_true",
                        help="update existing tasks")
    parser.add_argument("-S",
                        "--no-statements",
                        action="store_true",
                        help="do not import / update task statements")
    parser.add_argument("import_directory",
                        action="store",
                        type=utf8_decoder,
                        help="source directory from where import")

    args = parser.parse_args()

    loader_class = choose_loader(args.loader, args.import_directory,
                                 parser.error)

    importer = ContestImporter(path=args.import_directory,
                               test=args.test,
                               zero_time=args.zero_time,
                               user_number=args.user_number,
                               import_tasks=args.import_tasks,
                               update_contest=args.update_contest,
                               update_tasks=args.update_tasks,
                               no_statements=args.no_statements,
                               loader_class=loader_class)
    success = importer.do_import()
    return 0 if success is True else 1