From: Michael Tremer Date: Tue, 11 Aug 2015 22:11:50 +0000 (+0200) Subject: Catch exception when cpufreq is not supported on a system X-Git-Tag: 004~37 X-Git-Url: http://git.ipfire.org/?p=collecty.git;a=commitdiff_plain;h=0993237d60c480296bbf05c57c4d540ae669a937;hp=63f9f8beed445a80dcb492570b105c5b50e65a59 Catch exception when cpufreq is not supported on a system Signed-off-by: Michael Tremer --- diff --git a/src/collecty/plugins/cpufreq.py b/src/collecty/plugins/cpufreq.py index 19f099a..453e08e 100644 --- a/src/collecty/plugins/cpufreq.py +++ b/src/collecty/plugins/cpufreq.py @@ -112,6 +112,11 @@ class CPUFreqObject(base.Object): 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"), @@ -155,6 +160,10 @@ class CPUFreqPlugin(base.Plugin): 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)