-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetLabSubmissions.py
More file actions
executable file
·53 lines (41 loc) · 1.61 KB
/
getLabSubmissions.py
File metadata and controls
executable file
·53 lines (41 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python
import os
labSubmissionsDir = "labSubmissions"
if not os.access(labSubmissionsDir, os.W_OK):
os.mkdir(labSubmissionsDir, 0700)
import getpass
import sys
import argparse
from github_acadwf import pullRepoForGrading
# In the main directory of the repo where you are developing with PyGithub,
# type:
# git submodule add git://github.com/jacquev6/PyGithub.git PyGithub
# git submodule init
# git submodule update
#
# That will populate a PyGithub subdirectory with a clone of PyGithub
# Then, to add it to your Python path, you can do:
sys.path.append("./PyGithub");
from github import Github
from github import GithubException
parser = argparse.ArgumentParser(description='Pull repos for grading that start with a certain prefix')
parser.add_argument('prefix',help='prefix e.g. lab00')
parser.add_argument('-u','--githubUsername',
help="github username, default is current OS user",
default=getpass.getuser())
parser.add_argument('-o','--orgName',
help="organization e.g. UCSB-CS56-S13",
default='UCSB-CS56-S13')
args = parser.parse_args()
username = args.githubUsername
pw = getpass.getpass()
g = Github(username, pw, user_agent='PyGithub')
print("All repos for organization: ",args.orgName)
org = g.get_organization(args.orgName)
## TODO: Add some error checking code here to see whether
## the lookup was successful. Do we try/except or check the return value?
repos = org.get_repos()
for repo in repos:
if repo.name.startswith(args.prefix):
print(repo.name)
pullRepoForGrading(repo,labSubmissionsDir+'/'+args.prefix)