Pull.py for cs201

This code can be used to automatically download CS201’s homework template files.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
import os
import wget, tarfile
a=input("HW#:")
path="HWpath"+str(a)

out_fname='HW'+str(a)+'.tar.gz'
url ="http://repolab.colab.duke.edu/courses/cs201/assignments/HW"+str(a)+"/"+out_fname
wget.download(url, out=out_fname)
tar = tarfile.open(out_fname)
tar.extractall()
tar.close()
os.remove(out_fname)
for root, dirs, files in os.walk(path, topdown=False):
    for name in dirs:
        if name != "wdir_msg":
            print('Downloading'+os.path.join(root, name))
            os.chdir(os.path.join(root, name))
            #os.popen('cd '+os.path.join(root, name)).read()
            os.popen('make init-pull').read()