[Git][NTPsec/ntpsec][master] temp-temp: glob-ify ZONE detection.

Gary E. Miller gitlab at mg.gitlab.com
Fri Jan 27 04:25:14 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
2f98209b by Gary E. Miller at 2017-01-26T20:24:43-08:00
temp-temp: glob-ify ZONE detection.

- - - - -


1 changed file:

- contrib/temp-log.py


Changes:

=====================================
contrib/temp-log.py
=====================================
--- a/contrib/temp-log.py
+++ b/contrib/temp-log.py
@@ -172,19 +172,17 @@ class Temper:
 class ZoneTemp:
     "Zone sensors"
     def __init__(self):
-        self._base_dir = '/sys/class/thermal/'
-        self.zone_directories = []
-        for child in os.listdir(self._base_dir):
-            if re.compile('thermal_zone').match(child):
-                self.zone_directories.append(child)
+        base_dir = '/sys/class/thermal/thermal_zone?/'
+        self.zones = []
+        for child in glob.glob(base_dir):
+            self.zones.append(child)
 
     def get_data(self):
         "Collects the data and return the output as an array"
         _zone = 0
         _data = []
-        for zone in self.zone_directories:
-            _zone_data = open(os.path.join(os.path.join(self._base_dir, zone),
-                                           'temp'))
+        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())



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/2f98209bb5ef7144c013e52185586090a6cc9589
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170127/fe822803/attachment.html>


More information about the vc mailing list