[Git][NTPsec/ntpsec][master] Handle OSError when 'temp' file is not readable
Matt Selsky (@selsky)
gitlab at mg.gitlab.com
Tue Mar 11 00:28:24 UTC 2025
Matt Selsky pushed to branch master at NTPsec / ntpsec
Commits:
f27cd277 by Daniel at 2025-03-11T00:25:05+00:00
Handle OSError when 'temp' file is not readable
Sometimes reading 'temp' generates an error message 'No data available'.
Wrapping it in a try/catch allow other temp zone to work as expected.
This bug was reported at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1098368
- - - - -
1 changed file:
- ntpclients/ntplogtemp.py
Changes:
=====================================
ntpclients/ntplogtemp.py
=====================================
@@ -219,13 +219,16 @@ class ZoneTemp:
_zone = 0
_data = []
for zone in self.zones:
- _zone_data = open(os.path.join(zone, 'temp'))
- for line in _zone_data:
- temp = float(line) / 1000
- _now = int(time.time())
- _data.append('%d ZONE%s %s' % (_now, _zone, temp))
- _zone += 1
- _zone_data.close()
+ try:
+ with open(os.path.join(zone, 'temp')) as _zone_data:
+ for line in _zone_data:
+ temp = float(line) / 1000
+ _now = int(time.time())
+ _data.append('%d ZONE%s %s' % (_now, _zone, temp))
+ _zone += 1
+ except OSError:
+ # temp might not be readable, if so continue on to the next one
+ continue
return _data
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/f27cd2775ace2de700b110992333d8a2a3473d3f
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/f27cd2775ace2de700b110992333d8a2a3473d3f
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/20250311/33e50dab/attachment-0001.htm>
More information about the vc
mailing list