[Git][NTPsec/ntpsec][master] Fewer bare "except" in python code
Matt Selsky
gitlab at mg.gitlab.com
Sun Aug 19 15:04:14 UTC 2018
Matt Selsky pushed to branch master at NTPsec / ntpsec
Commits:
35cde1fd by Matt Selsky at 2018-08-19T14:58:37Z
Fewer bare "except" in python code
int()/float() raise ValueError
open() raises IOError
- - - - -
3 changed files:
- contrib/ntpheatusb
- contrib/zone-temp-log
- ntpclients/ntpq.py
Changes:
=====================================
contrib/ntpheatusb
=====================================
@@ -220,7 +220,7 @@ try:
# make sure it is a temperature
temp = float(output[0])
break
- except:
+ except ValueError:
# bad data, try aagin
fail = True
if args.verbose:
=====================================
contrib/zone-temp-log
=====================================
@@ -39,7 +39,7 @@ zone = 0
while True:
try:
f = open('/sys/class/thermal/thermal_zone{0}/temp'.format(zone), 'r')
- except:
+ except IOError:
break
for line in f:
temp = float(line) / 1000
=====================================
ntpclients/ntpq.py
=====================================
@@ -354,7 +354,7 @@ usage: help [ command ]
if line.startswith("&"):
try:
idx = int(line[1:].split()[0])
- except:
+ except ValueError:
self.warn("Invalid index literal.\n")
return -1
if idx < 0 or idx >= 2**16-1:
@@ -368,7 +368,7 @@ usage: help [ command ]
else:
try:
associd = int(line.split()[0])
- except:
+ except ValueError:
self.warn("Invalid associd literal.\n")
return -1
if (associd != 0 and
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/35cde1fd362076b3b84bcc3c50f313724b5fe03f
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/35cde1fd362076b3b84bcc3c50f313724b5fe03f
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20180819/c035bd92/attachment-0001.html>
More information about the vc
mailing list