def main() -> None: parser = argparse.ArgumentParser() parser.add_argument("user", type=str, help="github username") parser.add_argument("password", type=str, help="github password") parser.add_argument("repo", type=str, help="github repository name") parser.add_argument('config', type=str, help='config file for the lab') parser.add_argument('-v', '--verbose', action='store_true', help='enable verbose output') args = parser.parse_args() self_check() # get config conf = Config(args.config, args.verbose) # init Github SDK g = Github(args.user, args.password) # guser = g.get_user() org = g.get_organization("williams-cs") # TODO: verify that local repo is on the correct branch # issue pull request for given repo Infrastructor.issue_pull_request(conf, args.repo, org)
def main() -> None: parser = argparse.ArgumentParser() parser.add_argument("user", type=str, help="github username") parser.add_argument("password", type=str, help="github password") parser.add_argument('config', type=str, help='config file for the lab') parser.add_argument('-v', '--verbose', action='store_true', help='enable verbose output') args = parser.parse_args() # get config self_check() conf = Config(args.config, args.verbose) # init Github SDK g = Github(args.user, args.password) # guser = g.get_user() org = g.get_organization("williams-cs") # TODO: verify that local repo is on the correct branch basepath = conf.submission_path for repo in conf.repositories: # get submissions dir path for repo rdir = conf.pull_path(basepath, repo, False, conf.anonymize_sub_path) if not Infrastructor.branch_exists(conf, rdir): print(f"No feedback branch for {rdir}") continue # issue pull request for given repo print(f"issuing pull request for {rdir}") Infrastructor.issue_pull_request(conf, rdir, org) # Github aggressively rate-limits; sleep to avoid pain sleep(1)
def main() -> None: # get config args = Infrastructor.default_parser.parse_args() self_check() conf = Config(args.config, args.verbose) # issue go through the student repos, and add them as remotes for the # starter repo in the config. then push the default branch of the starter # repo to the student repo's default branch Infrastructor.push_starter(conf)
def main() -> None: args = Infrastructor.default_parser.parse_args() # get config self_check() conf = Config(args.config, args.verbose) # copy every commented assignment from TA location to submissions folder Infrastructor.copy_from_ta_folders(conf, conf.ta_path, conf.assignment_name, conf.submission_path) # commit changes Infrastructor.commit_changes(conf, conf.submission_path)
def main() -> None: # get config parser = argparse.ArgumentParser( description='collect the contents of all README.md files into one ' 'place, labeled by GitHub ID in order to update ' 'gradebooks') parser.add_argument('config', type=str, help='config file for the lab') parser.add_argument('feedback_file', type=str, help='file in repo where feedback is left (often ' 'README.md)') parser.add_argument('-v', '--verbose', action='store_true', help='enable verbose output') args = parser.parse_args() self_check() conf = Config(args.config, args.verbose) for student in sorted(conf.list_of_users): repo = conf.lookupRepo(student) # get submissions dir path for repo rdir = conf.pull_path(conf.submission_path, repo, False, conf.anonymize_sub_path) # all graded labs should have a feedback branch # if not infra.branch_exists(rdir): # print("\n\n") # print("# ERROR for {}".format(student)) # print("# No feedback branch in {}".format(rdir)) # print("\n\n") # continue # dump username and README.md contents to stdout print(f"# BEGIN {student} FEEDBACK") print(f"__({rdir})__") dump_file(os.path.join(rdir, args.feedback_file)) print(f"## END {student} FEEDBACK") print("\n\n")
def main() -> None: parser = argparse.ArgumentParser() parser.add_argument("user", type=str, help="github username") parser.add_argument("password", type=str, help="github password") parser.add_argument('config', type=str, help='config file for the lab') parser.add_argument('-v', '--verbose', action='store_true', help='enable verbose output') args = parser.parse_args() # Read in json config (generated with generate_config.py) # with open(conf_file, 'r') as f: # conf_json = json.load(f) # # seed RNG based on assignment name # seed = Config.java_string_hashcode(conf.assignment_name) # random.seed(seed) self_check() conf = Config(args.config, args.verbose) conf.pretty_print() # connect to github g = Github(args.user, args.password) # guser = g.get_user() org = g.get_organization("williams-cs") for repo_name, group in conf.repo2group.items(): # repo = None try: # check to see if repository already exists repo = org.get_repo(repo_name) ans = input(f"delete repository {repo_name}? (y/n) ") if ans == "y": repo.delete() except GithubException: print(f"GitHubException. " f"We could not delete repository {repo_name}")
def main() -> None: args = Infrastructor.default_parser.parse_args() # get config self_check() conf = Config(args.config, args.verbose) conf.pretty_print() # clone/update archive Infrastructor.pull_all(conf, conf.archive_path, True, False) Infrastructor.pull_all(conf, conf.submission_path, False, conf.anonymize_sub_path) # copy to TA folders Infrastructor.copy_to_ta_folders(conf, conf.ta_path, conf.assignment_name, conf.submission_path) ## set group permissions in submissions directory ... ## call(["chmod", "-R", "2770", conf.submission_path]) ## in group permissions in TA directory ... ## ta = f"{conf.ta_path}/{conf.assignment_name}" call(["chmod", "-R", "2770", ta])
def main() -> None: # get config parser = argparse.ArgumentParser( description='Run a command (e.g., autograding script) in each TA ' 'folder. Optionally dump the output to a file in the ' 'repository.') parser.add_argument('config', type=str, help='config file for the lab') parser.add_argument('command', type=str, help='bash command to run in each "TA" repo. Passed ' 'to Popen') parser.add_argument('output_file', type=str, help='File (in each repo) where output is stored.') parser.add_argument('-v', '--verbose', action='store_true', help='enable verbose output') args = parser.parse_args() self_check() conf = Config(args.config, args.verbose) # basepath = conf.ta_path for repo in conf.repositories: ta_dir = conf.TA_target(conf.ta_path, conf.assignment_name, repo) print(f"{repo}: {ta_dir}") with subprocess.Popen(args=args.command.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, cwd=ta_dir) as proc: output = proc.stdout.read() with open(os.path.join(ta_dir, args.output_file), 'a') as fout: print(output, file=fout)
def main() -> None: parser = argparse.ArgumentParser() parser.add_argument("user", type=str, help="github username") parser.add_argument("password", type=str, help="github password") parser.add_argument('config', type=str, help='config file for the lab') parser.add_argument('-v', '--verbose', action='store_true', help='enable verbose output') args = parser.parse_args() self_check() conf = Config(args.config, args.verbose) conf.pretty_print() # connect to github g = Github(args.user, args.password) org = g.get_organization("williams-cs") for repo_name, group in conf.repo2group.items(): # repo = None try: # check to see if repository already exists repo = org.get_repo(repo_name) except GithubException: # if not, create repository # auto_init=False so no README.md, license.txt, .gitignore --- # use push-starter.py after running this script print(f"creating repository {repo_name}") repo = org.create_repo( repo_name, description=(" and ".join(group) + "'s " + conf.course + "repository for " + conf.assignment_name + "."), private=True, auto_init=False) # add write privs for each student login for student in group: print(f"getting user for {student}") suser = g.get_user(student) # at this point, the repository is guaranteed to exist, # but sometimes Github will return a 404 for recently-created # repositories retries = 3 success = False while retries > 0: try: # add student as write-enabled collaborator print(f"adding {student} as collaborator to {repo_name} " f"repository.") repo.add_to_collaborators(suser) retries = 0 success = True except GithubException: retries -= 1 print(f"Could not find repository {repo_name}. " f"Sleeping...") time.sleep(5) # wait 5 seconds if not success: raise CannotAddUserToRepo