]> git.ipfire.org Git - collecty.git/commitdiff
Catch exception when cpufreq is not supported on a system
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 11 Aug 2015 22:11:50 +0000 (00:11 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 11 Aug 2015 22:11:50 +0000 (00:11 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/collecty/plugins/cpufreq.py

index 19f099a31981ae87d2b78d2bc83aea4db0129e0f..453e08edb0870abed4975741346351e3a600c3e8 100644 (file)
@@ -112,6 +112,11 @@ class CPUFreqObject(base.Object):
        def core_id(self):
                return self.read_file("topology/core_id")
 
        def core_id(self):
                return self.read_file("topology/core_id")
 
+       def is_cpufreq_supported(self):
+               path = os.path.join(self.sys_path, "cpufreq")
+
+               return os.path.exists(path)
+
        def collect(self):
                return (
                        self.read_frequency("cpufreq/cpuinfo_cur_freq"),
        def collect(self):
                return (
                        self.read_frequency("cpufreq/cpuinfo_cur_freq"),
@@ -155,6 +160,10 @@ class CPUFreqPlugin(base.Plugin):
                        if o.core_id in core_ids:
                                continue
 
                        if o.core_id in core_ids:
                                continue
 
+                       # Check if this processor is supported by cpufreq
+                       if not o.is_cpufreq_supported():
+                               continue
+
                        # Save the ID of the added core
                        core_ids.append(o.core_id)
 
                        # Save the ID of the added core
                        core_ids.append(o.core_id)