def download_course_tarball(self):
'''
Download tar.gz of full course content (via Studio)
'''
self.ensure_studio_site()
if self.verbose:
print "Downloading tar.gz for %s" % (self.course_id)
url = '%s/export/%s?_accept=application/x-tgz' % (self.BASE, self.course_id)
r3 = self.ses.get(url)
if not r3.ok or (r3.status_code==404):
url = '%s/export/slashes:%s+%s?_accept=application/x-tgz' % (self.BASE, self.course_id.replace('/','+'), sem)
r3 = self.ses.get(url)
dt = time.ctime(time.time()).replace(' ','_').replace(':','')
ofn = '%s/COURSE-%s___%s.tar.gz' % (self.data_dir, self.course_id.replace('/','__'), dt)
self.ensure_data_dir_exists()
with open(ofn, 'w') as fp:
fp.write(r3.content)
print "--> %s" % (ofn)
return ofn
评论列表
文章目录