multiCMD 1.71__tar.gz → 1.73__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {multicmd-1.71 → multicmd-1.73}/PKG-INFO +66 -11
- {multicmd-1.71 → multicmd-1.73}/README.md +65 -10
- {multicmd-1.71 → multicmd-1.73}/multiCMD.egg-info/PKG-INFO +66 -11
- {multicmd-1.71 → multicmd-1.73}/multiCMD.py +191 -64
- {multicmd-1.71 → multicmd-1.73}/tests/test_api.py +6 -1
- {multicmd-1.71 → multicmd-1.73}/tests/test_async_executor.py +435 -18
- {multicmd-1.71 → multicmd-1.73}/tests/test_env.py +4 -4
- {multicmd-1.71 → multicmd-1.73}/tests/test_interrupts.py +11 -11
- {multicmd-1.71 → multicmd-1.73}/tests/test_parsing.py +3 -3
- {multicmd-1.71 → multicmd-1.73}/tests/test_pool.py +3 -3
- {multicmd-1.71 → multicmd-1.73}/tests/test_process_groups.py +4 -4
- {multicmd-1.71 → multicmd-1.73}/tests/test_reader.py +1 -1
- {multicmd-1.71 → multicmd-1.73}/tests/test_sudo.py +117 -18
- {multicmd-1.71 → multicmd-1.73}/tests/test_supervision.py +7 -8
- {multicmd-1.71 → multicmd-1.73}/LICENSE +0 -0
- {multicmd-1.71 → multicmd-1.73}/multiCMD.egg-info/SOURCES.txt +0 -0
- {multicmd-1.71 → multicmd-1.73}/multiCMD.egg-info/dependency_links.txt +0 -0
- {multicmd-1.71 → multicmd-1.73}/multiCMD.egg-info/entry_points.txt +0 -0
- {multicmd-1.71 → multicmd-1.73}/multiCMD.egg-info/top_level.txt +0 -0
- {multicmd-1.71 → multicmd-1.73}/scripts/multiCMD +0 -0
- {multicmd-1.71 → multicmd-1.73}/setup.cfg +0 -0
- {multicmd-1.71 → multicmd-1.73}/setup.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_cli.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_cli_closed_stdout.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_cli_failed_stdout.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_cli_input.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_cli_summary.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_display.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_embed.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_expand_ranges.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_handover.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_helpers.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_packaging.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_pass_fds.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_ping.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_pty.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_reader_quit.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_regressions.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_run_command.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_run_commands.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_task.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_terminal_width.py +0 -0
- {multicmd-1.71 → multicmd-1.73}/tests/test_windows.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: multiCMD
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.73
|
|
4
4
|
Summary: Run commands simultaneously
|
|
5
5
|
Home-page: https://github.com/yufei-pan/multiCMD
|
|
6
6
|
Author: Yufei Pan
|
|
@@ -89,8 +89,8 @@ options:
|
|
|
89
89
|
= never, the default )
|
|
90
90
|
-m, --max_threads max_threads
|
|
91
91
|
maximum number of commands to run at once ( 0 = all )
|
|
92
|
-
--sudo use sudo for commands ( sudo -v asks first;
|
|
93
|
-
terminal
|
|
92
|
+
--sudo use sudo for commands ( sudo -v asks first; they run
|
|
93
|
+
as sudo -n on a terminal, or where sudo -v failed )
|
|
94
94
|
-q, --quiet quiet mode: hide command output ( the summary still
|
|
95
95
|
shows )
|
|
96
96
|
-n, --dry-run print each command, quoted, instead of running it
|
|
@@ -157,7 +157,13 @@ mcmd --sudo "systemctl restart myservice"
|
|
|
157
157
|
`sudo -v` asks for the password first, on the terminal, when `mcmd` runs in its foreground. Each command then runs as
|
|
158
158
|
`sudo -n` wherever there is a terminal, so one that sudo would still ask a password for (`timestamp_timeout=0`, a
|
|
159
159
|
remembered password that ran out mid-run, a run in the background) fails at once with `sudo: a password is required`
|
|
160
|
-
instead of waiting at a prompt nobody can answer. With no terminal (cron, `ssh` without `-t`)
|
|
160
|
+
instead of waiting at a prompt nobody can answer. With no terminal (cron, `ssh` without `-t`) `sudo -v` decides: where it
|
|
161
|
+
signs in (NOPASSWD for all, an askpass helper, a sign-in with no question) the commands run as plain `sudo`; where it
|
|
162
|
+
fails, as `sudo -n`, so on sudo 1.8.23, 1.9.5 and 1.9.16 pam_faillock counts at most one failed login per call (one `mcmd`
|
|
163
|
+
run, or one `run_commands` call: the one from `sudo -v`), and sudo 1.9.9 counts each command. Off POSIX there is no
|
|
164
|
+
`sudo -v`: the commands run as plain `sudo`. Where `sudo -v` signs in but a command needs a password
|
|
165
|
+
(every rule NOPASSWD and the command outside them), each refused command still counts one failed login, as before
|
|
166
|
+
([limitations](docs/limitations.md#where-sudo--v-needs-no-password-but-a-command-does-each-refused-command-counts-as-a-failed-login)).
|
|
161
167
|
|
|
162
168
|
Preview what a range expands to without running anything:
|
|
163
169
|
|
|
@@ -399,10 +405,19 @@ print(ex.get_results())
|
|
|
399
405
|
seconds (the constructor's `timeout` is only the per-command inactivity timeout).
|
|
400
406
|
`AsyncExecutor` takes the same `shell`, `prefix`, `color` and `pty` options as
|
|
401
407
|
`run_commands`, as constructor defaults or per call. One dispatcher thread
|
|
402
|
-
starts each queued command only after taking a permit from the semaphore, so
|
|
403
|
-
executor holds at most one thread per permit plus the dispatcher, however many
|
|
404
|
-
commands are queued.
|
|
405
|
-
|
|
408
|
+
starts each queued command only after taking a permit from the semaphore, so with a
|
|
409
|
+
limit the executor holds at most one thread per permit plus the dispatcher, however many
|
|
410
|
+
commands are queued. An executor given no semaphore, with `max_threads=0` (or less, or
|
|
411
|
+
`inf`), has no limit, as for `run_commands`. A `max_threads` given to one call limits that
|
|
412
|
+
call within the semaphore it uses (the executor's, or a `sem` given to the call; with
|
|
413
|
+
`sem=None`, the call's own `max_threads`, or the executor's `max_threads` when it gives
|
|
414
|
+
none), never past it, and holds back no command of another call. A call's commands start
|
|
415
|
+
in their order. A `max_threads` below 1 (or `inf`) is no limit; any other value that is
|
|
416
|
+
not a whole number is a `TypeError`, in a call (`None` there means not given) and in a
|
|
417
|
+
constructor that makes the semaphore.
|
|
418
|
+
A command's `task.thread`
|
|
419
|
+
is `None` until it starts, and goes back to `None` once it has finished and the
|
|
420
|
+
executor has joined its thread, so a
|
|
406
421
|
large batch does not keep a `Thread` object per finished command. `stop()` skips
|
|
407
422
|
commands that have not started yet, and so does a Ctrl-C ( or an error ) that interrupts
|
|
408
423
|
`run_command(s)`, for that call's commands.
|
|
@@ -423,9 +438,10 @@ multiCMD.run_command(["systemctl", "restart", "nginx"])
|
|
|
423
438
|
multiCMD.run_command(["id"], use_sudo=True)
|
|
424
439
|
```
|
|
425
440
|
|
|
426
|
-
If `sudo` is not on `PATH`,
|
|
427
|
-
|
|
428
|
-
in the terminal's foreground
|
|
441
|
+
If `sudo` is not on `PATH`, the request is ignored with a warning instead of failing. As root, `set_sudo(True)` (and so
|
|
442
|
+
`mcmd --sudo`) is ignored silently, but `use_sudo=True` on a call still runs `sudo`. On a terminal the commands run as
|
|
443
|
+
`sudo -n`, after a `sudo -v` that asks for the password in the terminal's foreground; with no terminal `sudo -v` decides
|
|
444
|
+
between plain `sudo` and `sudo -n` (as for `mcmd --sudo` above).
|
|
429
445
|
|
|
430
446
|
## Timeout semantics
|
|
431
447
|
|
|
@@ -568,6 +584,45 @@ pytest -m "not slow" # skip intentional sleep-heavy cases
|
|
|
568
584
|
```
|
|
569
585
|
|
|
570
586
|
`test_expand_ranges_perf.py` is a manual performance microbenchmark and is not collected by pytest.
|
|
587
|
+
`scripts/realsudo.py` runs `--sudo` against real sudo (1.8.23, 1.9.5, 1.9.9, 1.9.16) in Docker, with pam_faillock on, and
|
|
588
|
+
prints a table of what each version of `multiCMD.py` given to it did (`python3 scripts/realsudo.py` says how).
|
|
589
|
+
|
|
590
|
+
## Upgrading to 1.73 from 1.72
|
|
591
|
+
|
|
592
|
+
- Nothing needs doing unless a program builds an `AsyncExecutor` with no `semaphore` argument and a `max_threads` of 0 or
|
|
593
|
+
less, or above 1 that is not whole and not `inf` (`1.5`), or with `semaphore=None`, or gives `max_threads` to its
|
|
594
|
+
`run_command(s)`. `mcmd` and the module-level `run_command(s)` are unchanged.
|
|
595
|
+
- Fix: `AsyncExecutor(max_threads=0)`, or a negative value, with no `semaphore` given, runs every command at once, as
|
|
596
|
+
`run_commands(max_threads=0)` and `mcmd -m 0` do (1.72 started nothing, with no error, and `join()` never returned; a
|
|
597
|
+
negative value raised `ValueError`).
|
|
598
|
+
- Changed: a `max_threads` given to an executor's `run_command(s)` limits that call within the semaphore it uses (the
|
|
599
|
+
executor's, or a `sem` given to the call): it can lower the limit for the call, never raise it, and 0 or less adds none
|
|
600
|
+
(1.72 ignored it there, so `max_threads=1` on an executor of four now runs that call one at a time). It holds back no
|
|
601
|
+
command of another call. A call given a `sem` is limited by that one instead of the executor's, and `sem=None` by its
|
|
602
|
+
`max_threads`, or the executor's when it gives none, as before; with `semaphore=None` on the executor the calls no longer
|
|
603
|
+
wait for each other (1.72 made a call's limit hold up the calls queued after it).
|
|
604
|
+
- Changed: a `max_threads` given to an executor's call, or to its constructor when it makes the semaphore, that is not a
|
|
605
|
+
whole number (`1.5`) raises `TypeError` (1.72 made a semaphore of it that never blocks); below 1 (`0.5` too) and `inf` are
|
|
606
|
+
no limit. A string given to a call raises `TypeError` before anything runs, where 1.72 ignored it under the executor's
|
|
607
|
+
semaphore. `None` given to a call is the same as not giving it (1.72 raised `TypeError` for it on a call with no
|
|
608
|
+
semaphore).
|
|
609
|
+
|
|
610
|
+
## Upgrading to 1.72 from 1.71
|
|
611
|
+
|
|
612
|
+
- Nothing needs doing. Runs on a terminal, and runs whose `sudo -v` signs in (NOPASSWD for all, an askpass helper, a
|
|
613
|
+
sign-in with no question), are unchanged.
|
|
614
|
+
- Fix: with no terminal (cron, `ssh` without `-t`, mssh), where `sudo -v` fails (a password sudo with nothing remembered),
|
|
615
|
+
each command runs as `sudo -n`, so pam_faillock counts one failed login per call, `sudo -v`'s. 1.71 counted each command
|
|
616
|
+
too: a call of three commands locked the account at `deny=3` (4 records on sudo 1.8.23, 3 on 1.9.5 and 1.9.16). A
|
|
617
|
+
NOPASSWD rule for some commands still runs them. On sudo 1.9.9 (Ubuntu 22.04), which runs PAM for `sudo -n`, each still
|
|
618
|
+
counts.
|
|
619
|
+
- Changed: there `Task.command` and the summary show `sudo -n`, and a refused command says `sudo: a password is required`
|
|
620
|
+
(1.71: `a terminal is required to read the password ...`; on sudo 1.8.23 `no tty present and no askpass program
|
|
621
|
+
specified`). `--dry-run` with no terminal shows plain `sudo`: `sudo -v` does not run in a dry run.
|
|
622
|
+
- Changed, Windows (off POSIX): no `sudo -v` runs; the commands stay plain `sudo` (1.70 and 1.71 ran a `sudo -v` there and
|
|
623
|
+
ignored its exit).
|
|
624
|
+
- Known in 1.72, fixed in 1.73 (see above): `AsyncExecutor(max_threads=0)` starts no command, and a per-call
|
|
625
|
+
`max_threads` is ignored while the executor's own semaphore is used (as in 1.70 and 1.71).
|
|
571
626
|
|
|
572
627
|
## Upgrading to 1.71 from 1.70
|
|
573
628
|
|
|
@@ -64,8 +64,8 @@ options:
|
|
|
64
64
|
= never, the default )
|
|
65
65
|
-m, --max_threads max_threads
|
|
66
66
|
maximum number of commands to run at once ( 0 = all )
|
|
67
|
-
--sudo use sudo for commands ( sudo -v asks first;
|
|
68
|
-
terminal
|
|
67
|
+
--sudo use sudo for commands ( sudo -v asks first; they run
|
|
68
|
+
as sudo -n on a terminal, or where sudo -v failed )
|
|
69
69
|
-q, --quiet quiet mode: hide command output ( the summary still
|
|
70
70
|
shows )
|
|
71
71
|
-n, --dry-run print each command, quoted, instead of running it
|
|
@@ -132,7 +132,13 @@ mcmd --sudo "systemctl restart myservice"
|
|
|
132
132
|
`sudo -v` asks for the password first, on the terminal, when `mcmd` runs in its foreground. Each command then runs as
|
|
133
133
|
`sudo -n` wherever there is a terminal, so one that sudo would still ask a password for (`timestamp_timeout=0`, a
|
|
134
134
|
remembered password that ran out mid-run, a run in the background) fails at once with `sudo: a password is required`
|
|
135
|
-
instead of waiting at a prompt nobody can answer. With no terminal (cron, `ssh` without `-t`)
|
|
135
|
+
instead of waiting at a prompt nobody can answer. With no terminal (cron, `ssh` without `-t`) `sudo -v` decides: where it
|
|
136
|
+
signs in (NOPASSWD for all, an askpass helper, a sign-in with no question) the commands run as plain `sudo`; where it
|
|
137
|
+
fails, as `sudo -n`, so on sudo 1.8.23, 1.9.5 and 1.9.16 pam_faillock counts at most one failed login per call (one `mcmd`
|
|
138
|
+
run, or one `run_commands` call: the one from `sudo -v`), and sudo 1.9.9 counts each command. Off POSIX there is no
|
|
139
|
+
`sudo -v`: the commands run as plain `sudo`. Where `sudo -v` signs in but a command needs a password
|
|
140
|
+
(every rule NOPASSWD and the command outside them), each refused command still counts one failed login, as before
|
|
141
|
+
([limitations](docs/limitations.md#where-sudo--v-needs-no-password-but-a-command-does-each-refused-command-counts-as-a-failed-login)).
|
|
136
142
|
|
|
137
143
|
Preview what a range expands to without running anything:
|
|
138
144
|
|
|
@@ -374,10 +380,19 @@ print(ex.get_results())
|
|
|
374
380
|
seconds (the constructor's `timeout` is only the per-command inactivity timeout).
|
|
375
381
|
`AsyncExecutor` takes the same `shell`, `prefix`, `color` and `pty` options as
|
|
376
382
|
`run_commands`, as constructor defaults or per call. One dispatcher thread
|
|
377
|
-
starts each queued command only after taking a permit from the semaphore, so
|
|
378
|
-
executor holds at most one thread per permit plus the dispatcher, however many
|
|
379
|
-
commands are queued.
|
|
380
|
-
|
|
383
|
+
starts each queued command only after taking a permit from the semaphore, so with a
|
|
384
|
+
limit the executor holds at most one thread per permit plus the dispatcher, however many
|
|
385
|
+
commands are queued. An executor given no semaphore, with `max_threads=0` (or less, or
|
|
386
|
+
`inf`), has no limit, as for `run_commands`. A `max_threads` given to one call limits that
|
|
387
|
+
call within the semaphore it uses (the executor's, or a `sem` given to the call; with
|
|
388
|
+
`sem=None`, the call's own `max_threads`, or the executor's `max_threads` when it gives
|
|
389
|
+
none), never past it, and holds back no command of another call. A call's commands start
|
|
390
|
+
in their order. A `max_threads` below 1 (or `inf`) is no limit; any other value that is
|
|
391
|
+
not a whole number is a `TypeError`, in a call (`None` there means not given) and in a
|
|
392
|
+
constructor that makes the semaphore.
|
|
393
|
+
A command's `task.thread`
|
|
394
|
+
is `None` until it starts, and goes back to `None` once it has finished and the
|
|
395
|
+
executor has joined its thread, so a
|
|
381
396
|
large batch does not keep a `Thread` object per finished command. `stop()` skips
|
|
382
397
|
commands that have not started yet, and so does a Ctrl-C ( or an error ) that interrupts
|
|
383
398
|
`run_command(s)`, for that call's commands.
|
|
@@ -398,9 +413,10 @@ multiCMD.run_command(["systemctl", "restart", "nginx"])
|
|
|
398
413
|
multiCMD.run_command(["id"], use_sudo=True)
|
|
399
414
|
```
|
|
400
415
|
|
|
401
|
-
If `sudo` is not on `PATH`,
|
|
402
|
-
|
|
403
|
-
in the terminal's foreground
|
|
416
|
+
If `sudo` is not on `PATH`, the request is ignored with a warning instead of failing. As root, `set_sudo(True)` (and so
|
|
417
|
+
`mcmd --sudo`) is ignored silently, but `use_sudo=True` on a call still runs `sudo`. On a terminal the commands run as
|
|
418
|
+
`sudo -n`, after a `sudo -v` that asks for the password in the terminal's foreground; with no terminal `sudo -v` decides
|
|
419
|
+
between plain `sudo` and `sudo -n` (as for `mcmd --sudo` above).
|
|
404
420
|
|
|
405
421
|
## Timeout semantics
|
|
406
422
|
|
|
@@ -543,6 +559,45 @@ pytest -m "not slow" # skip intentional sleep-heavy cases
|
|
|
543
559
|
```
|
|
544
560
|
|
|
545
561
|
`test_expand_ranges_perf.py` is a manual performance microbenchmark and is not collected by pytest.
|
|
562
|
+
`scripts/realsudo.py` runs `--sudo` against real sudo (1.8.23, 1.9.5, 1.9.9, 1.9.16) in Docker, with pam_faillock on, and
|
|
563
|
+
prints a table of what each version of `multiCMD.py` given to it did (`python3 scripts/realsudo.py` says how).
|
|
564
|
+
|
|
565
|
+
## Upgrading to 1.73 from 1.72
|
|
566
|
+
|
|
567
|
+
- Nothing needs doing unless a program builds an `AsyncExecutor` with no `semaphore` argument and a `max_threads` of 0 or
|
|
568
|
+
less, or above 1 that is not whole and not `inf` (`1.5`), or with `semaphore=None`, or gives `max_threads` to its
|
|
569
|
+
`run_command(s)`. `mcmd` and the module-level `run_command(s)` are unchanged.
|
|
570
|
+
- Fix: `AsyncExecutor(max_threads=0)`, or a negative value, with no `semaphore` given, runs every command at once, as
|
|
571
|
+
`run_commands(max_threads=0)` and `mcmd -m 0` do (1.72 started nothing, with no error, and `join()` never returned; a
|
|
572
|
+
negative value raised `ValueError`).
|
|
573
|
+
- Changed: a `max_threads` given to an executor's `run_command(s)` limits that call within the semaphore it uses (the
|
|
574
|
+
executor's, or a `sem` given to the call): it can lower the limit for the call, never raise it, and 0 or less adds none
|
|
575
|
+
(1.72 ignored it there, so `max_threads=1` on an executor of four now runs that call one at a time). It holds back no
|
|
576
|
+
command of another call. A call given a `sem` is limited by that one instead of the executor's, and `sem=None` by its
|
|
577
|
+
`max_threads`, or the executor's when it gives none, as before; with `semaphore=None` on the executor the calls no longer
|
|
578
|
+
wait for each other (1.72 made a call's limit hold up the calls queued after it).
|
|
579
|
+
- Changed: a `max_threads` given to an executor's call, or to its constructor when it makes the semaphore, that is not a
|
|
580
|
+
whole number (`1.5`) raises `TypeError` (1.72 made a semaphore of it that never blocks); below 1 (`0.5` too) and `inf` are
|
|
581
|
+
no limit. A string given to a call raises `TypeError` before anything runs, where 1.72 ignored it under the executor's
|
|
582
|
+
semaphore. `None` given to a call is the same as not giving it (1.72 raised `TypeError` for it on a call with no
|
|
583
|
+
semaphore).
|
|
584
|
+
|
|
585
|
+
## Upgrading to 1.72 from 1.71
|
|
586
|
+
|
|
587
|
+
- Nothing needs doing. Runs on a terminal, and runs whose `sudo -v` signs in (NOPASSWD for all, an askpass helper, a
|
|
588
|
+
sign-in with no question), are unchanged.
|
|
589
|
+
- Fix: with no terminal (cron, `ssh` without `-t`, mssh), where `sudo -v` fails (a password sudo with nothing remembered),
|
|
590
|
+
each command runs as `sudo -n`, so pam_faillock counts one failed login per call, `sudo -v`'s. 1.71 counted each command
|
|
591
|
+
too: a call of three commands locked the account at `deny=3` (4 records on sudo 1.8.23, 3 on 1.9.5 and 1.9.16). A
|
|
592
|
+
NOPASSWD rule for some commands still runs them. On sudo 1.9.9 (Ubuntu 22.04), which runs PAM for `sudo -n`, each still
|
|
593
|
+
counts.
|
|
594
|
+
- Changed: there `Task.command` and the summary show `sudo -n`, and a refused command says `sudo: a password is required`
|
|
595
|
+
(1.71: `a terminal is required to read the password ...`; on sudo 1.8.23 `no tty present and no askpass program
|
|
596
|
+
specified`). `--dry-run` with no terminal shows plain `sudo`: `sudo -v` does not run in a dry run.
|
|
597
|
+
- Changed, Windows (off POSIX): no `sudo -v` runs; the commands stay plain `sudo` (1.70 and 1.71 ran a `sudo -v` there and
|
|
598
|
+
ignored its exit).
|
|
599
|
+
- Known in 1.72, fixed in 1.73 (see above): `AsyncExecutor(max_threads=0)` starts no command, and a per-call
|
|
600
|
+
`max_threads` is ignored while the executor's own semaphore is used (as in 1.70 and 1.71).
|
|
546
601
|
|
|
547
602
|
## Upgrading to 1.71 from 1.70
|
|
548
603
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: multiCMD
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.73
|
|
4
4
|
Summary: Run commands simultaneously
|
|
5
5
|
Home-page: https://github.com/yufei-pan/multiCMD
|
|
6
6
|
Author: Yufei Pan
|
|
@@ -89,8 +89,8 @@ options:
|
|
|
89
89
|
= never, the default )
|
|
90
90
|
-m, --max_threads max_threads
|
|
91
91
|
maximum number of commands to run at once ( 0 = all )
|
|
92
|
-
--sudo use sudo for commands ( sudo -v asks first;
|
|
93
|
-
terminal
|
|
92
|
+
--sudo use sudo for commands ( sudo -v asks first; they run
|
|
93
|
+
as sudo -n on a terminal, or where sudo -v failed )
|
|
94
94
|
-q, --quiet quiet mode: hide command output ( the summary still
|
|
95
95
|
shows )
|
|
96
96
|
-n, --dry-run print each command, quoted, instead of running it
|
|
@@ -157,7 +157,13 @@ mcmd --sudo "systemctl restart myservice"
|
|
|
157
157
|
`sudo -v` asks for the password first, on the terminal, when `mcmd` runs in its foreground. Each command then runs as
|
|
158
158
|
`sudo -n` wherever there is a terminal, so one that sudo would still ask a password for (`timestamp_timeout=0`, a
|
|
159
159
|
remembered password that ran out mid-run, a run in the background) fails at once with `sudo: a password is required`
|
|
160
|
-
instead of waiting at a prompt nobody can answer. With no terminal (cron, `ssh` without `-t`)
|
|
160
|
+
instead of waiting at a prompt nobody can answer. With no terminal (cron, `ssh` without `-t`) `sudo -v` decides: where it
|
|
161
|
+
signs in (NOPASSWD for all, an askpass helper, a sign-in with no question) the commands run as plain `sudo`; where it
|
|
162
|
+
fails, as `sudo -n`, so on sudo 1.8.23, 1.9.5 and 1.9.16 pam_faillock counts at most one failed login per call (one `mcmd`
|
|
163
|
+
run, or one `run_commands` call: the one from `sudo -v`), and sudo 1.9.9 counts each command. Off POSIX there is no
|
|
164
|
+
`sudo -v`: the commands run as plain `sudo`. Where `sudo -v` signs in but a command needs a password
|
|
165
|
+
(every rule NOPASSWD and the command outside them), each refused command still counts one failed login, as before
|
|
166
|
+
([limitations](docs/limitations.md#where-sudo--v-needs-no-password-but-a-command-does-each-refused-command-counts-as-a-failed-login)).
|
|
161
167
|
|
|
162
168
|
Preview what a range expands to without running anything:
|
|
163
169
|
|
|
@@ -399,10 +405,19 @@ print(ex.get_results())
|
|
|
399
405
|
seconds (the constructor's `timeout` is only the per-command inactivity timeout).
|
|
400
406
|
`AsyncExecutor` takes the same `shell`, `prefix`, `color` and `pty` options as
|
|
401
407
|
`run_commands`, as constructor defaults or per call. One dispatcher thread
|
|
402
|
-
starts each queued command only after taking a permit from the semaphore, so
|
|
403
|
-
executor holds at most one thread per permit plus the dispatcher, however many
|
|
404
|
-
commands are queued.
|
|
405
|
-
|
|
408
|
+
starts each queued command only after taking a permit from the semaphore, so with a
|
|
409
|
+
limit the executor holds at most one thread per permit plus the dispatcher, however many
|
|
410
|
+
commands are queued. An executor given no semaphore, with `max_threads=0` (or less, or
|
|
411
|
+
`inf`), has no limit, as for `run_commands`. A `max_threads` given to one call limits that
|
|
412
|
+
call within the semaphore it uses (the executor's, or a `sem` given to the call; with
|
|
413
|
+
`sem=None`, the call's own `max_threads`, or the executor's `max_threads` when it gives
|
|
414
|
+
none), never past it, and holds back no command of another call. A call's commands start
|
|
415
|
+
in their order. A `max_threads` below 1 (or `inf`) is no limit; any other value that is
|
|
416
|
+
not a whole number is a `TypeError`, in a call (`None` there means not given) and in a
|
|
417
|
+
constructor that makes the semaphore.
|
|
418
|
+
A command's `task.thread`
|
|
419
|
+
is `None` until it starts, and goes back to `None` once it has finished and the
|
|
420
|
+
executor has joined its thread, so a
|
|
406
421
|
large batch does not keep a `Thread` object per finished command. `stop()` skips
|
|
407
422
|
commands that have not started yet, and so does a Ctrl-C ( or an error ) that interrupts
|
|
408
423
|
`run_command(s)`, for that call's commands.
|
|
@@ -423,9 +438,10 @@ multiCMD.run_command(["systemctl", "restart", "nginx"])
|
|
|
423
438
|
multiCMD.run_command(["id"], use_sudo=True)
|
|
424
439
|
```
|
|
425
440
|
|
|
426
|
-
If `sudo` is not on `PATH`,
|
|
427
|
-
|
|
428
|
-
in the terminal's foreground
|
|
441
|
+
If `sudo` is not on `PATH`, the request is ignored with a warning instead of failing. As root, `set_sudo(True)` (and so
|
|
442
|
+
`mcmd --sudo`) is ignored silently, but `use_sudo=True` on a call still runs `sudo`. On a terminal the commands run as
|
|
443
|
+
`sudo -n`, after a `sudo -v` that asks for the password in the terminal's foreground; with no terminal `sudo -v` decides
|
|
444
|
+
between plain `sudo` and `sudo -n` (as for `mcmd --sudo` above).
|
|
429
445
|
|
|
430
446
|
## Timeout semantics
|
|
431
447
|
|
|
@@ -568,6 +584,45 @@ pytest -m "not slow" # skip intentional sleep-heavy cases
|
|
|
568
584
|
```
|
|
569
585
|
|
|
570
586
|
`test_expand_ranges_perf.py` is a manual performance microbenchmark and is not collected by pytest.
|
|
587
|
+
`scripts/realsudo.py` runs `--sudo` against real sudo (1.8.23, 1.9.5, 1.9.9, 1.9.16) in Docker, with pam_faillock on, and
|
|
588
|
+
prints a table of what each version of `multiCMD.py` given to it did (`python3 scripts/realsudo.py` says how).
|
|
589
|
+
|
|
590
|
+
## Upgrading to 1.73 from 1.72
|
|
591
|
+
|
|
592
|
+
- Nothing needs doing unless a program builds an `AsyncExecutor` with no `semaphore` argument and a `max_threads` of 0 or
|
|
593
|
+
less, or above 1 that is not whole and not `inf` (`1.5`), or with `semaphore=None`, or gives `max_threads` to its
|
|
594
|
+
`run_command(s)`. `mcmd` and the module-level `run_command(s)` are unchanged.
|
|
595
|
+
- Fix: `AsyncExecutor(max_threads=0)`, or a negative value, with no `semaphore` given, runs every command at once, as
|
|
596
|
+
`run_commands(max_threads=0)` and `mcmd -m 0` do (1.72 started nothing, with no error, and `join()` never returned; a
|
|
597
|
+
negative value raised `ValueError`).
|
|
598
|
+
- Changed: a `max_threads` given to an executor's `run_command(s)` limits that call within the semaphore it uses (the
|
|
599
|
+
executor's, or a `sem` given to the call): it can lower the limit for the call, never raise it, and 0 or less adds none
|
|
600
|
+
(1.72 ignored it there, so `max_threads=1` on an executor of four now runs that call one at a time). It holds back no
|
|
601
|
+
command of another call. A call given a `sem` is limited by that one instead of the executor's, and `sem=None` by its
|
|
602
|
+
`max_threads`, or the executor's when it gives none, as before; with `semaphore=None` on the executor the calls no longer
|
|
603
|
+
wait for each other (1.72 made a call's limit hold up the calls queued after it).
|
|
604
|
+
- Changed: a `max_threads` given to an executor's call, or to its constructor when it makes the semaphore, that is not a
|
|
605
|
+
whole number (`1.5`) raises `TypeError` (1.72 made a semaphore of it that never blocks); below 1 (`0.5` too) and `inf` are
|
|
606
|
+
no limit. A string given to a call raises `TypeError` before anything runs, where 1.72 ignored it under the executor's
|
|
607
|
+
semaphore. `None` given to a call is the same as not giving it (1.72 raised `TypeError` for it on a call with no
|
|
608
|
+
semaphore).
|
|
609
|
+
|
|
610
|
+
## Upgrading to 1.72 from 1.71
|
|
611
|
+
|
|
612
|
+
- Nothing needs doing. Runs on a terminal, and runs whose `sudo -v` signs in (NOPASSWD for all, an askpass helper, a
|
|
613
|
+
sign-in with no question), are unchanged.
|
|
614
|
+
- Fix: with no terminal (cron, `ssh` without `-t`, mssh), where `sudo -v` fails (a password sudo with nothing remembered),
|
|
615
|
+
each command runs as `sudo -n`, so pam_faillock counts one failed login per call, `sudo -v`'s. 1.71 counted each command
|
|
616
|
+
too: a call of three commands locked the account at `deny=3` (4 records on sudo 1.8.23, 3 on 1.9.5 and 1.9.16). A
|
|
617
|
+
NOPASSWD rule for some commands still runs them. On sudo 1.9.9 (Ubuntu 22.04), which runs PAM for `sudo -n`, each still
|
|
618
|
+
counts.
|
|
619
|
+
- Changed: there `Task.command` and the summary show `sudo -n`, and a refused command says `sudo: a password is required`
|
|
620
|
+
(1.71: `a terminal is required to read the password ...`; on sudo 1.8.23 `no tty present and no askpass program
|
|
621
|
+
specified`). `--dry-run` with no terminal shows plain `sudo`: `sudo -v` does not run in a dry run.
|
|
622
|
+
- Changed, Windows (off POSIX): no `sudo -v` runs; the commands stay plain `sudo` (1.70 and 1.71 ran a `sudo -v` there and
|
|
623
|
+
ignored its exit).
|
|
624
|
+
- Known in 1.72, fixed in 1.73 (see above): `AsyncExecutor(max_threads=0)` starts no command, and a per-call
|
|
625
|
+
`max_threads` is ignored while the executor's own semaphore is used (as in 1.70 and 1.71).
|
|
571
626
|
|
|
572
627
|
## Upgrading to 1.71 from 1.70
|
|
573
628
|
|