1
0
mirror of https://github.com/HorlogeSkynet/archey4 synced 2025-04-13 04:00:15 +02:00

[CORE] Don't crash when reading from /sys/ file system is not allowed

This commit is contained in:
Samuel FORESTIER 2021-10-16 10:23:08 +02:00
parent 70144a1ed9
commit 8d5ae79ac8
3 changed files with 9 additions and 8 deletions

@ -9,6 +9,7 @@ and this project (partially) adheres to [Semantic Versioning](https://semver.org
### Changed
- Fix `df` output parsing when file-systems column contain white-spaces in `Disk`
- Prevent program crash when calling external programs raise `PermissionError` exception
- Prevent program crash when reading from `/sys/` file system is not allowed
## [v4.13.1] - 2021-09-04
### Changed

@ -84,7 +84,7 @@ class Model(Entry):
'/sys/devices/virtual/dmi/id/product_name', encoding='UTF-8'
) as f_product_name:
product_name = f_product_name.read().rstrip()
except FileNotFoundError:
except OSError:
return None
# Stop `/sys/devices/virtual/dmi/id/*` parsing on fuzzy data.
@ -96,7 +96,7 @@ class Model(Entry):
'/sys/devices/virtual/dmi/id/product_version', encoding='UTF-8'
) as f_product_version:
product_version = f_product_version.read().rstrip()
except FileNotFoundError:
except OSError:
product_version = ''
if not product_version:

@ -131,14 +131,14 @@ class Temperature(Entry):
def _poll_thermal_zones(self):
# We just check for values within files present in the path below.
for thermal_file in iglob(r'/sys/class/thermal/thermal_zone*/temp'):
with open(thermal_file, encoding='ASCII') as file:
try:
try:
with open(thermal_file, encoding='ASCII') as file:
temp = float(file.read())
except OSError:
continue
except OSError:
continue
if temp != 0.0:
self._temps.append(temp / 1000)
if temp != 0.0:
self._temps.append(temp / 1000)
def _run_istats_or_osxcputemp(self):
"""