2
0
mirror of https://opendev.org/x/pyghmi synced 2025-08-31 15:28:07 +00:00

Fix download error reporting

Threaded downloads now
store the exception for passing
to the caller.

Change-Id: Ibe4a7a267b04a2775ad3775dd904a4e3c7520ebb
This commit is contained in:
Jarrod Johnson
2020-03-11 11:04:00 -04:00
parent daf2c36fb5
commit dd10bb7579
3 changed files with 9 additions and 1 deletions

View File

@@ -1018,6 +1018,8 @@ class XCCClient(IMMClient):
progress({'phase': 'download',
'progress': 100 * self.wc.get_download_progress()})
self._refresh_token()
if fd.exc:
raise fd.exc
if progress:
progress({'phase': 'complete'})
return savefile

View File

@@ -716,6 +716,8 @@ class OEMHandler(generic.OEMHandler):
progress({'phase': 'download',
'progress': 100 * self.wc.get_download_progress()})
self._refresh_token()
if fd.exc:
raise fd.exc
if progress:
progress({'phase': 'complete'})
return savefile

View File

@@ -74,10 +74,14 @@ class FileDownloader(threading.Thread):
self.wc = webclient
self.url = url
self.savefile = savefile
self.exc = None
super(FileDownloader, self).__init__()
def run(self):
self.wc.download(self.url, self.savefile)
try:
self.wc.download(self.url, self.savefile)
except Exception as e:
self.exc = e
def get_upload_form(filename, data, formname, otherfields):