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.
Metadata
Release files for qtoggleserver-cmdline 1.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| qtoggleserver_cmdline-1.4.2.tar.gz | 7.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qtoggleserver_cmdline-1.4.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.9 kB
Release files / qtoggleserver_cmdline-1.4.2.tar.gz
| Download URL | qtoggleserver_cmdline-1.4.2.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4453f9cda13d0e55c1687f61399ce2aa12b6c5b0fb90789464b1057718d2955d
|
|
BLAKE2b-256 checksum How to use checksums |
8c96b5b3939136223bdcc7fde87098538d6884a8a50cf096f3570203e7ecd770
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / qtoggleserver_cmdline-1.4.2-py3-none-any.whl
| Download URL | qtoggleserver_cmdline-1.4.2-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6942c8649c1c0f37c779a79ea4dd7278a4085fa7d3db461000f9746c6d85d706
|
|
BLAKE2b-256 checksum How to use checksums |
24dc79bc748962a5c7a539dec88a9cd859782502e0e31aee09b93478779219a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|