edxapi.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:edxcut 作者: mitodl 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号