1
0
mirror of https://github.com/mbirth/tcl_ota_check.git synced 2024-11-09 22:06:47 +00:00

clean up network error messages

This commit is contained in:
thurask 2017-09-07 12:47:13 -04:00
parent 1d3e6db9a6
commit 1ba638df00
No known key found for this signature in database
GPG Key ID: A6CCCDEA29795048
2 changed files with 6 additions and 1 deletions

View File

@ -5,7 +5,7 @@
import tcllib
import sys
from requests.exceptions import RequestException
from requests.exceptions import RequestException, Timeout
fc = tcllib.FotaCheck()
fc.serid = "3531510"
@ -28,6 +28,9 @@ for prdline in prds:
check_xml = fc.do_check()
curef, fv, tv, fw_id, fileid, fn, fsize, fhash = fc.parse_check(check_xml)
print("{}: {} {} ({})".format(prd, tv, fhash, model))
except Timeout as e:
print("{} failed. (Connection timed out.)".format(prd))
continue
except (SystemExit, RequestException) as e:
print("{} failed. ({})".format(prd, str(e)))
continue

View File

@ -87,6 +87,8 @@ class FotaCheck:
return req.text
elif req.status_code == 204:
raise requests.exceptions.HTTPError("No update available.", response=req)
elif req.status_code in (500, 503):
raise requests.exceptions.HTTPError("Server busy, try again later.", response=req)
else:
req.raise_for_status()
raise requests.exceptions.HTTPError("HTTP {}.".format(req.status_code), response=req)