Command Line Interface#

After installing the mahos package, a command named mahos is installed. This command serves as a command line interface (CLI) to use mahos. The mahos CLI provides several sub-commands described below.

Shell completion#

The mahos CLI supports shell completion via argcomplete for bash and zsh, which is enabled by:

eval "$(register-python-argcomplete mahos)"

To enable persistently, add the same line to ~/.bashrc or ~/.zshrc. If you are using Git Bash on Windows, you need to add export ARGCOMPLETE_USE_TEMPFILES=1 too. See here for details.

Node operations#

Common arguments#

There are common arguments for node operation commands.

-c [config file]#

To operate on MAHOS nodes, you have to prepare toml-based configuration file. The -c option specifies the path to the config file. Defaults to conf.toml.

-H [hostname]#

A CLI command usually targets a node. The full name of the node consists of a hostname and nodename. The -H option specifies the hostname part. Defaults to real hostname (platform.uname().node) if it is in the config file, or localhost.

mahos run#

mahos run [nodename] starts a mahos node.

If the node is InstrumentServer, you can specify Instrument to include / exclude using -i or -e arguments.

mahos launch#

mahos launch [nodenames] starts all the nodes (or specified nodes) pertaining to single host.

mahos launch -e [nodenames-to-exclude] starts all the nodes excluding specified names.

If a node named log (the recommended name for a LogBroker node) is defined to run on the host and is already up, it is automatically excluded.

mahos log#

mahos log [nodename=log] subscribes to a LogBroker to print logs on the console.

If the specified LogBroker node is configured to run on the same host and is not up, this command automatically starts the node.

mahos ls#

mahos ls prints the list of defined nodes in the config file.

mahos ls -i enables listing of Instruments and InstrumentOverlays in InstrumentServers.

mahos graph#

mahos graph visualizes the config file as a graph.

Add option -o [filename] to save to a file.

mahos echo#

mahos echo -t [topicname] [nodename] subscribes to a topic and prints published messages.

mahos shell#

mahos shell [nodenames] starts an IPython shell with clients for the nodes.

A bound variable cli holds instances of the clients. For each client, client.M is the message module that may be required to invoke client APIs.

Data operations#

mahos data ls#

mahos data ls [filenames] prints the list of attributes and types in data files.

mahos data note#

mahos data note [filenames] prints (or amends) the note attribute in data files.

Add option -a [new note string] to amend the note in the files.

mahos data print#

mahos data print [filenames] -k [keys=[params]] prints the attributes in data files.

mahos data plot#

mahos data plot [subcommand] plots the data inside data files.

mahos plot is a shorthand of mahos data plot.