forked from joshuacw/grading_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrade_module_6.py
More file actions
executable file
·49 lines (42 loc) · 1.28 KB
/
grade_module_6.py
File metadata and controls
executable file
·49 lines (42 loc) · 1.28 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
#!/usr/bin/env python
import sys
import os
import subprocess
from data.student_info import github_usernames
MODULE_NUMBER = 6
PROJECT = "debug_me"
folder_name = "module_" + str(MODULE_NUMBER) + "_repos"
results = {}
# Create a directory to hold all repositories
os.mkdir(folder_name)
# Navigate into that directory
os.chdir(folder_name)
# One by one, clone the repo, navigate inside, test the code
for username in github_usernames:
url = "https://github.com/" + username + "/" + PROJECT + ".git"
clone_path = username + "." + PROJECT
try:
# Clone the repo
subprocess.check_call(["git", "clone", url, clone_path])
except:
results[username] = "couldn't clone repository at " + url
print("Couldn't find it :/\n")
continue
# Navigate inside
os.chdir(clone_path)
# Test the code
try:
subprocess.check_call(["python", "add_five.py", "4"])
except:
# This means the script threw an error; it's not supposed to
results[username] = "code threw an error"
print("Error in code...")
os.chdir("..")
continue
results[username] = "correct"
print("Correct!\n")
# Navigate back
os.chdir("..")
# Print results
for user in github_usernames:
print(user + ": " + results[user])