utils
Utility functions for formatting data and managing UI colors.
find_free_port
find_free_port ()
Find an available port.
format_bytes
format_bytes (bytes_value:int)
Format bytes to human readable string.
| Type | Details | |
|---|---|---|
| bytes_value | int | The number of bytes to format |
| Returns | str | A formatted string representation of the byte value |
format_bandwidth
format_bandwidth (bytes_per_sec:float)
Format bandwidth to human readable string.
| Type | Details | |
|---|---|---|
| bytes_per_sec | float | The number of bytes per second to format |
| Returns | str | A formatted string representation of the bandwidth value |
format_uptime
format_uptime (boot_time_str:str)
Format uptime from boot time string.
| Type | Details | |
|---|---|---|
| boot_time_str | str | Boot time in ‘%Y-%m-%d %H:%M:%S’ format |
| Returns | str | A formatted string representation of the uptime |
get_progress_color
get_progress_color (percent:float)
Get progress bar color based on percentage.
| Type | Details | |
|---|---|---|
| percent | float | The percentage value to determine color for |
| Returns | SingleValueUtility | A progress color from the DaisyUI color scheme |
get_temperature_color
get_temperature_color (temp_celsius:float, high:int=85, critical:int=95)
Get color for temperature display.
| Type | Default | Details | |
|---|---|---|---|
| temp_celsius | float | The temperature value in Celsius | |
| high | int | 85 | The threshold for high temperature |
| critical | int | 95 | The threshold for critical temperature |
| Returns | ColoredUtilityDaisyUI | A text color from the DaisyUI semantic colors |
get_temperature_badge_color
get_temperature_badge_color (temp_celsius:float, high:int=85, critical:int=95)
Get badge color for temperature.
| Type | Default | Details | |
|---|---|---|---|
| temp_celsius | float | The temperature value in Celsius | |
| high | int | 85 | The threshold for high temperature |
| critical | int | 95 | The threshold for critical temperature |
| Returns | SingleValueUtility | A badge color from the DaisyUI color scheme |
open_browser
open_browser (url:str)
Open browser based on environment settings.
| Type | Details | |
|---|---|---|
| url | str | The URL to open in the browser |
| Returns | None | None |