Archived
1
1
Fork 0

touch up linting after shuffling

This commit is contained in:
Josh Lay 2023-04-24 22:05:09 -05:00
parent b72f6d8056
commit 7447588552
Signed by: jlay
GPG key ID: B265E45CACAD108A
2 changed files with 45 additions and 9 deletions

View file

@ -1,4 +1,19 @@
from .utils import CARD, SRC_FILES, TEMP_FILES, format_frequency, read_stat """
interface.py
This module provides the TUI aspect of 'amdgpu-stats'
Classes:
- GPUStats: the object for the _Application_, instantiated at runtime
- GPUStatsWidget: the primary container for the three stat widgets:
- MiscDisplay
- ClockDisplay
- PowerDisplay
- LogScreen: Second screen with the logging widget, header, and footer
Functions:
- tui: Renders the TUI using the classes above
"""
import sys import sys
from textual.binding import Binding from textual.binding import Binding
@ -8,6 +23,8 @@ from textual.reactive import reactive
from textual.screen import Screen from textual.screen import Screen
from textual.widgets import Header, Footer, Static, TextLog, Label from textual.widgets import Header, Footer, Static, TextLog, Label
from .utils import CARD, SRC_FILES, TEMP_FILES, format_frequency, read_stat
class LogScreen(Screen): class LogScreen(Screen):
"""Creates a screen for the logging widget""" """Creates a screen for the logging widget"""
@ -209,10 +226,14 @@ class ClockDisplay(Static):
"""Called when the clocks attribute changes """Called when the clocks attribute changes
- Updates label values - Updates label values
- Casting inputs to string to avoid type problems w/ int/None""" - Casting inputs to string to avoid type problems w/ int/None"""
self.query_one("#clk_core_val", Static).update(f"{core_vals['sclk']}") self.query_one("#clk_core_val",
self.query_one("#util_pct", Static).update(f"{core_vals['util_pct']}%") Static).update(f"{core_vals['sclk']}")
self.query_one("#clk_voltage_val", Static).update(f"{core_vals['voltage']}V") self.query_one("#util_pct",
self.query_one("#clk_memory_val", Static).update(f"{core_vals['mclk']}") Static).update(f"{core_vals['util_pct']}%")
self.query_one("#clk_voltage_val",
Static).update(f"{core_vals['voltage']}V")
self.query_one("#clk_memory_val",
Static).update(f"{core_vals['mclk']}")
class PowerDisplay(Static): class PowerDisplay(Static):
@ -261,10 +282,14 @@ class PowerDisplay(Static):
"""Called when the micro_watts attributes change. """Called when the micro_watts attributes change.
- Updates label values - Updates label values
- Casting inputs to string to avoid type problems w/ int/None""" - Casting inputs to string to avoid type problems w/ int/None"""
self.query_one("#pwr_avg_val", Static).update(f"{micro_watts['average']}W") self.query_one("#pwr_avg_val",
self.query_one("#pwr_lim_val", Static).update(f"{micro_watts['limit']}W") Static).update(f"{micro_watts['average']}W")
self.query_one("#pwr_def_val", Static).update(f"{micro_watts['default']}W") self.query_one("#pwr_lim_val",
self.query_one("#pwr_cap_val", Static).update(f"{micro_watts['capability']}W") Static).update(f"{micro_watts['limit']}W")
self.query_one("#pwr_def_val",
Static).update(f"{micro_watts['default']}W")
self.query_one("#pwr_cap_val",
Static).update(f"{micro_watts['capability']}W")
def tui() -> None: def tui() -> None:

View file

@ -1,3 +1,14 @@
"""
utils.py
This module contains utility functions/variables used throughout 'amdgpu-stats'
Variables:
- CARD: the identifier for the discovered AMD GPU, ie: `card0` / `card1`
- hwmon_dir: the `hwmon` interface (dir) that provides stats for this card
- SRC_FILES: dictionary of the known stats from the items in `hwmon_dir`
- TEMP_FILES: dictionary of the *discovered* temperature nodes / stat files
"""
from os import path from os import path
import glob import glob
from typing import Tuple, Optional from typing import Tuple, Optional