def open_assignment(conf, args): """Adds each student in the roster to their respective homework repositories as Developers so they can pull/commit/push their work. """ hw_name = args.name 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"] full_name = StudentRepo.name(semester, student_section, hw_name, username) try: repo = StudentRepo(host, namespace, full_name, token) if "id" not in student: student["id"] = Repo.get_user_id(username, host, token) repo.add_member(student["id"], Access.developer) count += 1 except RepoError: logging.warn("Could not add {} to {}.".format(username, full_name)) except HTTPError: raise print("Granted access to {} repositories.".format(count))
def open_assignment(args): with config(args.config) as conf: 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']) if 'id' not in student: student['id'] = Repo.get_user_id(student['username'], conf['gitlab-host'], conf['token']) repo.add_member(student['id'], Access.developer) count += 1 except RepoError: logging.warn("Could not add %s to %s", student['username'], name) except HTTPError as e: raise if e.response.status_code == 404: logging.warn("Repository %s does not exist.", name) else: raise print("Granted access to ", count, " repositories")