Skip to main content

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.

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.2.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.2-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for qtoggleserver_cmdline-1.4.2.tar.gz
Algorithm Hash digest
SHA256 4453f9cda13d0e55c1687f61399ce2aa12b6c5b0fb90789464b1057718d2955d
MD5 14775ec561fd9977c68ec61234b0e2c2
BLAKE2b-256 8c96b5b3939136223bdcc7fde87098538d6884a8a50cf096f3570203e7ecd770

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for qtoggleserver_cmdline-1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6942c8649c1c0f37c779a79ea4dd7278a4085fa7d3db461000f9746c6d85d706
MD5 77e3f69e660d15a74acb1415ab4537a4
BLAKE2b-256 24dc79bc748962a5c7a539dec88a9cd859782502e0e31aee09b93478779219a0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.4.2 This release

2 files

1.4.0

2 files

1.3.2

2 files

1.3.1

2 files

1.3.0

2 files

1.2.0

2 files

1.0.4

1 file

1.0.3

1 file

1.0.2

1 file

1.0.1

1 file

1.0.0

1 file

Supported by

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