Utilities API Reference¶
Utility functions for pysiphon.
Hex Conversion¶
hex_to_bytes(hex_string)
¶
Convert hex string to bytes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hex_string
|
str
|
Hex string like "6D DE AD BE EF" or "6DDEADBEEF" |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
bytes object |
Source code in pysiphon/utils.py
bytes_to_hex(data)
¶
Convert bytes to hex string format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes
|
bytes object |
required |
Returns:
| Type | Description |
|---|---|
str
|
Hex string like "6D DE AD BE EF" |
Configuration¶
parse_config_file(filepath)
¶
Parse TOML config file and extract process configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str
|
Path to TOML config file |
required |
Returns:
| Type | Description |
|---|---|
str
|
Tuple of (process_name, process_window_name, attributes_dict) |
str
|
where attributes_dict maps attribute names to their config |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If config file doesn't exist |
ValueError
|
If config file is invalid |
Source code in pysiphon/utils.py
Image Handling¶
save_frame_image(pixels, width, height, filename)
¶
Save frame pixels to image file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pixels
|
bytes
|
Raw BGRA pixel data |
required |
width
|
int
|
Image width |
required |
height
|
int
|
Image height |
required |
filename
|
str
|
Output filename (format auto-detected from extension) |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Source code in pysiphon/utils.py
Formatting¶
format_bytes_size(size)
¶
Format byte size in human-readable format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
Size in bytes |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted string like "1.5 MB" |