qToggleServer ports backed by system commands
Project description
About
This is an addon for qToggleServer.
It provides a driver for ports whose values are backed by system commands.
Install
Install using pip:
pip install qtoggleserver-cmdline
Usage
qtoggleserver.conf:
...
peripherals = [
...
{
driver = "qtoggleserver.cmdline.CommandLine"
name = "my_command"
output_regexp = "^some (value1) and some other (value2)$"
read_command = "/path/to/command with args"
write_command = "echo ${my_port1} ${my_port2}"
ports = [
{id = "my_port1", type = "boolean"}
{id = "my_port2", type = "number"}
...
]
port = {
id = "my_port"
type = "boolean"
}
timeout = 5
},
...
]
...
name is an optional name that will be used as a prefix for all ports.
read_command sets a command to be executed to determine the value of ports. If this parameter is not specified, no
polling is done and the values will only be set to what is written to the ports.
If output_regexp is specified, output of read_command is parsed against it as a regular expression. Following rules
apply:
- If output does not match the regular expression, all port values will be set to
null. - The port values will be determined in order of the indicated groups. If no group is defined, the entire output will be used to determine the value of all ports.
- For boolean ports, text
true(case-insensitive) or any other non-zero decimal number representstrue. - For number ports, matched group content will be converted to float.
If output_regexp is not specified, exit code of read_command will be used to determine port values. An exit code of
0 represents true for all boolean ports, while any other exit code represents false. All number ports will use
exit code as their value.
The write_command parameter, if specified, sets a command that will be called whenever the port value changes. The new
port values will be supplied in environment variables with names corresponding to port ids. Any dots in port ids will be
converted to underscores. Boolean values will be transmitted as 0 and 1. All port values will be available,
regardless of which one has changed.
If write_command is not specified, all ports will be read-only.
ports is a list of ports to be exposed. If you only need one port, use the port shortcut parameter.
Use the timeout parameter to set a timeout when waiting for the commands to complete, in seconds.
Although using blocking commands will not block the server, it is recommended that you supply commands that don't block.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qtoggleserver_cmdline-1.3.1.tar.gz.
File metadata
- Download URL: qtoggleserver_cmdline-1.3.1.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5b4f81ac346c0e580c604732e0e788b0f17d85008f6cdbc6825120f1d756956
|
|
| MD5 |
688ba5338e9757489d24320bcdef1c37
|
|
| BLAKE2b-256 |
3b0619f632eaf32854a999873fc9dfb863b96c8571bd332b69618af33d3d9f30
|
File details
Details for the file qtoggleserver_cmdline-1.3.1-py3-none-any.whl.
File metadata
- Download URL: qtoggleserver_cmdline-1.3.1-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
876134b56039021a6cce5979c4a728179d30e5d058e52361be6dabe75798b0a0
|
|
| MD5 |
35681728cebb312dba472baf75ac02b3
|
|
| BLAKE2b-256 |
e763a7b3bd24dcaf917b2ecaf4198420ffd013c6d9ea5cb621211c31424a6110
|