diff options
author | Jeff Lane <jeffrey.lane@canonical.com> | 2015-07-17 11:21:49 -0400 |
---|---|---|
committer | Jeff Lane <jeffrey.lane@canonical.com> | 2015-07-17 11:21:49 -0400 |
commit | aba456242f6b053365d461da03ee7c3a525dc683 (patch) | |
tree | d2136e49ea7d42821ae617ed6b9f0890fa0ec8cb /bin | |
parent | f73e4610cf69e41349b69b08be620e2f7a4fe84e (diff) |
Changed sysfs_cpu try/except block to catch FileNotFoundError when run on systems without sysfs (ARM)
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/cpu_topology | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bin/cpu_topology b/bin/cpu_topology index e113ae6..4cb2249 100755 --- a/bin/cpu_topology +++ b/bin/cpu_topology @@ -44,10 +44,13 @@ class sysfs_cpu(): self.path = '/sys/devices/system/cpu/' + proc + '/topology' items = ['core_id', 'physical_package_id'] for i in items: - syscpu_fh = open(os.path.join(self.path, i), 'r') try: + syscpu_fh = open(os.path.join(self.path, i), 'r') + except FileNotFoundError: + print("/sys/devices seems to be missing, unable to continue") + sys.exit(1) + else: self.syscpu[i] = syscpu_fh.readline().strip() - finally: syscpu_fh.close() |