Skip to content

Commit

Permalink
catch 403 in downloading tarball
Browse files Browse the repository at this point in the history
  • Loading branch information
ichuang committed Jun 19, 2018
1 parent fc7f1dd commit 4248504
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion edxcut/edxapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,9 +767,15 @@ def download_course_tarball(self):
self.headers['Referer'] = url
self.headers['Accept'] = 'application/json, text/javascript, */*; q=0.01'
r3 = self.ses.post(url, headers=self.headers) # start the export process - tarball creation takes some time, poll until done
if r3.status_code==403:
print("Sorry, access forbidden for %s" % url)
try:
r3j = r3.json()
except Exception as err:
raise Exception("[edxapi] unknown response from server (%s): %s" % (url, r3.content))
try:
cnt = 0
estat = r3.json()['ExportStatus']
estat = r3j['ExportStatus']
url = '%s/export_status/%s' % (self.BASE, self.course_id)
while not estat==3:
cnt += 1
Expand Down

0 comments on commit 4248504

Please sign in to comment.