[Git][NTPsec/ntpsec][master] address issue #451: ntplogtemp crashes if lm sensors installed with no thermometers detected

Matt Selsky gitlab at mg.gitlab.com
Wed Jan 17 05:30:00 UTC 2018


Matt Selsky pushed to branch master at NTPsec / ntpsec


Commits:
5a361938 by James Browning at 2018-01-16T10:35:37-08:00
address issue #451: ntplogtemp crashes if lm sensors installed with no thermometers detected

- - - - -


1 changed file:

- ntpclients/ntplogtemp.py


Changes:

=====================================
ntpclients/ntplogtemp.py
=====================================
--- a/ntpclients/ntplogtemp.py
+++ b/ntpclients/ntplogtemp.py
@@ -90,13 +90,18 @@ class CpuTemp:
         # grab the needed output
         output = run_binary(["sensors", "-u"])
 
-        for record in output:
-            match = self._pattern.match(record)
-            if match and match.group(1):
-                _now = int(time.time())
-                _cpu_temprature = match.group(1)
-                _data.append('%d LM%s %s' % (_now, _index, _cpu_temprature))
-                _index += 1
+        if output is not None:
+            for record in output:
+                match = self._pattern.match(record)
+                if match and match.group(1):
+                    _now = int(time.time())
+                    _cpu_temprature = match.group(1)
+                    _data.append('%d LM%s %s' % (_now, _index, _cpu_temprature))
+                    _index += 1
+        else:
+            self.has_sensors = False
+            if args.verbose:
+                sys.stderr.write("No sensors returned temperatures. Have you run sensors-detect?")
 
         return _data
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/5a36193859b208546ef2e4328e50387c99d7b40d

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/5a36193859b208546ef2e4328e50387c99d7b40d
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/20180117/b05ddffc/attachment.html>


More information about the vc mailing list