### Full Stress Testing Example Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Complete workflow for starting, running, and stopping the stresser. ```python from s_tui.builtin_stresser import BuiltinStresser, STRATEGY_NUMPY stresser = BuiltinStresser() # Start stressing 8 cores with numpy stresser.start(num_workers=8, strategy=STRATEGY_NUMPY) # ... let it run for 30 seconds ... import time time.sleep(30) # Stop gracefully stresser.stop() # Verify it's stopped assert not stresser.is_running() ``` -------------------------------- ### Install s-tui on OpenSUSE Source: https://github.com/amanusk/s-tui/blob/master/README.md Use zypper to install s-tui on OpenSUSE. ```bash sudo zypper install s-tui ``` -------------------------------- ### Initialize MainLoop Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-ui.md Example of instantiating and running the custom MainLoop. ```python from s_tui.s_tui import MainLoop import urwid widget = urwid.Text("Hello") loop = MainLoop(widget, palette=palette) loop.run() ``` -------------------------------- ### SensorsMenu Initialization Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-ui.md Example of instantiating the SensorsMenu with source definitions and default configurations. ```python menu = SensorsMenu( return_fn=on_menu_close, sources={"Temp": temp_source, "Freq": freq_source}, default_conf={"Temp": [True, True, True], "Freq": [True, True, True, True]} ) ``` -------------------------------- ### Install development dependencies Source: https://github.com/amanusk/s-tui/blob/master/README.md Install the project in editable mode with test dependencies and required static analysis tools. ```bash pip install -e ".[test]" pip install ruff==0.15.4 pyright==1.1.408 ``` -------------------------------- ### Initialize StressController Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Example of initializing the StressController and retrieving available modes. ```python from s_tui.s_tui import StressController controller = StressController(stress_installed=True) modes = controller.get_modes() # ["Monitor", "s-tui stress", "Stress (ext)"] ``` -------------------------------- ### Example Configuration File Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/types-and-constants.md The configuration file uses the INI format and is located at ~/.config/s-tui/s-tui.conf. ```ini [Graphs] temp=True freq=True util=True power=False fan=False [Summaries] temp=True freq=True util=True power=False fan=False [Stress] smooth=False mode=Monitor [General] refresh_rate=2.0 ``` -------------------------------- ### Install s-tui on Fedora Source: https://github.com/amanusk/s-tui/blob/master/README.md Use dnf to install s-tui from the Fedora repository. ```bash sudo dnf install s-tui ``` -------------------------------- ### Install dependencies Source: https://github.com/amanusk/s-tui/blob/master/README.md Install required Python packages using pip. ```bash [sudo] pip install urwid (--user) [sudo] pip install psutil (--user) ``` -------------------------------- ### Initialize TempSource instances Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Examples of initializing TempSource with default settings, integer thresholds, or string-based thresholds. ```python # Default 80°C threshold source = TempSource() # Custom threshold source = TempSource(temp_thresh=85) # Threshold set by string source = TempSource(temp_thresh="90") ``` -------------------------------- ### Install s-tui with pipsi Source: https://github.com/amanusk/s-tui/blob/master/README.md Install s-tui within a virtual environment using pipsi. ```bash pipsi install s-tui ``` -------------------------------- ### Initialize urwid MainLoop with Palette Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/types-and-constants.md Example of importing and applying the DEFAULT_PALETTE to an urwid MainLoop. ```python from s_tui.sturwid.ui_elements import DEFAULT_PALETTE import urwid loop = urwid.MainLoop(widget, palette=DEFAULT_PALETTE) ``` -------------------------------- ### Install s-tui on Arch Linux and Manjaro Source: https://github.com/amanusk/s-tui/blob/master/README.md Install s-tui from the official repository or the AUR. ```bash sudo pacman -S s-tui ``` ```bash yay -S s-tui-git ``` -------------------------------- ### Example Hook Script Implementation Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md A sample shell script for handling temperature threshold alerts, including logging and desktop notifications. ```bash #!/bin/sh # ~/.config/s-tui/hooks.d/temp.sh # Triggers when CPU temperature exceeds threshold # Log the event echo "Temperature alert at $(date)" >> /tmp/s-tui-alerts.log # Send desktop notification (if available) if command -v notify-send >/dev/null 2>&1; then notify-send "CPU Temperature Alert" "Temperature threshold exceeded" fi # Custom action: reduce CPU frequency # (This is an example; actual cpufreq manipulation requires root) # echo "powersave" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor ``` -------------------------------- ### Install s-tui on Ubuntu and Debian Source: https://github.com/amanusk/s-tui/blob/master/README.md Use apt to install s-tui on supported Ubuntu and Debian versions. ```bash sudo apt install s-tui ``` ```bash sudo add-apt-repository ppa:amanusk/python-s-tui sudo apt-get update sudo apt-get install python3-s-tui ``` -------------------------------- ### Install external stress tools Source: https://github.com/amanusk/s-tui/blob/master/README.md Install system-level stress utilities for additional load options. ```bash sudo apt-get install stress ``` -------------------------------- ### Install s-tui stress dependencies Source: https://github.com/amanusk/s-tui/blob/master/README.md Install optional packages to enhance CPU stress testing performance. ```bash pip install s-tui[stress] ``` ```bash pip install numpy ``` -------------------------------- ### StressController.start_stress Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Starts an external stress tool process. ```APIDOC ## start_stress(stress_cmd: list[str]) -> None ### Description Executes an external stress tool command in a new process group. ### Parameters - **stress_cmd** (list[str]) - Required - The command and arguments to execute. ``` -------------------------------- ### Start External Stress Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Starts an external stress tool using a command list. ```python controller.start_stress(["stress", "-c", "4", "-t", "60s"]) ``` -------------------------------- ### Display and Output Options Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md Examples for controlling terminal output format and mouse interaction. ```bash # Show current stats in terminal format s-tui --terminal # Temp: coretemp,0: 55.0, ... # Show current stats as JSON s-tui --json # {"Temp": {"coretemp,0": "55.0", ...}, "Throttle": ""} # Run TUI without mouse s-tui --no-mouse ``` -------------------------------- ### StressController.start_builtin_stress Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Starts the built-in stress testing utility. ```APIDOC ## start_builtin_stress(num_workers: int, strategy: str | None = None) -> None ### Description Starts the built-in stresser using the specified number of workers and strategy. Handles potential multiprocessing errors gracefully. ### Parameters - **num_workers** (int) - Required - Number of worker processes to spawn. - **strategy** (str) - Optional - The stress strategy to use (e.g., 'numpy' or 'hashlib'). ``` -------------------------------- ### Load Script Hooks Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Example of loading specific script hooks and attaching them to a source. ```python loader = ScriptHookLoader(get_user_config_dir()) # Looks for ~/.config/s-tui/hooks.d/temp.sh temp_hook = loader.load_script("Temp", timeoutMilliseconds=30000) # Looks for ~/.config/s-tui/hooks.d/freq.sh freq_hook = loader.load_script("Freq", timeoutMilliseconds=30000) if temp_hook is not None: temp_source.add_edge_hook(temp_hook) ``` -------------------------------- ### Install s-tui via pip Source: https://github.com/amanusk/s-tui/blob/master/README.md Install the latest version of s-tui using pip for user or root access. ```bash pip install s-tui --user ``` ```bash sudo pip install s-tui ``` -------------------------------- ### CSV Format Example Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md The structure of the generated CSV output file. ```csv Time,Temp:coretemp,0,Temp:coretemp,1,Freq:Avg,Freq:Core 0,Util:Avg,Throttle 2025-08-20_12:34:56,55.0,54.0,3500.0,3500.0,45.5, 2025-08-20_12:34:57,55.5,54.5,3400.0,3400.0,48.2,T/W ``` -------------------------------- ### Start CPU Stress Test Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/INDEX.md Manage a stress test session using the BuiltinStresser class. ```python from s_tui.builtin_stresser import BuiltinStresser stresser = BuiltinStresser() stresser.start(num_workers=4, strategy="numpy") # ... let it run ... stresser.stop() ``` -------------------------------- ### Start Built-in Stress Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Starts the built-in stresser with a specified number of workers and strategy. ```python controller.start_builtin_stress(num_workers=4, strategy="numpy") ``` -------------------------------- ### Start Stresser Workers Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Initiate CPU stress with a specified number of workers and strategy. ```python stresser.start(num_workers=4, strategy="numpy") # Use numpy matmul burn stresser.start(num_workers=4) # Auto-select best available strategy ``` -------------------------------- ### Retrieve configuration paths Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-helpers.md Functions to get the paths for the s-tui configuration directory and main configuration file. ```python from s_tui.helper_functions import get_user_config_dir config_dir = get_user_config_dir() # "/home/user/.config/s-tui" ``` ```python from s_tui.helper_functions import get_user_config_file config_file = get_user_config_file() # "/home/user/.config/s-tui/s-tui.conf" ``` -------------------------------- ### Debug log output format Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md Example of the log structure generated when the --debug flag is enabled. ```text DEBUG:root:Initializing TempSource DEBUG:root:sensors_data {'coretemp': [...], ...} DEBUG:root:Temp sensor name coretemp,0 DEBUG:root:Updated custom threshold to 80 INFO:root:Utilization recorded [45.5, 50.0, 40.0, ...] DEBUG:root:Source Temp update failed with recoverable OSError: [Errno 2] No such file ``` -------------------------------- ### Run s-tui without mouse support Source: https://github.com/amanusk/s-tui/blob/master/README.md Use this flag if the application crashes on start in a TTY environment. ```bash s-tui --no-mouse ``` -------------------------------- ### Get base XDG config directory Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-helpers.md Returns the base XDG configuration directory path. ```python from s_tui.helper_functions import get_config_dir base_config = get_config_dir() # "/home/user/.config" ``` -------------------------------- ### Version and Help Information Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md Commands to display version information and help documentation. ```bash s-tui --version # s-tui 1.5.0 - (C) 2017-2025 Alex Manuskin, Gil Tsuker # Released under GNU GPLv2 s-tui --help # Shows all options and usage information ``` -------------------------------- ### Initialize SummaryTextList Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-ui.md Sets up a scrollable text list component for displaying sensor readings. ```python from s_tui.sturwid.summary_text_list import SummaryTextList summary = SummaryTextList( source=freq_source, title="Frequency" ) summary.update() ``` -------------------------------- ### Initialize and use RaplReader Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Instantiate the reader and check availability before reading power stats. ```python from s_tui.sources.rapl_read import RaplReader reader = RaplReader() if reader.available(): stats = reader.read_power() ``` -------------------------------- ### Initialize RaplPowerSource Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Instantiates the RaplPowerSource and checks for platform availability. ```python source = RaplPowerSource() if source.get_is_available(): # System supports RAPL power reading pass ``` -------------------------------- ### Initialize MockSource for testing Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/architecture-and-modules.md Demonstrates instantiation and basic method calls for the MockSource class used in integration testing. ```python from s_tui.sources.source import MockSource source = MockSource() source.get_maximum() # Returns 20 source.get_summary() # Returns {"MockValue": "5", "Tahat": "34"} ``` -------------------------------- ### Initialize GraphView Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-ui.md Instantiating the GraphView with a controller. ```python view = GraphView(controller) loop = MainLoop(view) ``` -------------------------------- ### Initialize BuiltinStresser Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Instantiate the stresser object before starting workers. ```python from s_tui.builtin_stresser import BuiltinStresser stresser = BuiltinStresser() ``` -------------------------------- ### Initialize FreqSource Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Instantiates the FreqSource and checks for system availability before proceeding with monitoring. ```python source = FreqSource() if source.get_is_available(): # System supports frequency monitoring pass ``` -------------------------------- ### Configure pre-commit hooks Source: https://github.com/amanusk/s-tui/blob/master/README.md Set up pre-commit hooks to automatically run ruff and pyright before each push. ```bash pip install pre-commit pre-commit install --hook-type pre-push ``` -------------------------------- ### Use MockSource Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Demonstrates retrieving a summary from the MockSource. ```python source = MockSource() summary = source.get_summary() # {"MockValue": "5", "Tahat": "34"} ``` -------------------------------- ### Creating Hook Script Directory and Files Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md Commands to initialize the hook script directory and create an executable script file. ```bash mkdir -p ~/.config/s-tui/hooks.d ``` ```bash touch ~/.config/s-tui/hooks.d/temp.sh chmod +x ~/.config/s-tui/hooks.d/temp.sh ``` -------------------------------- ### Access BuiltinStresser Property Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Accesses the builtin_stresser property to start the stress process. ```python stresser = controller.builtin_stresser stresser.start(4) ``` -------------------------------- ### Get Current Stress Mode Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Retrieves the currently active stress mode. ```python mode = controller.get_current_mode() # "Monitor" or "s-tui stress" or "Stress (ext)" ``` -------------------------------- ### Monitor Temperature with TempSource Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/INDEX.md Initialize a temperature source with a threshold and retrieve current readings. ```python from s_tui.sources.temp_source import TempSource source = TempSource(temp_thresh=80) source.update() temps = source.get_reading_list() # [55.0, 54.0, 53.0] ``` -------------------------------- ### Initialize and use AMDRaplMsrReader Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Instantiate the MSR-based AMD reader and read power. ```python from s_tui.sources.rapl_read import AMDRaplMsrReader reader = AMDRaplMsrReader() stats = reader.read_power() ``` -------------------------------- ### ScriptHookLoader.__init__ Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Initializes the loader with the base configuration directory. ```APIDOC ## ScriptHookLoader(dir_path: str) ### Description Initializes a new instance of the ScriptHookLoader. Hooks are expected to be located in the `{dir_path}/hooks.d/` directory. ### Parameters - **dir_path** (str) - Required - Base configuration directory. ``` -------------------------------- ### Create configuration directory Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-helpers.md Creates the s-tui configuration directory and the hooks.d subdirectory if they do not exist. ```python from s_tui.helper_functions import make_user_config_dir config_path = make_user_config_dir() if config_path: # Directory created or already exists pass ``` -------------------------------- ### Get UtilSource Maximum Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Retrieves the maximum percentage scale value, which is always 100. ```python max_val = source.get_top() # 100 ``` -------------------------------- ### Initialize ViListBox Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-ui.md Instantiates a ViListBox with a SimpleFocusListWalker. ```python from s_tui.sturwid.ui_elements import ViListBox list_box = ViListBox(urwid.SimpleFocusListWalker([])) # j/k to scroll, x to select ``` -------------------------------- ### Initialize and Invoke Hook Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Create a Hook instance with a callback and check readiness before invocation. ```python def on_threshold_exceeded(args): print(f"Threshold exceeded: {args}") hook = Hook(on_threshold_exceeded, timeout_milliseconds=30000) ``` ```python if hook.is_ready(): hook.invoke() ``` ```python hook.invoke() # Callback is invoked; if timeout was set, next invoke won't fire until timeout expires ``` -------------------------------- ### Get Throttle Status Label Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Retrieve a string representation of active throttle reasons. ```python status = read_therm_status(0) print(status.label) # "T/W" = thermal + power limit # "C" = critical # "" = no throttle ``` -------------------------------- ### Initialize and use AMDEnergyReader Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Instantiate the AMD energy reader and perform a power read. ```python from s_tui.sources.rapl_read import AMDEnergyReader reader = AMDEnergyReader() if reader.available(): stats = reader.read_power() ``` -------------------------------- ### Read CPU MSR Value Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Example of reading the IA32_THERM_STATUS register from a specific CPU core. ```python from s_tui.sources.msr import read_msr # Read IA32_THERM_STATUS (0x19C) from CPU 0 value = read_msr(0, 0x19C) ``` -------------------------------- ### Initialize ScriptHookLoader Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Instantiate the loader using the user configuration directory. ```python from s_tui.helper_functions import get_user_config_dir from s_tui.sources.script_hook_loader import ScriptHookLoader loader = ScriptHookLoader(get_user_config_dir()) ``` -------------------------------- ### Initialize UtilSource Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Instantiates the UtilSource class, which requires psutil.cpu_percent availability. ```python source = UtilSource() ``` -------------------------------- ### Initialize and Invoke ScriptHook Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Create a ScriptHook instance and execute the associated shell script. ```python hook = ScriptHook("/home/user/.config/s-tui/hooks.d/temp.sh", timeout_milliseconds=30000) ``` ```python hook.invoke() # Script is executed as: /bin/sh /path/to/script.sh ``` -------------------------------- ### Initialize FanSource Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Instantiates the FanSource and checks for sensor availability. ```python source = FanSource() if source.get_is_available(): # System has fan sensors pass ``` -------------------------------- ### Configure Summary Pane Display Settings Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md Defines which sensor summary text panes are enabled on application startup. ```ini [Summaries] temp=True freq=True util=True power=False fan=False ``` -------------------------------- ### Run s-tui Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md The primary entry point for the application. ```bash s-tui [options] ``` -------------------------------- ### Display s-tui help information Source: https://github.com/amanusk/s-tui/blob/master/README.md Run this command to view the help message and list all available command line options. ```bash s-tui --help ``` -------------------------------- ### StressController.__init__ Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Initializes the stress controller with information about the availability of external stress tools. ```APIDOC ## StressController(stress_installed: bool) ### Description Initializes the stress controller. The controller manages available stress modes based on whether the external 'stress' tool is installed. ### Parameters - **stress_installed** (bool) - Required - True if the external 'stress' tool is available on the system. ``` -------------------------------- ### Override configuration with CLI arguments Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md Demonstrates how command-line arguments take precedence over values defined in the configuration file. ```bash # config file has t_thresh=80, but CLI overrides it to 75 s-tui --t_thresh 75 ``` -------------------------------- ### Temperature Threshold Configuration Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md Setting the temperature alert threshold in Celsius. ```bash # Use 75°C threshold s-tui --t_thresh 75 # Use 90°C threshold s-tui --t_thresh 90 ``` -------------------------------- ### Clone the s-tui repository Source: https://github.com/amanusk/s-tui/blob/master/README.md Initial steps to download the source code from GitHub. ```bash git clone https://github.com/amanusk/s-tui.git cd s-tui ``` -------------------------------- ### Integrate with RaplPowerSource Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Uses RaplPowerSource to compute power consumption in watts based on energy deltas. ```python from s_tui.sources.rapl_power_source import RaplPowerSource source = RaplPowerSource() if source.get_is_available(): source.update() # Computes watts from energy delta since last update readings = source.get_reading_list() # [65.5, 32.2, 33.3] # Watts per domain ``` -------------------------------- ### Initialize BarGraphVector Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-ui.md Sets up a multi-sensor bar graph component for visualizing data sources. ```python from s_tui.sturwid.bar_graph_vector import BarGraphVector graph = BarGraphVector( source=temp_source, title="Temperature", max_value=100 ) graph.update() ``` -------------------------------- ### Run Interactive TUI Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/INDEX.md Launch the main s-tui interface. ```python from s_tui.s_tui import main main() ``` -------------------------------- ### Configure General Application Settings Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md Sets application-wide parameters such as the sensor refresh interval. ```ini [General] refresh_rate=2.0 ``` -------------------------------- ### Main argument processing logic Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md The entry point for argument parsing and TUI initialization. ```python # s_tui/s_tui.py def main(): parser = argparse.ArgumentParser(...) # ... add all options ... args = parser.parse_args() # Handle non-TUI outputs if args.terminal: output_to_terminal(sources) return if args.json: output_to_json(sources) return # Run TUI loop = MainLoop(...) loop.run() ``` -------------------------------- ### Common CLI usage patterns Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md Various command-line patterns for monitoring, logging, and testing. ```bash s-tui --terminal ``` ```bash * * * * * s-tui --terminal --csv --csv-file /var/log/cpu-stats.csv ``` ```bash s-tui --debug --debug-file /tmp/stress-debug.log # Start in Monitor mode, switch to "s-tui stress" in TUI ``` ```bash s-tui --t_thresh 70 ``` ```bash s-tui --debug_run ``` -------------------------------- ### Read Configuration Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/INDEX.md Access user-defined configuration settings using the standard configparser library. ```python from s_tui.helper_functions import get_user_config_file, user_config_file_exists import configparser if user_config_file_exists(): config = configparser.ConfigParser() config.read(get_user_config_file()) smooth = config["Stress"].getboolean("smooth", fallback=False) ``` -------------------------------- ### Visualize Module Dependency Graph Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/architecture-and-modules.md A text-based representation of the s-tui module hierarchy and inter-dependencies. ```text s_tui.py (main entry point) ├── helper_functions.py (config, I/O, formatting) ├── sources/ │ ├── source.py (base class) │ ├── temp_source.py (depends: source.py, helper_functions.py) │ ├── freq_source.py (depends: source.py, msr.py, intel_therm.py, amd_pstate_limit.py) │ ├── util_source.py (depends: source.py) │ ├── rapl_power_source.py (depends: source.py, rapl_read.py) │ ├── fan_source.py (depends: source.py) │ ├── hook.py (no dependencies) │ ├── hook_script.py (depends: hook.py) │ ├── script_hook_loader.py (depends: hook_script.py) │ ├── msr.py (no dependencies) │ ├── intel_therm.py (depends: msr.py) │ ├── amd_pstate_limit.py (depends: msr.py, helper_functions.py) │ └── rapl_read.py (depends: helper_functions.py, msr.py) ├── sturwid/ │ ├── ui_elements.py (depends: urwid, source.py) │ ├── bar_graph_vector.py (depends: urwid, source.py) │ ├── summary_text_list.py (depends: urwid, source.py) │ └── complex_bar_graph.py (depends: urwid) ├── builtin_stresser.py (multiprocessing, importlib) ├── stress_menu.py (depends: ui_elements.py) ├── builtin_stress_menu.py (depends: ui_elements.py, builtin_stresser.py) ├── sensors_menu.py (depends: ui_elements.py, source.py) ├── power_profile_menu.py (depends: ui_elements.py, helper_functions.py) ├── about_menu.py (depends: ui_elements.py) └── help_menu.py (depends: ui_elements.py) ``` -------------------------------- ### Run manual quality checks Source: https://github.com/amanusk/s-tui/blob/master/README.md Execute linting, formatting, type checking, and test suites manually. ```bash ruff check . # lint ruff format --check . # format check pyright s_tui/ # type check pytest # tests ``` -------------------------------- ### Retrieve full source summary Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Returns a dictionary containing the source name and all sensor summaries. ```python summary = source.get_summary() # {"Temp [C]": "", "coretemp,0": "55.0", ...} ``` -------------------------------- ### available() -> bool Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Checks if the AMD MSR P-state cap detection functionality is supported and usable on the current system. ```APIDOC ## available() -> bool ### Description Checks if AMD MSR P-state cap detection is usable. Requires root privileges, the msr kernel module, and an AMD Zen family CPU (family >= 0x17). ### Returns - **bool** - True if detection is supported and readable, False otherwise. ``` -------------------------------- ### Create a button Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-ui.md Creates a styled button with a callback function. ```python from s_tui.sturwid.ui_elements import button btn = button("Click Me", on_click) ``` -------------------------------- ### Logging and Debugging Options Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md Commands for enabling debug logs and performing short test runs. ```bash # Enable debug logging s-tui --debug # Use custom log file s-tui --debug --debug-file /tmp/s-tui-debug.log # Quick test run s-tui --debug_run ``` -------------------------------- ### Configure Stress Test Settings Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md Sets the initial stress mode and rendering options for stress testing. ```ini [Stress] smooth=False mode=Monitor ``` -------------------------------- ### Attach Hook to Source Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Integrate a Hook with a TempSource to trigger alerts based on temperature thresholds. ```python from s_tui.sources.temp_source import TempSource from s_tui.sources.hook import Hook def alert_high_temp(args): print("CPU overheating!") temp_source = TempSource() hook = Hook(alert_high_temp, timeout_milliseconds=30000) temp_source.add_edge_hook(hook) # Each time source.update() is called and threshold is exceeded, # hook.invoke() is called (at most once per 30 seconds) ``` -------------------------------- ### Check AMDEnergyReader availability Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Verify the existence of the AMD energy platform device. ```python if AMDEnergyReader.available(): reader = AMDEnergyReader() ``` -------------------------------- ### Application Constants Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/types-and-constants.md Global configuration constants for update intervals, default file paths, and application metadata. ```python UPDATE_INTERVAL = 1 # Seconds between graph/sensor updates HOOK_INTERVAL = 30 * 1000 # Milliseconds between hook invocations (30s) DEGREE_SIGN = "\N{DEGREE SIGN}" # ° ZERO_TIME = "00:00:00" DEFAULT_LOG_FILE = "_s-tui.log" DEFAULT_CSV_FILE = "s-tui_log_" + time.strftime("%Y-%m-%d_%H_%M_%S") + ".csv" VERSION_MESSAGE = "s-tui 1.5.0 - (C) 2017-2025 Alex Manuskin, Gil Tsuker\nReleased under GNU GPLv2" ERROR_MESSAGE = """ Oops! s-tui has encountered a fatal error Please report this bug here: https://github.com/amanusk/s-tui """ ``` -------------------------------- ### Manage UI Overlays with urwid Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-ui.md Use urwid.Overlay to display menus over the main widget and restore the original widget to close them. ```python # Open menu as overlay overlay = urwid.Overlay( menu.main_window, original_widget, ("fixed left", 1), menu_width, "top", menu_height, ) loop.widget = overlay # Close menu (return to main display) loop.widget = original_widget ``` -------------------------------- ### CSV Output Configuration Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md Commands for logging sensor data to CSV files. ```bash # Log to default CSV file s-tui --csv # Log to specific file s-tui --csv --csv-file /tmp/cpu-stats.csv ``` -------------------------------- ### Define Version and Constants Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-helpers.md Defines package version and platform-specific constants for file system operations. ```python __version__ = "1.5.0" POSIX = os.name == "posix" ENCODING = sys.getfilesystemencoding() ENCODING_ERRS = ... # "surrogateescape" or "replace" ``` -------------------------------- ### Check RaplReader availability Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Verify the existence of the RAPL sysfs directory. ```python if RaplReader.available(): reader = RaplReader() ``` -------------------------------- ### UtilSource Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Monitors per-core CPU utilization percentage. ```APIDOC ## UtilSource ### Description Monitors per-core CPU utilization percentage. ### Methods - **update()** (None) - Samples per-core CPU utilization and computes the average. - **get_top()** (int) - Returns the maximum scale value (100). - **get_is_available()** (bool) - Checks if the source is available. ``` -------------------------------- ### get_summary() Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Returns a dict including the source name and all sensor summaries. ```APIDOC ## get_summary() ### Description Returns a dict including the source name and all sensor summaries. ### Signature `get_summary() -> OrderedDict[str, str]` ``` -------------------------------- ### Configure Graph Display Settings Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md Defines which sensor graphs are enabled on application startup. ```ini [Graphs] temp=True freq=True util=True power=False fan=False ``` -------------------------------- ### Monitor CPU Temperature Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/README.md Initializes a TempSource object to retrieve current CPU temperature readings. ```python from s_tui.sources.temp_source import TempSource source = TempSource() source.update() readings = source.get_reading_list() # [55.0, 54.0, 53.0] ``` -------------------------------- ### Check configuration existence Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-helpers.md Utility functions to verify if the s-tui configuration directory or file exists. ```python from s_tui.helper_functions import user_config_dir_exists if user_config_dir_exists(): # Load settings from config directory pass ``` ```python from s_tui.helper_functions import user_config_file_exists if user_config_file_exists(): # Load configuration pass ``` -------------------------------- ### available() -> bool (Intel Throttle) Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Checks if Intel MSR throttle detection is usable on the current system. ```APIDOC ## available() -> bool ### Description Checks if Intel MSR throttle detection is usable. Requires root, msr kernel module, and readable MSR device files. ``` -------------------------------- ### Update and Read RaplPowerSource Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Updates the power source and retrieves the list of power readings in watts. ```python source.update() readings = source.get_reading_list() # [65.5, 32.2, 33.3] # Watts per domain (e.g., package, core, uncore) ``` -------------------------------- ### Filesystem Path for Thermal Throttle Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/types-and-constants.md Path template for accessing CPU thermal throttle information via sysfs. ```python SYSFS_THERMAL_THROTTLE = "/sys/devices/system/cpu/cpu{}/thermal_throttle" ``` -------------------------------- ### RAPL Constants Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/types-and-constants.md Constants and directory paths for Intel and AMD RAPL energy monitoring. ```python INTER_RAPL_DIR = "/sys/class/powercap/intel-rapl/" AMD_ENERGY_DIR_GLOB = "/sys/devices/platform/amd_energy.0/hwmon/hwmon*/" MICRO_JOULE_IN_JOULE = 1000000.0 # AMD MSR constants UNIT_MSR = 0xC0010299 CORE_MSR = 0xC001029A PACKAGE_MSR = 0xC001029B ENERGY_UNIT_MASK = 0x1F00 ``` -------------------------------- ### Power Profile Sysfs Paths Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/types-and-constants.md System file paths for accessing CPU frequency governors and energy performance preferences. ```python SYSFS_AVAIL_GOVERNORS = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors" SYSFS_AVAIL_EPP = "/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference" SYSFS_GOVERNOR = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" SYSFS_EPP = "/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference" ``` -------------------------------- ### Run s-tui Source: https://github.com/amanusk/s-tui/blob/master/README.md Execute the application using the Python module flag. ```bash python -m s_tui.s_tui ``` -------------------------------- ### Define Encoding Constants Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/types-and-constants.md Sets up environment-specific encoding and error handling constants for filesystem operations. ```python POSIX = os.name == "posix" ENCODING = sys.getfilesystemencoding() ENCODING_ERRS = sys.getfilesystemencodeerrors() or "surrogateescape" if POSIX else "replace" ``` -------------------------------- ### Update and Read UtilSource Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Updates the source and retrieves the list of CPU utilization readings. ```python source.update() readings = source.get_reading_list() # [45.5, 50.0, 42.0, 48.0, ...] # Average, then per-core ``` -------------------------------- ### Create and Enable Shell Script Hook Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Define a shell script and attach it to a TempSource using ScriptHook. ```bash #!/bin/sh # This script runs when temperature exceeds threshold notify-send "CPU temperature alert" ``` ```python from s_tui.sources.temp_source import TempSource from s_tui.sources.hook_script import ScriptHook temp_source = TempSource(temp_thresh=75) script_hook = ScriptHook("~/.config/s-tui/hooks.d/temp.sh", timeout_milliseconds=30000) temp_source.add_edge_hook(script_hook) # Each time temp exceeds 75°C (at most once per 30s), the script runs ``` -------------------------------- ### Define ViListBox class Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-ui.md Defines the structure for a custom urwid ListBox with vim-style keybindings. ```python class ViListBox(urwid.ListBox): def keypress(self, size, key): ... ``` -------------------------------- ### Retrieve sensor list Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Returns a list of all available sensors for the source. ```python sensors = source.get_sensor_list() # TempSource: ["coretemp,0", "coretemp,1", "packagetemp,0"] # UtilSource: ["Avg", "Core 0", "Core 1", ...] ``` -------------------------------- ### Persist configuration to file Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/architecture-and-modules.md Uses ConfigParser to save application settings to the user's configuration directory. ```python config = configparser.ConfigParser() config["Graphs"] = {"temp": True, "freq": True, ...} config["Summaries"] = {...} config["Stress"] = {"smooth": False, "mode": "Monitor"} config["General"] = {"refresh_rate": "2.0"} with open(config_file, "w") as f: config.write(f) ``` -------------------------------- ### Check Intel Throttle Detection Availability Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Verify that Intel throttle detection is supported and accessible. ```python from s_tui.sources.intel_therm import available if available(): # Can read Intel throttle status pass ``` -------------------------------- ### Retrieve Sensor Suffixes Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Fetches throttle reason labels for each core based on the underlying hardware architecture. ```python suffixes = source.get_sensor_suffixes() # ["", "T/W", "T", "W"] # Avg, Core0, Core1, Core2 throttle reasons ``` -------------------------------- ### MSR Utility Definitions Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Core function signatures for interacting with CPU MSRs. ```python def read_msr(cpu: int, register: int) -> int: ... def msr_available() -> bool: ... ``` -------------------------------- ### output_to_terminal(sources: list) → None Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-helpers.md Prints all sensor readings to stdout in key=value format and then exits. ```APIDOC ## output_to_terminal(sources: list) → None ### Description Prints all sensor readings to stdout in key=value format, then exits. ### Parameters - **sources** (list) - Required - List of Source objects. ### Example ```python from s_tui.helper_functions import output_to_terminal output_to_terminal([temp_source, freq_source]) ``` ``` -------------------------------- ### RaplPowerSource Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Monitors CPU power draw via RAPL on supported Intel and AMD systems. ```APIDOC ## RaplPowerSource ### Description Monitors CPU power draw via RAPL (Running Average Power Limit) on Intel and AMD systems. ### Methods - **update()** (None) - Reads energy counters and computes power in watts. - **get_maximum()** (float) - Returns the peak power reading since startup. - **get_top()** (float) - Returns the current top scale value. - **reset()** (None) - Resets the power reader state. - **get_edge_triggered()** (bool) - Returns the edge trigger status. ``` -------------------------------- ### get_is_available() Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Returns whether this source's data is available on the system. ```APIDOC ## get_is_available() ### Description Returns whether this source's data is available on the system. ### Signature `get_is_available() -> bool` ``` -------------------------------- ### Check source availability Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Verifies if the source data is accessible on the system before attempting to retrieve readings. ```python if source.get_is_available(): readings = source.get_reading_list() ``` -------------------------------- ### which(program: str) → str | None Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-helpers.md Locates the full path of an executable in the system PATH or relative to the current working directory. ```APIDOC ## which(program: str) → str | None ### Description Locates the full path of an executable in PATH or relative to cwd. ### Parameters - **program** (str) - Required - Program name or relative path ### Returns - str | None - Full absolute path if found, None otherwise ``` -------------------------------- ### AMDRaplMsrReader Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Reads AMD Zen RAPL via MSR. ```APIDOC ## AMDRaplMsrReader ### Description Reads AMD Zen RAPL via MSR (Model Specific Registers). ### Methods - **__init__()** - Maps CPU cores to package/core topology IDs via sysfs. - **read_power() -> list[RaplStats]** - Reads energy MSRs (0xC001029A for core, 0xC001029B for package) and computes power draw. ``` -------------------------------- ### Source Interface Hierarchy Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/architecture-and-modules.md Abstract base class for sensor data collection and its specific implementations. ```text Source (abstract base) ├── TempSource → psutil.sensors_temperatures() ├── FreqSource → psutil.cpu_freq() + MSR throttle detection ├── UtilSource → psutil.cpu_percent() ├── RaplPowerSource → Intel RAPL or AMD energy MSR/sysfs └── FanSource → psutil.sensors_fans() ``` -------------------------------- ### Retrieve source name Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Returns the human-readable name of the source. ```python name = source.get_source_name() # Returns "Temp" for TempSource ``` -------------------------------- ### Auto-fix linting and formatting Source: https://github.com/amanusk/s-tui/blob/master/README.md Automatically apply fixes for linting and formatting issues. ```bash ruff check --fix . ruff format . ``` -------------------------------- ### Set XDG configuration directory Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md Overrides the default configuration directory location. ```bash XDG_CONFIG_HOME=/home/user/.config s-tui # Looks for config in ~/.config/s-tui instead of default ``` -------------------------------- ### Check Strategy Availability Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-hooks-stress.md Determine the default strategy or check if a specific strategy is available. ```python from s_tui.builtin_stresser import get_default_strategy, strategy_available best = get_default_strategy() # "numpy" or "hashlib" has_numpy = strategy_available("numpy") ``` -------------------------------- ### Configuration Management Functions Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-helpers.md Functions for retrieving and managing s-tui configuration paths and directory states. ```APIDOC ## Configuration Management Functions ### get_user_config_dir() → str Returns the s-tui config directory path (~/.config/s-tui). ### get_user_config_file() → str Returns the s-tui main config file path (~/.config/s-tui/s-tui.conf). ### user_config_dir_exists() → bool Checks if the s-tui config directory exists. ### user_config_file_exists() → bool Checks if the s-tui config file exists. ### make_user_config_dir() → str | None Creates the s-tui config directory and hooks.d subdirectory if they don't exist. Returns path or None if creation fails. ### get_config_dir() → str Returns the base XDG config directory (~/.config). ``` -------------------------------- ### Enable unbuffered output Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/configuration-cli.md Forces unbuffered output, which is useful when logging. ```bash PYTHONUNBUFFERED=1 s-tui --debug ``` -------------------------------- ### Define MainLoop Class Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-ui.md Custom urwid MainLoop implementation with signal handling. ```python class MainLoop(urwid.MainLoop): def __init__(self, *args, **kwargs) -> None: ... def _signal_handler(self, signum: int, frame: object) -> None: ... def unhandled_input(self, data): ... ``` -------------------------------- ### Check availability of AMD MSR detection Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Verifies if the environment supports AMD P-state cap detection. ```python from s_tui.sources.amd_pstate_limit import available if available(): # Can read AMD P-state cap status pass ``` -------------------------------- ### Retrieve sensor summary Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Returns a dictionary mapping sensor names to their formatted measurement strings. ```python summary = source.get_sensors_summary() # {"coretemp,0": "55.0", "coretemp,1": "54.0", "packagetemp,0": "53.0"} ``` -------------------------------- ### RaplPowerSource Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md A class used to compute power consumption in watts from energy deltas. ```APIDOC ## RaplPowerSource ### Description RaplPowerSource uses a power reader to compute watts from energy deltas. It performs an update cycle that reads energy counters, computes joules, and calculates watts based on the time elapsed since the last read. ### Methods - `get_is_available() -> bool`: Checks if the power source is available. - `update()`: Computes watts from energy delta since the last update. - `get_reading_list() -> list`: Returns the list of current power readings in watts. ### Example ```python from s_tui.sources.rapl_power_source import RaplPowerSource source = RaplPowerSource() if source.get_is_available(): source.update() readings = source.get_reading_list() ``` ``` -------------------------------- ### Export sensor data to CSV Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-helpers.md Appends sensor readings and a timestamp to a CSV file. Creates the file if it does not exist. ```python from s_tui.helper_functions import output_to_csv sources = {"Temp": temp_wrapper, "Freq": freq_wrapper} output_to_csv(sources, "/tmp/s-tui.csv") ``` -------------------------------- ### Validate Source Availability on Initialization Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/architecture-and-modules.md Checks for sensor availability during class instantiation and marks the source as unavailable if sensors are missing or inaccessible. ```python class TempSource(Source): def __init__(self, temp_thresh=None): try: sensors_data = psutil.sensors_temperatures() if not sensors_data: self.is_available = False return except (AttributeError, OSError, TypeError): self.is_available = False return # ... continue initialization only if available ``` -------------------------------- ### RaplReader Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Reads Intel RAPL energy counters from sysfs. ```APIDOC ## RaplReader ### Description Reads Intel RAPL (Running Average Power Limit) energy counters from sysfs. ### Methods - **__init__()** - Initializes the reader by scanning /sys/class/powercap/intel-rapl:*/ for available domains. - **read_power() -> list[RaplStats]** - Reads energy counters from all available RAPL domains. Returns a list of RaplStats namedtuples. - **available() -> bool** - Static method that checks if /sys/class/powercap/intel-rapl exists. ``` -------------------------------- ### get_power_reader() Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Selects the best available power reader for the system based on hardware support. ```APIDOC ## get_power_reader() ### Description Selects the best available power reader for the system. Priority is given to Intel RAPL, followed by AMD hwmon energy, then AMD MSR RAPL. ### Signature `get_power_reader() -> RaplReader | AMDEnergyReader | AMDRaplMsrReader | None` ### Example ```python from s_tui.sources.rapl_read import get_power_reader reader = get_power_reader() if reader: stats = reader.read_power() for stat in stats: print(f"{stat.label}: {stat.current / 1_000_000}W") ``` ``` -------------------------------- ### Locate executable path with which Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-helpers.md Finds the absolute path of an executable within the system PATH or relative to the current working directory. ```python from s_tui.helper_functions import which stress_path = which("stress") # "/usr/bin/stress" unknown = which("nonexistent") # None ``` -------------------------------- ### Update source measurements Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Refreshes temperature readings and triggers attached hooks. ```python source = TempSource() source.update() # Refresh temperature readings ``` -------------------------------- ### Read AMD energy statistics Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-msr-power.md Retrieve energy counters from available AMD domains. ```python stats = reader.read_power() # [RaplStats("Esocket0", 12345.0, 0.0), RaplStats("Ecore0", 6789.0, 0.0), ...] ``` -------------------------------- ### reset() Source: https://github.com/amanusk/s-tui/blob/master/_autodocs/api-reference-source.md Resets source state. ```APIDOC ## reset() ### Description Resets source state, typically clearing maximum values. ### Signature `reset() -> None` ```