plesty.server.cli.main
The plesty-server command group.
Every command opens the Bench for the
--home/-f given (or found) and calls one presenter method. Long work
(install, update, field test) is started as a job and the job log is streamed
unless --no-wait is given; the hidden _job group is what those jobs
execute in the foreground.
Attributes
Classes
What every command receives: how to open the bench, and how loud to be. |
Functions
|
Install, launch and supervise PLESTY device servers on this bench. |
|
Call action, turning every expected failure into a one-line CLI error. |
|
Stream a job's log until it ends; returns its exit code. |
|
|
|
Add device NAME running PACKAGE to the fleet file, or to the fleet NAME. |
|
Have NAME running for an experiment's run; say the port it listens on. |
|
Read PROBE under ROOT, and write REPLY there: is ROOT the master's shared disk? |
|
|
|
Install the environment NAME declares (as a job). |
|
Pull and re-sync (git) or reinstall (PyPI) the environment of NAME. |
|
Stop NAME and remove its environment (unless another device uses it). |
|
Remove parts of this bench's home — or all of it. |
|
Write found for the uninstaller's list: one tab-separated line per row. |
|
Render size in units a person reads at a glance. |
|
Empty the server log of NAME (and with it the traffic history). |
|
The device modules on this bench — what the fleet declares instances of. |
|
Put PACKAGE on this bench (as a job); no device is declared. |
|
Load the module repository at FOLDER where it lives (as a job). |
|
List the modules installed on this bench. |
|
Show every declared device: source, installed version, state. |
|
Start the device server NAME (installing first when needed). |
|
Stop the device server NAME. |
|
Stop (if running) and start the device server NAME. |
|
Show the state of NAMES (default: every declared device). |
|
Print the tail of the server log of NAME. |
|
Run the field test of NAME on this bench (as a job). EXTRA goes to the script. |
|
|
|
List the published field-test reports of NAME. |
|
Long-running work on the bench: installs, updates, field tests. |
|
List jobs, newest first. |
|
Print the log of JOB_ID (from --offset; --json for a tailing client). |
|
Kill a running job. |
|
Operate every device declared in fleet.yaml at once. |
|
Create the empty fleet NAME on this bench (<home>/fleets/NAME.yaml). |
|
Every fleet of this bench: its name, file and device count; * marks the current. |
|
Write an annotated example fleet.yaml to PATH. |
|
Install and start the autostart devices (or NAMES). |
|
Stop the declared devices (or NAMES). |
|
Bring the fleet up and keep it up until interrupted (headless bench mode). |
|
Show the state of every declared device. |
|
Serve plesty-bench clients: run plesty-server commands for them on this bench. |
|
Show this bench's Plesty share and folder, or set them. |
|
Print a bench's share, folder and the root they make, or that none is set. |
|
Open the Qt console (needs the 'gui' extra). |
|
Foreground twins of the job commands (run by the launcher, not by people). |
|
Install NAME in the foreground. |
|
Install the module PACKAGE in the foreground. |
|
Load the module repository at FOLDER in the foreground. |
|
Run experiment NAME's module COMMAND, then stop the devices the run started. |
|
Leave a copy of this job's log in the run's directory; say why when it cannot. |
|
Write the run's report into its own directory; say why when it cannot. |
|
Update NAME in the foreground. |
|
Run the field test of NAME in the foreground. |
|
Run the detached launcher (spec as JSON on stdin); used by the PyInstaller bundle. |
|
|
|
|
|
|
|
|
|
|
|
Console-script entry point. |
|
GUI-script entry point ( |
Module Contents
- class plesty.server.cli.main.Context(home: str | None, fleet: str | None, quiet: bool)
What every command receives: how to open the bench, and how loud to be.
Remember the global options.
- Parameters:
home (str | None)
fleet (str | None)
quiet (bool)
- home_arg
- fleet_arg
- quiet
- _bench: plesty.server.presenter.Bench | None = None
- bench() plesty.server.presenter.Bench
The bench (opened once per invocation).
- Return type:
- say(line: str) None
Progress to stderr unless
--quiet.- Parameters:
line (str)
- Return type:
None
- plesty.server.cli.main.pass_context
- plesty.server.cli.main.app(ctx: click.Context, home_arg: str | None, fleet_arg: str | None, quiet: bool) None
Install, launch and supervise PLESTY device servers on this bench.
- Parameters:
ctx (click.Context)
home_arg (str | None)
fleet_arg (str | None)
quiet (bool)
- Return type:
None
- plesty.server.cli.main.EXPECTED
- plesty.server.cli.main._run[T](ctx: Context, action: collections.abc.Callable[[], T]) T
Call action, turning every expected failure into a one-line CLI error.
- Parameters:
ctx (Context)
action (collections.abc.Callable[[], T])
- Return type:
T
- plesty.server.cli.main._follow_job(ctx: Context, job: plesty.server.model.Job) int
Stream a job’s log until it ends; returns its exit code.
- Parameters:
ctx (Context)
job (plesty.server.model.Job)
- Return type:
int
- plesty.server.cli.main._finish_job(ctx: Context, job: plesty.server.model.Job, wait: bool) None
- Parameters:
ctx (Context)
job (plesty.server.model.Job)
wait (bool)
- Return type:
None
- plesty.server.cli.main.declare(ctx: Context, name: str, package: str, version: str | None, git_url: str | None, ref: str | None, args: tuple[str, Ellipsis], env: tuple[str, Ellipsis], no_autostart: bool, fleet_name: str | None) None
Add device NAME running PACKAGE to the fleet file, or to the fleet NAME.
- Parameters:
ctx (Context)
name (str)
package (str)
version (str | None)
git_url (str | None)
ref (str | None)
args (tuple[str, Ellipsis])
env (tuple[str, Ellipsis])
no_autostart (bool)
fleet_name (str | None)
- Return type:
None
- plesty.server.cli.main.serve(ctx: Context, name: str, entry_json: str, as_json: bool) None
Have NAME running for an experiment’s run; say the port it listens on.
Declares it from –entry when the fleet lacks it (a free port when the entry names none), then starts it unless it is running already. What a master bench asks of this one when a run needs a device here.
- Parameters:
ctx (Context)
name (str)
entry_json (str)
as_json (bool)
- Return type:
None
Read PROBE under ROOT, and write REPLY there: is ROOT the master’s shared disk?
A master bench writes PROBE under the disk as it sees it, and reads REPLY back: the same content at both ends shows both see one folder, and that this bench can write to it. Both paths stay under ROOT.
- Parameters:
root (str)
probe (str)
reply (str)
as_json (bool)
- Return type:
None
- plesty.server.cli.main._parse_env(pairs: tuple[str, Ellipsis]) dict[str, str]
- Parameters:
pairs (tuple[str, Ellipsis])
- Return type:
dict[str, str]
- plesty.server.cli.main.install(ctx: Context, name: str, force: bool, no_wait: bool) None
Install the environment NAME declares (as a job).
- Parameters:
ctx (Context)
name (str)
force (bool)
no_wait (bool)
- Return type:
None
- plesty.server.cli.main.update(ctx: Context, name: str, ref: str | None, no_wait: bool) None
Pull and re-sync (git) or reinstall (PyPI) the environment of NAME.
- Parameters:
ctx (Context)
name (str)
ref (str | None)
no_wait (bool)
- Return type:
None
- plesty.server.cli.main.uninstall(ctx: Context, name: str) None
Stop NAME and remove its environment (unless another device uses it).
- Parameters:
ctx (Context)
name (str)
- Return type:
None
- plesty.server.cli.main.purge(ctx: Context, parts: tuple[str, Ellipsis], listing: bool, everything: bool, as_json: bool, tsv: str | None, yes: bool) None
Remove parts of this bench’s home — or all of it.
Uninstalling the application and wiping the bench are different acts, and only the first had a command. PARTS names what to remove (purge –list prints the names): a whole part, such as packages, or one item of it, such as module:plesty-pm100d. –all removes the home directory itself.
Stop the fleet first: a running server holds its environment open.
- Parameters:
ctx (Context)
parts (tuple[str, Ellipsis])
listing (bool)
everything (bool)
as_json (bool)
tsv (str | None)
yes (bool)
- Return type:
None
- plesty.server.cli.main._write_purge_list(path: pathlib.Path, found: collections.abc.Sequence[plesty.server.model.purge.Removable]) None
Write found for the uninstaller’s list: one tab-separated line per row.
A row is
level, key, label, size: a group’s heading at level 0 and its items at level 1 under it, or a single level-0 row for a part that is one item (process state, tools). The uninstaller ticks a heading’s items with it and passes back only item keys. UTF-8 with a byte-order mark, which is how Inno Setup’sLoadStringsFromFiletells it from the ANSI codepage.- Parameters:
path (pathlib.Path)
found (collections.abc.Sequence[plesty.server.model.purge.Removable])
- Return type:
None
- plesty.server.cli.main._bytes(size: int) str
Render size in units a person reads at a glance.
Binary divisor, binary names. It divided by 1024 and wrote
MB, so the printed column and the--jsonbyte count disagreed by 5% — on the one screen whose whole purpose is telling somebody what removing a part costs them, which is exactly where a reader stops and checks twice.MiBis ugly and unambiguous; the alternative, dividing by 1000 to match the name, would have disagreed with what Windows shows for the same directory instead.- Parameters:
size (int) – A number of bytes.
- Returns:
The size with a unit that means what it says.
- Return type:
str
- plesty.server.cli.main.clear_log(ctx: Context, name: str) None
Empty the server log of NAME (and with it the traffic history).
- Parameters:
ctx (Context)
name (str)
- Return type:
None
- plesty.server.cli.main.module() None
The device modules on this bench — what the fleet declares instances of.
- Return type:
None
- plesty.server.cli.main.module_install(ctx: Context, package: str, version: str | None, git_url: str | None, ref: str | None, force: bool, no_wait: bool) None
Put PACKAGE on this bench (as a job); no device is declared.
- Parameters:
ctx (Context)
package (str)
version (str | None)
git_url (str | None)
ref (str | None)
force (bool)
no_wait (bool)
- Return type:
None
- plesty.server.cli.main.module_load(ctx: Context, folder: str, ref: str | None, no_wait: bool) None
Load the module repository at FOLDER where it lives (as a job).
Nothing is copied: the bench records the folder, what the module is, its branch, version and commit, and runs it with the folder’s own .venv.
- Parameters:
ctx (Context)
folder (str)
ref (str | None)
no_wait (bool)
- Return type:
None
- plesty.server.cli.main.module_list(ctx: Context, as_json: bool) None
List the modules installed on this bench.
- Parameters:
ctx (Context)
as_json (bool)
- Return type:
None
- plesty.server.cli.main.list_devices(ctx: Context, no_probe: bool, as_json: bool) None
Show every declared device: source, installed version, state.
- Parameters:
ctx (Context)
no_probe (bool)
as_json (bool)
- Return type:
None
- plesty.server.cli.main.start(ctx: Context, name: str, no_wait: bool, timeout: float | None) None
Start the device server NAME (installing first when needed).
- Parameters:
ctx (Context)
name (str)
no_wait (bool)
timeout (float | None)
- Return type:
None
- plesty.server.cli.main.stop(ctx: Context, name: str, timeout: float | None) None
Stop the device server NAME.
- Parameters:
ctx (Context)
name (str)
timeout (float | None)
- Return type:
None
- plesty.server.cli.main.restart(ctx: Context, name: str, no_wait: bool) None
Stop (if running) and start the device server NAME.
- Parameters:
ctx (Context)
name (str)
no_wait (bool)
- Return type:
None
- plesty.server.cli.main.status(ctx: Context, names: tuple[str, Ellipsis], no_probe: bool, as_json: bool) None
Show the state of NAMES (default: every declared device).
- Parameters:
ctx (Context)
names (tuple[str, Ellipsis])
no_probe (bool)
as_json (bool)
- Return type:
None
- plesty.server.cli.main.log(ctx: Context, name: str, lines: int) None
Print the tail of the server log of NAME.
- Parameters:
ctx (Context)
name (str)
lines (int)
- Return type:
None
- plesty.server.cli.main.field_test(ctx: Context, name: str, extra: tuple[str, Ellipsis], tier: str, address: str | None, gates: str | None, repetitions: int | None, keep_going: bool, keep_server: bool, no_wait: bool) None
Run the field test of NAME on this bench (as a job). EXTRA goes to the script.
- Parameters:
ctx (Context)
name (str)
extra (tuple[str, Ellipsis])
tier (str)
address (str | None)
gates (str | None)
repetitions (int | None)
keep_going (bool)
keep_server (bool)
no_wait (bool)
- Return type:
None
- plesty.server.cli.main._field_test_run(tier: str, address: str | None, gates: str | None, repetitions: int | None, keep_going: bool, keep_server: bool, extra: tuple[str, Ellipsis]) plesty.server.model.FieldTestRun
- Parameters:
tier (str)
address (str | None)
gates (str | None)
repetitions (int | None)
keep_going (bool)
keep_server (bool)
extra (tuple[str, Ellipsis])
- Return type:
- plesty.server.cli.main.reports(ctx: Context, name: str, as_json: bool) None
List the published field-test reports of NAME.
- Parameters:
ctx (Context)
name (str)
as_json (bool)
- Return type:
None
- plesty.server.cli.main.jobs() None
Long-running work on the bench: installs, updates, field tests.
- Return type:
None
- plesty.server.cli.main.jobs_list(ctx: Context, name: str | None, kind: str | None, as_json: bool) None
List jobs, newest first.
- Parameters:
ctx (Context)
name (str | None)
kind (str | None)
as_json (bool)
- Return type:
None
- plesty.server.cli.main.jobs_log(ctx: Context, job_id: str, follow: bool, offset: int, as_json: bool) None
Print the log of JOB_ID (from –offset; –json for a tailing client).
- Parameters:
ctx (Context)
job_id (str)
follow (bool)
offset (int)
as_json (bool)
- Return type:
None
- plesty.server.cli.main.jobs_cancel(ctx: Context, job_id: str) None
Kill a running job.
- Parameters:
ctx (Context)
job_id (str)
- Return type:
None
- plesty.server.cli.main.fleet() None
Operate every device declared in fleet.yaml at once.
- Return type:
None
- plesty.server.cli.main.fleet_new(ctx: Context, name: str) None
Create the empty fleet NAME on this bench (<home>/fleets/NAME.yaml).
The current fleet stays current; declare into the new one with
declare … --fleet NAME.- Parameters:
ctx (Context)
name (str)
- Return type:
None
- plesty.server.cli.main.fleet_list(ctx: Context, as_json: bool) None
Every fleet of this bench: its name, file and device count; * marks the current.
- Parameters:
ctx (Context)
as_json (bool)
- Return type:
None
- plesty.server.cli.main.fleet_init(path: str, force: bool) None
Write an annotated example fleet.yaml to PATH.
- Parameters:
path (str)
force (bool)
- Return type:
None
- plesty.server.cli.main.fleet_up(ctx: Context, names: tuple[str, Ellipsis], no_install: bool, no_wait: bool) None
Install and start the autostart devices (or NAMES).
- Parameters:
ctx (Context)
names (tuple[str, Ellipsis])
no_install (bool)
no_wait (bool)
- Return type:
None
- plesty.server.cli.main.fleet_down(ctx: Context, names: tuple[str, Ellipsis]) None
Stop the declared devices (or NAMES).
- Parameters:
ctx (Context)
names (tuple[str, Ellipsis])
- Return type:
None
- plesty.server.cli.main.fleet_run(ctx: Context, names: tuple[str, Ellipsis], interval: float, with_agent: bool, bind: str | None, token: str | None, leave_running: bool, sweeps: int | None) None
Bring the fleet up and keep it up until interrupted (headless bench mode).
- Parameters:
ctx (Context)
names (tuple[str, Ellipsis])
interval (float)
with_agent (bool)
bind (str | None)
token (str | None)
leave_running (bool)
sweeps (int | None)
- Return type:
None
- plesty.server.cli.main.fleet_status(ctx: Context, no_probe: bool) None
Show the state of every declared device.
- Parameters:
ctx (Context)
no_probe (bool)
- Return type:
None
- plesty.server.cli.main.agent(ctx: Context, bind: str | None, token: str | None, workers: int, max_replies: int | None) None
Serve plesty-bench clients: run plesty-server commands for them on this bench.
Defaults come from the bench’s own agent settings (
<home>/agent.yaml, written by the console’s Server ▸ Configure…), so a configured bench is served the same way whichever surface starts it. Every option overrides.- Parameters:
ctx (Context)
bind (str | None)
token (str | None)
workers (int)
max_replies (int | None)
- Return type:
None
- plesty.server.cli.main.data_path(ctx: Context, share: str | None, folder: str, clear: bool) None
Show this bench’s Plesty share and folder, or set them.
SHARE is the lab’s shared disk as this machine mounts it, and FOLDER this bench’s folder in it, as Server ▸ Configure… sets them. Every device the bench starts writes under SHARE/FOLDER, to its
data_dirortmp/<device>, and is given SHARE asPLESTY_DATA. SHARE must be an existing folder; FOLDER is created when missing. Throughplesty-bench -b BENCH data-path SHARE --folder FOLDERit sets another bench’s.- Parameters:
ctx (Context)
share (str | None)
folder (str)
clear (bool)
- Return type:
None
- plesty.server.cli.main._echo_data_location(settings: plesty.server.model.AgentSettings) None
Print a bench’s share, folder and the root they make, or that none is set.
- Parameters:
settings (plesty.server.model.AgentSettings)
- Return type:
None
- plesty.server.cli.main.gui(ctx: Context, title: str | None) None
Open the Qt console (needs the ‘gui’ extra).
- Parameters:
ctx (Context)
title (str | None)
- Return type:
None
- plesty.server.cli.main.job_group() None
Foreground twins of the job commands (run by the launcher, not by people).
- Return type:
None
- plesty.server.cli.main.job_install(ctx: Context, name: str, force: bool) None
Install NAME in the foreground.
- Parameters:
ctx (Context)
name (str)
force (bool)
- Return type:
None
- plesty.server.cli.main.job_module_install(ctx: Context, package: str, version: str | None, git_url: str | None, ref: str | None, force: bool) None
Install the module PACKAGE in the foreground.
- Parameters:
ctx (Context)
package (str)
version (str | None)
git_url (str | None)
ref (str | None)
force (bool)
- Return type:
None
- plesty.server.cli.main.job_module_load(ctx: Context, folder: str, ref: str | None) None
Load the module repository at FOLDER in the foreground.
- Parameters:
ctx (Context)
folder (str)
ref (str | None)
- Return type:
None
- plesty.server.cli.main.job_experiment_run(ctx: Context, name: str, release: tuple[str, Ellipsis], run_root: str | None, run_id: str | None, command: tuple[str, Ellipsis]) None
Run experiment NAME’s module COMMAND, then stop the devices the run started.
The module ends however it ends — completed, stopped, aborted, crashed — and its devices are stopped every time; the job exits with its code.
The run’s report is written into its directory afterwards, so a finished measurement carries its own reading of itself without anybody pressing anything. Devices are released first: a report is worth having and a device left holding the hardware is not.
- Parameters:
ctx (Context)
name (str)
release (tuple[str, Ellipsis])
run_root (str | None)
run_id (str | None)
command (tuple[str, Ellipsis])
- Return type:
None
- plesty.server.cli.main._keep_log_with_run(name: str, run_root: str, run_id: str | None) None
Leave a copy of this job’s log in the run’s directory; say why when it cannot.
The job’s log is in the bench home, which an uninstall can empty and another bench never had; the run is on the shared disk. Last, so the copy holds the report’s line too. Never raises, for the reason the report does not (#33).
- Parameters:
name (str)
run_root (str)
run_id (str | None)
- Return type:
None
- plesty.server.cli.main._report_on_run(name: str, run_root: str, run_id: str | None) None
Write the run’s report into its own directory; say why when it cannot.
Never raises. The measurement is already over and its data is on disk, so a report that cannot be compiled is worth a line in the job log and nothing more — failing the job here would report a successful run as a failed one.
- Parameters:
name (str)
run_root (str)
run_id (str | None)
- Return type:
None
- plesty.server.cli.main.job_update(ctx: Context, name: str, ref: str | None) None
Update NAME in the foreground.
- Parameters:
ctx (Context)
name (str)
ref (str | None)
- Return type:
None
- plesty.server.cli.main.job_field_test(ctx: Context, name: str, extra: tuple[str, Ellipsis], tier: str, address: str | None, gates: str | None, repetitions: int | None, keep_going: bool, keep_server: bool) None
Run the field test of NAME in the foreground.
- Parameters:
ctx (Context)
name (str)
extra (tuple[str, Ellipsis])
tier (str)
address (str | None)
gates (str | None)
repetitions (int | None)
keep_going (bool)
keep_server (bool)
- Return type:
None
- plesty.server.cli.main.launch_waiter() None
Run the detached launcher (spec as JSON on stdin); used by the PyInstaller bundle.
- Return type:
None
- plesty.server.cli.main._device_dict(view: plesty.server.presenter.DeviceView) dict[str, object]
- Parameters:
- Return type:
dict[str, object]
- plesty.server.cli.main._report_dict(ctx: Context, report: plesty.server.model.FieldTestReport) dict[str, object]
- Parameters:
ctx (Context)
report (plesty.server.model.FieldTestReport)
- Return type:
dict[str, object]
- plesty.server.cli.main._table(header: collections.abc.Sequence[str], rows: collections.abc.Sequence[collections.abc.Sequence[str]]) list[str]
- Parameters:
header (collections.abc.Sequence[str])
rows (collections.abc.Sequence[collections.abc.Sequence[str]])
- Return type:
list[str]
- plesty.server.cli.main._status_table(statuses: collections.abc.Sequence[plesty.server.model.ProcessStatus]) list[str]
- Parameters:
statuses (collections.abc.Sequence[plesty.server.model.ProcessStatus])
- Return type:
list[str]
- plesty.server.cli.main._echo_status(status: plesty.server.model.ProcessStatus) None
- Parameters:
status (plesty.server.model.ProcessStatus)
- Return type:
None
- plesty.server.cli.main.main() None
Console-script entry point.
- Return type:
None
- plesty.server.cli.main.gui_main() None
GUI-script entry point (
plesty-server-gui): the console window, no terminal.Installed as a
gui-scriptsentry so Windows starts it withpythonw— no black console box behind the window. Arguments are the group’s (--home,-f);_launch/_jobpass through for re-execution.- Return type:
None