From dd10bb7579cd453182d675545e0b47c0939ff41e Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 11 Mar 2020 11:04:00 -0400 Subject: [PATCH] Fix download error reporting Threaded downloads now store the exception for passing to the caller. Change-Id: Ibe4a7a267b04a2775ad3775dd904a4e3c7520ebb --- pyghmi/ipmi/oem/lenovo/imm.py | 2 ++ pyghmi/redfish/oem/lenovo/xcc.py | 2 ++ pyghmi/util/webclient.py | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 13870f7a..27143193 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -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 diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index fb7dd23d..6b7ad5b0 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -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 diff --git a/pyghmi/util/webclient.py b/pyghmi/util/webclient.py index 1e0004cd..8c6a58a8 100644 --- a/pyghmi/util/webclient.py +++ b/pyghmi/util/webclient.py @@ -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):