Fix empty size in response and write debug file on HTTP error
This commit is contained in:
@ -85,7 +85,10 @@ class UpdateInfo:
|
||||
for f in files:
|
||||
# For some reason, WebUpdater returns file size in KiB instead of Bytes
|
||||
size_kb = self.dom_get_text(f.getElementsByTagName("Size"))
|
||||
size_bytes = float(size_kb) * 1024
|
||||
if not size_kb.isdecimal():
|
||||
size_bytes = None
|
||||
else:
|
||||
size_bytes = float(size_kb) * 1024
|
||||
self.files.append( {
|
||||
"url": self.dom_get_text(f.getElementsByTagName("Location")),
|
||||
"md5": self.dom_get_text(f.getElementsByTagName("MD5Sum")),
|
||||
@ -288,14 +291,14 @@ class UpdateServer:
|
||||
|
||||
r = requests.post(WEBUPDATER_SOFTWAREUPDATE_URL, headers=headers, data=data)
|
||||
|
||||
if r.status_code != 200:
|
||||
r.raise_for_status()
|
||||
return None
|
||||
|
||||
if self.debug:
|
||||
#print(r.content)
|
||||
with open("webupdaterreply.xml", "wb") as f:
|
||||
f.write(r.content)
|
||||
f.close()
|
||||
|
||||
if r.status_code != 200:
|
||||
r.raise_for_status()
|
||||
return None
|
||||
|
||||
return r.content
|
||||
|
Reference in New Issue
Block a user