Skip to content

Commit

Permalink
Fixes for macOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasPantle authored and amanusk committed Jul 10, 2022
1 parent d7a9ee4 commit 231a5af
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
5 changes: 4 additions & 1 deletion s_tui/sources/fan_source.py
Expand Up @@ -28,7 +28,10 @@
class FanSource(Source):
""" Source for fan information """
def __init__(self):
if (not hasattr(psutil, "sensors_fans") and psutil.sensors_fans()):
try:
if psutil.sensors_fans():
self.is_available = True
except AttributeError:
self.is_available = False
logging.debug("Fans sensors is not available from psutil")
return
Expand Down
21 changes: 12 additions & 9 deletions s_tui/sources/rapl_read.py
Expand Up @@ -159,18 +159,21 @@ def read_power(self):

@staticmethod
def available():
cpuinfo = cat("/proc/cpuinfo", binary=False)
# The reader only supports family 17h CPUs
m = re.search(r"vendor_id[\s]+: ([A-Za-z]+)", cpuinfo)
try:
cpuinfo = cat("/proc/cpuinfo", binary=False)
# The reader only supports family 17h CPUs
m = re.search(r"vendor_id[\s]+: ([A-Za-z]+)", cpuinfo)

if not m or m is None:
return False
if not m or m is None:
return False

if m.group(1) != "AuthenticAMD":
return False
if m.group(1) != "AuthenticAMD":
return False

m = re.search(r"cpu family[\s]+: ([0-9]+)", cpuinfo)
if int(m[1]) != 0x17:
m = re.search(r"cpu family[\s]+: ([0-9]+)", cpuinfo)
if int(m[1]) != 0x17:
return False
except (FileNotFoundError, PermissionError):
return False

# with open("/proc/cpuinfo", "rb") as cpuinfo:
Expand Down
6 changes: 4 additions & 2 deletions s_tui/sources/temp_source.py
Expand Up @@ -33,8 +33,10 @@ class TempSource(Source):

def __init__(self, temp_thresh=None):
warnings.filterwarnings('ignore', '.*FileNotFound.*',)
if (not hasattr(psutil, "sensors_temperatures") and
psutil.sensors_temperatures()):
try:
if psutil.sensors_temperatures():
self.is_available = True
except AttributeError:
self.is_available = False
logging.debug("cpu temperature is not available from psutil")
return
Expand Down

0 comments on commit 231a5af

Please sign in to comment.