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: ControlShell

A 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 --strategy command line argument is applied together with the socket path given in the -s | --socket argument. If the latter is not given but required, the auto-detection of SocketClient will 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 --strategy command line argument is given.

Parameters:

gpioStrategy (GpioStrategy | True) – The strategy to apply for creating a GPIO client for a specific GPIO server. True is equivalent to SERVER_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 from GpioStrategy stating 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, ServiceControlShell

A context manager for creating services internally using a GPIO client.

__init__(parser, processExecutor=None, envConfigPath=None, msgBuffer=None, lng=None, **kwargs)

Accepts an additional gpioStrategy parameter 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.