Created
November 3, 2016 04:45
-
-
Save zzeleznick/e9c7c2bac34746ff52469a5562219b16 to your computer and use it in GitHub Desktop.
Clones repos for student projects to be graded
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
import subprocess | |
# Internal Python Modules | |
from get_urls import URLS | |
DEST = "repos" | |
class FileManager(object): | |
dest = DEST | |
if not os.path.exists(dest): | |
os.mkdir(dest) | |
home = os.getcwd() | |
def __enter__(self): | |
os.chdir(self.dest) | |
return self | |
def __exit__(self, type, value, traceback): | |
os.chdir(self.home) | |
with FileManager() as FM: | |
failures = 0 | |
total = len(URLS) | |
for (idx, url) in enumerate(URLS): | |
username = url.split("https://github.com/")[-1].split("/")[0] | |
command = ['git', 'clone', url, username] | |
if os.path.exists(username): | |
print "(%s)-[%s] already cloned " % (idx, username) | |
continue | |
try: | |
result = subprocess.check_output(command, stderr=subprocess.STDOUT) | |
except Exception as e: | |
failures += 1 | |
print "(%s)-[%s] FAILED -- %s " % (idx, username, e) | |
else: | |
print "(%s)-[%s] clone success " % (idx, username) | |
print "Cloned %s of %s repos" % (total - failures, total) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add the URLS that you need to clone | |
URLS = [ | |
"https://github.com/TianyiSun/ios-decal-proj1.git", | |
"https://github.com/Zeronica/ios-decal-proj1.git", | |
"https://github.com/tvanness28/ios-decal-proj1.git", | |
"https://github.com/vikascbh/ios-decal-proj1.git", | |
"https://github.com/williampsmith/ios-decal-proj1.git", | |
"https://github.com/willyoungs/ios-decal-proj1.git", | |
"https://github.com/yadelab/ios-decal-proj1.git", | |
"https://github.com/YAQIMIAO/ios-decal-proj1.git", | |
"https://github.com/yeshunlin/ios-decal-proj1.git", | |
"https://github.com/deathisnotacurse/ios-decal-proj1.git", | |
"https://github.com/tuotuo251/ios-decal-proj1.git", | |
"https://github.com/zzeleznick/ios-decal-proj1.git" | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment