Exemplo n.º 1
0
def manage_users(args, level):
    if args.dry_run:
        raise NotImplementedError("'--dry-run' is not implemented")
    if args.student:
        raise NotImplementedError("'--student' is not implemented")

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

            if 'id' in student:
                try:
                    repo = StudentRepo(conf['gitlab-host'], conf['namespace'], name, conf['token'])
                    repo.edit_member(student['id'], level)
                    count += 1
                except HTTPError as e:
                    raise
                    if e.response.status_code == 404:
                        logging.warning("Repository %s does not exist.", name)
                    else:
                        raise
            else:
                logging.warning("Student %s does not have a gitlab account.", student['username'])

    print("Changed ", count, " repositories.")
Exemplo n.º 2
0
def manage_users(conf, args, level):
    """Creates a folder for the assignment in the CWD (or <path>, if specified)
    and clones each students' repository into subfolders.
    """
    hw_name = args.name
    dry_run = args.dry_run

    if dry_run:
        raise NotImplementedError("'--dry-run' is not implemented")

    host = conf.gitlab_host
    namespace = conf.namespace
    token = conf.token
    semester = conf.semester

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

    count = 0
    for student in roster:
        username = student["username"]
        student_section = student["section"]
        if "id" not in student:
            logging.warning(
                "Student {} does not have a gitlab account.".format(username)
            )
            continue
        full_name = StudentRepo.name(semester, student_section,
                                     hw_name, username)

        try:
            repo = StudentRepo(host, namespace, full_name, token)
            repo.edit_member(student["id"], level)
            count += 1
        except HTTPError:
            raise

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