diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 0b553a59..2622fba2 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -1498,7 +1498,7 @@ class XCCClient(IMMClient): progress({'phase': 'upload', 'progress': 100.0 * rsp['received'] / rsp['size']}) elif rsp['state'] != 'done': - if rsp.get('status', None) == 413: + if rsp.get('status', None) == 413 or uploadthread.rspstatus == 413: raise Exception('File is larger than supported') raise Exception('Unexpected result:' + repr(rsp)) uploadstate = rsp['state'] diff --git a/pyghmi/util/webclient.py b/pyghmi/util/webclient.py index fd746b95..fe770b8b 100644 --- a/pyghmi/util/webclient.py +++ b/pyghmi/util/webclient.py @@ -53,11 +53,17 @@ class FileUploader(threading.Thread): self.data = data self.otherfields = otherfields self.formname = formname + self.rsp = '' + self.rspstatus = 500 super(FileUploader, self).__init__() def run(self): - self.rsp = self.wc.upload(self.url, self.filename, self.data, - self.formname, otherfields=self.otherfields) + try: + self.rsp = self.wc.upload(self.url, self.filename, self.data, + self.formname, otherfields=self.otherfields) + except Exception: + self.rspstatus = self.wc.rspstatus + raise class FileDownloader(threading.Thread): @@ -244,6 +250,7 @@ class SecureHTTPConnection(httplib.HTTPConnection, object): del uploadforms[filename] except KeyError: # something could have already deleted it pass + self.rspstatus = rsp.status if rsp.status != 200: raise Exception('Unexpected response in file upload: ' + rsp.read())