Пример #1
0
def get(args):
    if args.student:
        raise NotImplementedError("'--student' is not implemented")

    with config(args.config) as conf:
        path = os.path.join(args.path, args.name)
        os.makedirs(path, mode=0o700, exist_ok=True)

        count = 0
        for student in conf['roster']:
            name = StudentRepo.name(conf['semester'], student['section'], args.name, student['username'])

            try:
                repo = StudentRepo(conf['gitlab-host'], conf['namespace'], name, conf['token'])
                repo.clone_to(os.path.join(path, student['username']))
                count += 1
            except HTTPError as e:
                if e.response.status_code == 404:
                    logging.warn("Repository %s does not exist.", name)
                else:
                    raise

    print("Cloned ", count, " repositories")
Пример #2
0
def get(conf, args):
    """Creates a folder for the assignment in the CWD (or <path>, if specified)
    and clones each students' repository into subfolders.
    """
    hw_name = args.name
    hw_path = args.path
    host = conf.gitlab_host
    namespace = conf.namespace
    token = conf.token
    semester = conf.semester

    roster = get_filtered_roster(conf.roster, args.section, args.student)

    path = os.path.join(hw_path, hw_name)
    os.makedirs(path, mode=0o700, exist_ok=True)

    count = 0
    for student in roster:
        username = student["username"]
        student_section = student["section"]
        full_name = StudentRepo.name(semester, student_section,
                                     hw_name, username)

        try:
            repo = StudentRepo(host, namespace, full_name, token)
            repo.clone_to(os.path.join(path, username))
            count += 1
        except RepoError as e:
            logging.warn(str(e))
        except HTTPError as e:
            if e.response.status_code == 404:
                logging.warn("Repository {} does not exist.".format(full_name))
            else:
                raise

    print("Cloned {} repositories.".format(count))