Commit 2b703b16 authored by Quentin Aristote's avatar Quentin Aristote
Browse files

handle download failure

parent 13dea479
......@@ -132,7 +132,10 @@ def downloadFile(html, path = '.') :
cwd = os.getcwd()
os.chdir(directory)
url = HOSTNAME + html.find('a', attrs = {'class' : 'button raised'})['href']
try :
url = HOSTNAME + html.find('a', attrs = {'class' : 'button raised'})['href']
except :
raise FileNotFoundError('the file does not seem available for download.')
filename, _ = urllib.request.urlretrieve(url, filename = filename)
os.chdir(cwd)
......@@ -181,8 +184,12 @@ def getRecordings(directory = '.',
path = os.path.join(directory, filename)
if not(os.path.isfile(path)) or overwrite :
file_html = getFileHTML(id)
_ = downloadFile(file_html, path = path)
print('Downloading {filename} ...'.format(filename = filename))
try :
_ = downloadFile(file_html, path = path)
print('Success.')
except Exception as e :
print('Failure : {exception}'.format(exception = e))
return None
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment