1
0
mirror of https://github.com/mbirth/tcl_ota_check.git synced 2024-09-19 22:33:25 +01: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 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

View File

@ -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)