Skip to main content

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 represents true.
  • 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qtoggleserver_cmdline-1.4.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qtoggleserver_cmdline-1.4.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file qtoggleserver_cmdline-1.4.0.tar.gz.

File metadata

  • Download URL: qtoggleserver_cmdline-1.4.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qtoggleserver_cmdline-1.4.0.tar.gz
Algorithm Hash digest
SHA256 922140628549a9ebfde66f8d5674e8aef64e52444e1f221ac39629e6c2d5aaea
MD5 ad7663e1e938549e7db5a0f333881635
BLAKE2b-256 4a7c394dc366a0de6463880136770cda308f159e008859db0647e4179bab41f1

See more details on using hashes here.

File details

Details for the file qtoggleserver_cmdline-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for qtoggleserver_cmdline-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c34af6ee82211e3e86749046b9cc7af6c7d0878f94a85ce40b7b48f9d8c33e65
MD5 ab192e56e7bfe431c59ea899ff0d9fc6
BLAKE2b-256 beb6f587b8525e37c8b2d735d13aa63b453ace29ee9a1856a3cd688d10848f7a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page