shell module
Base classes for implementing CLI utilities and service daemons requiring a GPIO client.
Class GpioControl holds a GPIO client in addition to the resources
of Control.
Classes GpioControlShell and ServiceControlShell serve
as a Python context managers for CLI utilities. They take care of the GPIO
client lifecycle, in addition to the lifecycle management of
ControlShell.
Classes
- class gpiosvr.shell.GpioControlShell(parser, processExecutor=None, envConfigPath=True, msgBuffer=None, lng=True, gpioStrategy=None, **kwargs)
Bases:
ControlShellA context manager for creating CLI utilities internally using a GPIO client.
- __init__(parser, processExecutor=None, envConfigPath=True, msgBuffer=None, lng=True, gpioStrategy=None, **kwargs)
Creates and lifecycle-manages a GPIO client. To this end, the strategy given in the
--strategycommand line argument is applied together with the socket path given in the-s|--socketargument. If the latter is not given but required, the auto-detection ofSocketClientwill take effect.Arguments with the same name have the same meaning as with
ctlbase.shell.ControlShell.__init__().The following parameter takes effect only if no
--strategycommand line argument is given.- Parameters:
gpioStrategy¶ (
GpioStrategy| True) – The strategy to apply for creating a GPIO client for a specific GPIO server.Trueis equivalent toSERVER_FIRST(as a default).
- static addStandardArgs(parser, strategyKey=None, socketPathKey=None, nameKey=None)
For uniform arguments of executable scripts, amends an argument parser with standard arguments.
--strategy: The name of a constant fromGpioStrategystating the strategy for auto-detecting an available GPIO server and a corresponding client. Handled by__enter__().-s|--socket: Socket path of the GPIO server to connect to. Handled by__enter__().--name: A human-readable name identifying the client in the GPIO server. Handled by__enter__().
- gpioClient
The GPIO client lifecycle-managed by this context manager.
- class gpiosvr.shell.GpioServiceControlShell(parser, processExecutor=None, envConfigPath=None, msgBuffer=None, lng=None, **kwargs)
Bases:
GpioControlShell,ServiceControlShellA context manager for creating services internally using a GPIO client.
- __init__(parser, processExecutor=None, envConfigPath=None, msgBuffer=None, lng=None, **kwargs)
Accepts an additional
gpioStrategyparameter for creating a GPIO client for a specific GPIO server.
Constants and defaults
- class gpiosvr.shell.GpioStrategy(value)
Strategy for auto-decting a GPIO server and a corresponding client.