mirror of
https://github.com/mbirth/tcl_ota_check.git
synced 2024-11-10 06:16:46 +00:00
clean up network error messages
This commit is contained in:
parent
1d3e6db9a6
commit
1ba638df00
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import tcllib
|
import tcllib
|
||||||
import sys
|
import sys
|
||||||
from requests.exceptions import RequestException
|
from requests.exceptions import RequestException, Timeout
|
||||||
|
|
||||||
fc = tcllib.FotaCheck()
|
fc = tcllib.FotaCheck()
|
||||||
fc.serid = "3531510"
|
fc.serid = "3531510"
|
||||||
@ -28,6 +28,9 @@ for prdline in prds:
|
|||||||
check_xml = fc.do_check()
|
check_xml = fc.do_check()
|
||||||
curef, fv, tv, fw_id, fileid, fn, fsize, fhash = fc.parse_check(check_xml)
|
curef, fv, tv, fw_id, fileid, fn, fsize, fhash = fc.parse_check(check_xml)
|
||||||
print("{}: {} {} ({})".format(prd, tv, fhash, model))
|
print("{}: {} {} ({})".format(prd, tv, fhash, model))
|
||||||
|
except Timeout as e:
|
||||||
|
print("{} failed. (Connection timed out.)".format(prd))
|
||||||
|
continue
|
||||||
except (SystemExit, RequestException) as e:
|
except (SystemExit, RequestException) as e:
|
||||||
print("{} failed. ({})".format(prd, str(e)))
|
print("{} failed. ({})".format(prd, str(e)))
|
||||||
continue
|
continue
|
||||||
|
@ -87,6 +87,8 @@ class FotaCheck:
|
|||||||
return req.text
|
return req.text
|
||||||
elif req.status_code == 204:
|
elif req.status_code == 204:
|
||||||
raise requests.exceptions.HTTPError("No update available.", response=req)
|
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:
|
else:
|
||||||
req.raise_for_status()
|
req.raise_for_status()
|
||||||
raise requests.exceptions.HTTPError("HTTP {}.".format(req.status_code), response=req)
|
raise requests.exceptions.HTTPError("HTTP {}.".format(req.status_code), response=req)
|
||||||
|
Loading…
Reference in New Issue
Block a user