# utils


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

------------------------------------------------------------------------

<a
href="https://github.com/cj-mills/cjm-fasthtml-sysmon/blob/main/cjm_fasthtml_sysmon/core/utils.py#L25"
target="_blank" style="float:right; font-size:smaller">source</a>

### find_free_port

>  find_free_port ()

*Find an available port.*

------------------------------------------------------------------------

<a
href="https://github.com/cj-mills/cjm-fasthtml-sysmon/blob/main/cjm_fasthtml_sysmon/core/utils.py#L33"
target="_blank" style="float:right; font-size:smaller">source</a>

### format_bytes

>  format_bytes (bytes_value:int)

*Format bytes to human readable string.*

<table>
<colgroup>
<col style="width: 9%" />
<col style="width: 38%" />
<col style="width: 52%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>bytes_value</td>
<td>int</td>
<td>The number of bytes to format</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>str</strong></td>
<td><strong>A formatted string representation of the byte
value</strong></td>
</tr>
</tbody>
</table>

------------------------------------------------------------------------

<a
href="https://github.com/cj-mills/cjm-fasthtml-sysmon/blob/main/cjm_fasthtml_sysmon/core/utils.py#L44"
target="_blank" style="float:right; font-size:smaller">source</a>

### format_bandwidth

>  format_bandwidth (bytes_per_sec:float)

*Format bandwidth to human readable string.*

<table>
<colgroup>
<col style="width: 9%" />
<col style="width: 38%" />
<col style="width: 52%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>bytes_per_sec</td>
<td>float</td>
<td>The number of bytes per second to format</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>str</strong></td>
<td><strong>A formatted string representation of the bandwidth
value</strong></td>
</tr>
</tbody>
</table>

------------------------------------------------------------------------

<a
href="https://github.com/cj-mills/cjm-fasthtml-sysmon/blob/main/cjm_fasthtml_sysmon/core/utils.py#L58"
target="_blank" style="float:right; font-size:smaller">source</a>

### format_uptime

>  format_uptime (boot_time_str:str)

*Format uptime from boot time string.*

<table>
<colgroup>
<col style="width: 9%" />
<col style="width: 38%" />
<col style="width: 52%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>boot_time_str</td>
<td>str</td>
<td>Boot time in ‘%Y-%m-%d %H:%M:%S’ format</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>str</strong></td>
<td><strong>A formatted string representation of the
uptime</strong></td>
</tr>
</tbody>
</table>

------------------------------------------------------------------------

<a
href="https://github.com/cj-mills/cjm-fasthtml-sysmon/blob/main/cjm_fasthtml_sysmon/core/utils.py#L76"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_progress_color

>  get_progress_color (percent:float)

*Get progress bar color based on percentage.*

<table>
<colgroup>
<col style="width: 9%" />
<col style="width: 38%" />
<col style="width: 52%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>percent</td>
<td>float</td>
<td>The percentage value to determine color for</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>SingleValueUtility</strong></td>
<td><strong>A progress color from the DaisyUI color scheme</strong></td>
</tr>
</tbody>
</table>

------------------------------------------------------------------------

<a
href="https://github.com/cj-mills/cjm-fasthtml-sysmon/blob/main/cjm_fasthtml_sysmon/core/utils.py#L88"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_temperature_color

>  get_temperature_color (temp_celsius:float, high:int=85, critical:int=95)

*Get color for temperature display.*

<table>
<colgroup>
<col style="width: 6%" />
<col style="width: 25%" />
<col style="width: 34%" />
<col style="width: 34%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Default</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>temp_celsius</td>
<td>float</td>
<td></td>
<td>The temperature value in Celsius</td>
</tr>
<tr>
<td>high</td>
<td>int</td>
<td>85</td>
<td>The threshold for high temperature</td>
</tr>
<tr>
<td>critical</td>
<td>int</td>
<td>95</td>
<td>The threshold for critical temperature</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>ColoredUtilityDaisyUI</strong></td>
<td></td>
<td><strong>A text color from the DaisyUI semantic colors</strong></td>
</tr>
</tbody>
</table>

------------------------------------------------------------------------

<a
href="https://github.com/cj-mills/cjm-fasthtml-sysmon/blob/main/cjm_fasthtml_sysmon/core/utils.py#L104"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_temperature_badge_color

>  get_temperature_badge_color (temp_celsius:float, high:int=85,
>                                   critical:int=95)

*Get badge color for temperature.*

<table>
<colgroup>
<col style="width: 6%" />
<col style="width: 25%" />
<col style="width: 34%" />
<col style="width: 34%" />
</colgroup>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Default</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>temp_celsius</td>
<td>float</td>
<td></td>
<td>The temperature value in Celsius</td>
</tr>
<tr>
<td>high</td>
<td>int</td>
<td>85</td>
<td>The threshold for high temperature</td>
</tr>
<tr>
<td>critical</td>
<td>int</td>
<td>95</td>
<td>The threshold for critical temperature</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>SingleValueUtility</strong></td>
<td></td>
<td><strong>A badge color from the DaisyUI color scheme</strong></td>
</tr>
</tbody>
</table>

------------------------------------------------------------------------

<a
href="https://github.com/cj-mills/cjm-fasthtml-sysmon/blob/main/cjm_fasthtml_sysmon/core/utils.py#L120"
target="_blank" style="float:right; font-size:smaller">source</a>

### open_browser

>  open_browser (url:str)

*Open browser based on environment settings.*

<table>
<thead>
<tr>
<th></th>
<th><strong>Type</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>url</td>
<td>str</td>
<td>The URL to open in the browser</td>
</tr>
<tr>
<td><strong>Returns</strong></td>
<td><strong>None</strong></td>
<td><strong>None</strong></td>
</tr>
</tbody>
</table>
