Archived
1
1
Fork 0

Merge pull request #13 from joshlay/rtd_import_testfix

only set/use CARD and hwmon_dir if not None
This commit is contained in:
Josh Lay 2023-04-25 22:49:52 -05:00 committed by GitHub
commit 00e8eabb42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,11 +46,12 @@ def find_card() -> Optional[Tuple[Optional[str], Optional[str]]]:
# base vars: card identifier, hwmon directory for stats, then the stat dicts # base vars: card identifier, hwmon directory for stats, then the stat dicts
CARD, hwmon_dir = find_card() CARD, hwmon_dir = find_card()
card_dir = path.join("/sys/class/drm/", CARD) # eg: /sys/class/drm/card0/ if CARD is not None:
card_dir = path.join("/sys/class/drm/", CARD) # eg: /sys/class/drm/card0/
# dictionary of known source files # dictionary of known source files
# ref: https://docs.kernel.org/gpu/amdgpu/thermal.html # ref: https://docs.kernel.org/gpu/amdgpu/thermal.html
SRC_FILES = {'pwr_limit': path.join(hwmon_dir, "power1_cap"), SRC_FILES = {'pwr_limit': path.join(hwmon_dir, "power1_cap"),
'pwr_average': path.join(hwmon_dir, "power1_average"), 'pwr_average': path.join(hwmon_dir, "power1_average"),
'pwr_cap': path.join(hwmon_dir, "power1_cap_max"), 'pwr_cap': path.join(hwmon_dir, "power1_cap_max"),
'pwr_default': path.join(hwmon_dir, "power1_cap_default"), 'pwr_default': path.join(hwmon_dir, "power1_cap_default"),
@ -63,11 +64,11 @@ SRC_FILES = {'pwr_limit': path.join(hwmon_dir, "power1_cap"),
'fan_rpm_target': path.join(hwmon_dir, "fan1_target"), 'fan_rpm_target': path.join(hwmon_dir, "fan1_target"),
} }
# determine temperature nodes, construct a dict to store them # determine temperature nodes, construct a dict to store them
# interface will iterate over these, creating labels as needed # interface will iterate over these, creating labels as needed
TEMP_FILES = {} TEMP_FILES = {}
temp_node_labels = glob.glob(path.join(hwmon_dir, "temp*_label")) temp_node_labels = glob.glob(path.join(hwmon_dir, "temp*_label"))
for temp_node_label_file in temp_node_labels: for temp_node_label_file in temp_node_labels:
# determine the base node id, eg: temp1 # determine the base node id, eg: temp1
# construct the path to the file that will label it. ie: edge/junction # construct the path to the file that will label it. ie: edge/junction
temp_node_id = path.basename(temp_node_label_file).split('_')[0] temp_node_id = path.basename(temp_node_label_file).split('_')[0]