meerschaum 2.2.7__py3-none-any.whl → 2.3.0__py3-none-any.whl
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.
- meerschaum/__init__.py +6 -1
- meerschaum/__main__.py +0 -5
- meerschaum/_internal/arguments/__init__.py +1 -1
- meerschaum/_internal/arguments/_parse_arguments.py +72 -6
- meerschaum/_internal/arguments/_parser.py +45 -15
- meerschaum/_internal/docs/index.py +265 -8
- meerschaum/_internal/entry.py +154 -24
- meerschaum/_internal/shell/Shell.py +264 -77
- meerschaum/actions/__init__.py +29 -17
- meerschaum/actions/api.py +12 -12
- meerschaum/actions/attach.py +113 -0
- meerschaum/actions/copy.py +68 -41
- meerschaum/actions/delete.py +112 -50
- meerschaum/actions/edit.py +3 -3
- meerschaum/actions/install.py +40 -32
- meerschaum/actions/pause.py +44 -27
- meerschaum/actions/restart.py +107 -0
- meerschaum/actions/show.py +130 -159
- meerschaum/actions/start.py +161 -100
- meerschaum/actions/stop.py +78 -42
- meerschaum/api/_events.py +25 -1
- meerschaum/api/_oauth2.py +2 -0
- meerschaum/api/_websockets.py +2 -2
- meerschaum/api/dash/callbacks/jobs.py +36 -44
- meerschaum/api/dash/jobs.py +89 -78
- meerschaum/api/routes/__init__.py +1 -0
- meerschaum/api/routes/_actions.py +148 -17
- meerschaum/api/routes/_jobs.py +407 -0
- meerschaum/api/routes/_pipes.py +5 -5
- meerschaum/config/_default.py +1 -0
- meerschaum/config/_jobs.py +1 -1
- meerschaum/config/_paths.py +7 -0
- meerschaum/config/_shell.py +8 -3
- meerschaum/config/_version.py +1 -1
- meerschaum/config/static/__init__.py +17 -0
- meerschaum/connectors/Connector.py +13 -7
- meerschaum/connectors/__init__.py +28 -15
- meerschaum/connectors/api/APIConnector.py +27 -1
- meerschaum/connectors/api/_actions.py +71 -6
- meerschaum/connectors/api/_jobs.py +368 -0
- meerschaum/connectors/api/_pipes.py +85 -84
- meerschaum/connectors/parse.py +27 -15
- meerschaum/core/Pipe/_bootstrap.py +16 -8
- meerschaum/jobs/_Executor.py +69 -0
- meerschaum/jobs/_Job.py +899 -0
- meerschaum/jobs/__init__.py +396 -0
- meerschaum/jobs/systemd.py +694 -0
- meerschaum/plugins/__init__.py +97 -12
- meerschaum/utils/daemon/Daemon.py +276 -30
- meerschaum/utils/daemon/FileDescriptorInterceptor.py +5 -5
- meerschaum/utils/daemon/RotatingFile.py +14 -7
- meerschaum/utils/daemon/StdinFile.py +121 -0
- meerschaum/utils/daemon/__init__.py +15 -7
- meerschaum/utils/daemon/_names.py +15 -13
- meerschaum/utils/formatting/__init__.py +2 -1
- meerschaum/utils/formatting/_jobs.py +115 -62
- meerschaum/utils/formatting/_shell.py +6 -0
- meerschaum/utils/misc.py +41 -22
- meerschaum/utils/packages/_packages.py +9 -6
- meerschaum/utils/process.py +9 -9
- meerschaum/utils/prompt.py +16 -8
- meerschaum/utils/venv/__init__.py +2 -2
- {meerschaum-2.2.7.dist-info → meerschaum-2.3.0.dist-info}/METADATA +22 -25
- {meerschaum-2.2.7.dist-info → meerschaum-2.3.0.dist-info}/RECORD +70 -61
- {meerschaum-2.2.7.dist-info → meerschaum-2.3.0.dist-info}/WHEEL +1 -1
- {meerschaum-2.2.7.dist-info → meerschaum-2.3.0.dist-info}/LICENSE +0 -0
- {meerschaum-2.2.7.dist-info → meerschaum-2.3.0.dist-info}/NOTICE +0 -0
- {meerschaum-2.2.7.dist-info → meerschaum-2.3.0.dist-info}/entry_points.txt +0 -0
- {meerschaum-2.2.7.dist-info → meerschaum-2.3.0.dist-info}/top_level.txt +0 -0
- {meerschaum-2.2.7.dist-info → meerschaum-2.3.0.dist-info}/zip-safe +0 -0
meerschaum/actions/install.py
CHANGED
@@ -10,9 +10,9 @@ from __future__ import annotations
|
|
10
10
|
from meerschaum.utils.typing import List, Any, SuccessTuple, Optional, Union
|
11
11
|
|
12
12
|
def install(
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
action: Optional[List[str]] = None,
|
14
|
+
**kw: Any
|
15
|
+
) -> SuccessTuple:
|
16
16
|
"""
|
17
17
|
Install Meerschaum plugins or Python packages.
|
18
18
|
"""
|
@@ -26,9 +26,9 @@ def install(
|
|
26
26
|
|
27
27
|
|
28
28
|
def _complete_install(
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
action: Optional[List[str]] = None,
|
30
|
+
**kw: Any
|
31
|
+
) -> List[str]:
|
32
32
|
"""
|
33
33
|
Override the default Meerschaum `complete_` function.
|
34
34
|
"""
|
@@ -52,13 +52,13 @@ def _complete_install(
|
|
52
52
|
|
53
53
|
|
54
54
|
def _install_plugins(
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
55
|
+
action: Optional[List[str]] = None,
|
56
|
+
repository: Optional[str] = None,
|
57
|
+
skip_deps: bool = False,
|
58
|
+
force: bool = False,
|
59
|
+
debug: bool = False,
|
60
|
+
**kw: Any
|
61
|
+
) -> SuccessTuple:
|
62
62
|
"""
|
63
63
|
Install a plugin.
|
64
64
|
|
@@ -103,10 +103,10 @@ def _install_plugins(
|
|
103
103
|
|
104
104
|
|
105
105
|
def _complete_install_plugins(
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
action: Optional[List[str]] = None,
|
107
|
+
repository: Optional[str] = None,
|
108
|
+
**kw: Any
|
109
|
+
) -> List[str]:
|
110
110
|
"""
|
111
111
|
Search for plugins to autocomplete command line text.
|
112
112
|
NOTE: Disabled for the time being so we don't interrupt the user typing.
|
@@ -143,12 +143,12 @@ class NoVenv:
|
|
143
143
|
pass
|
144
144
|
|
145
145
|
def _install_packages(
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
146
|
+
action: Optional[List[str]] = None,
|
147
|
+
sub_args: Optional[List[str]] = None,
|
148
|
+
venv: Union[str, NoVenv] = NoVenv,
|
149
|
+
debug: bool = False,
|
150
|
+
**kw: Any
|
151
|
+
) -> SuccessTuple:
|
152
152
|
"""
|
153
153
|
Install PyPI packages into the Meerschaum virtual environment.
|
154
154
|
|
@@ -179,19 +179,17 @@ def _install_packages(
|
|
179
179
|
)
|
180
180
|
|
181
181
|
|
182
|
-
def _complete_install_packages(
|
183
|
-
**kw : Any
|
184
|
-
) -> List[str]:
|
182
|
+
def _complete_install_packages(**kw : Any) -> List[str]:
|
185
183
|
return []
|
186
184
|
|
187
185
|
|
188
186
|
def _install_required(
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
187
|
+
action: Optional[List[str]] = None,
|
188
|
+
repository: Optional[str] = None,
|
189
|
+
force: bool = False,
|
190
|
+
debug: bool = False,
|
191
|
+
**kw
|
192
|
+
) -> SuccessTuple:
|
195
193
|
"""
|
196
194
|
Install the required packages for Meerschaum plugins.
|
197
195
|
Each plugin's packages will be installed into its virtual environment.
|
@@ -237,6 +235,16 @@ def _complete_install_required(*args, **kw) -> List[str]:
|
|
237
235
|
return _complete_uninstall_plugins(*args, **kw)
|
238
236
|
|
239
237
|
|
238
|
+
def _install_systemd(
|
239
|
+
action: Optional[List[str]] = None,
|
240
|
+
**kwargs: Any
|
241
|
+
) -> SuccessTuple:
|
242
|
+
"""
|
243
|
+
Install the Meerschaum job monitor as a systemd service.
|
244
|
+
"""
|
245
|
+
import sys
|
246
|
+
|
247
|
+
|
240
248
|
### NOTE: This must be the final statement of the module.
|
241
249
|
### Any subactions added below these lines will not
|
242
250
|
### be added to the `help` docstring.
|
meerschaum/actions/pause.py
CHANGED
@@ -27,13 +27,20 @@ def _complete_pause(
|
|
27
27
|
"""
|
28
28
|
Override the default Meerschaum `complete_` function.
|
29
29
|
"""
|
30
|
-
from meerschaum.actions.
|
30
|
+
from meerschaum.actions.delete import _complete_delete_jobs
|
31
|
+
from functools import partial
|
32
|
+
|
31
33
|
if action is None:
|
32
34
|
action = []
|
33
35
|
|
36
|
+
_complete_pause_jobs = partial(
|
37
|
+
_complete_delete_jobs,
|
38
|
+
_get_job_method='running',
|
39
|
+
)
|
40
|
+
|
34
41
|
options = {
|
35
|
-
'job'
|
36
|
-
'jobs'
|
42
|
+
'job': _complete_pause_jobs,
|
43
|
+
'jobs': _complete_pause_jobs,
|
37
44
|
}
|
38
45
|
|
39
46
|
if (
|
@@ -49,43 +56,53 @@ def _complete_pause(
|
|
49
56
|
|
50
57
|
|
51
58
|
def _pause_jobs(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
+
action: Optional[List[str]] = None,
|
60
|
+
executor_keys: Optional[str] = None,
|
61
|
+
noask: bool = False,
|
62
|
+
force: bool = False,
|
63
|
+
yes: bool = False,
|
64
|
+
nopretty: bool = False,
|
65
|
+
debug: bool = False,
|
66
|
+
**kw
|
67
|
+
) -> SuccessTuple:
|
59
68
|
"""
|
60
|
-
Pause running jobs
|
61
|
-
|
62
|
-
To see running jobs, run `show jobs`.
|
69
|
+
Pause (suspend) running jobs.
|
63
70
|
"""
|
64
71
|
from meerschaum.utils.formatting._jobs import pprint_jobs
|
65
72
|
from meerschaum.utils.daemon import (
|
66
73
|
get_filtered_daemons, get_running_daemons, get_stopped_daemons, get_paused_daemons,
|
67
74
|
)
|
75
|
+
from meerschaum.jobs import (
|
76
|
+
get_filtered_jobs,
|
77
|
+
get_running_jobs,
|
78
|
+
get_stopped_jobs,
|
79
|
+
get_paused_jobs,
|
80
|
+
)
|
68
81
|
from meerschaum.utils.warnings import warn
|
69
82
|
from meerschaum.utils.prompt import yes_no
|
70
83
|
from meerschaum.utils.misc import items_str
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
84
|
+
|
85
|
+
jobs = get_filtered_jobs(executor_keys, action, debug=debug, warn=(not nopretty))
|
86
|
+
running_jobs = get_running_jobs(executor_keys, jobs, debug=debug)
|
87
|
+
paused_jobs = get_paused_jobs(executor_keys, jobs, debug=debug)
|
88
|
+
stopped_jobs = get_stopped_jobs(executor_keys, jobs, debug=debug)
|
89
|
+
|
90
|
+
if action and stopped_jobs and not nopretty:
|
76
91
|
warn(
|
77
|
-
f"Skipping stopped job" + ("s" if len(
|
78
|
-
|
79
|
-
|
92
|
+
f"Skipping stopped job" + ("s" if len(stopped_jobs) > 1 else '')
|
93
|
+
+ " '"
|
94
|
+
+ ("', '".join(stopped_jobs.keys()))
|
95
|
+
+ "'.",
|
96
|
+
stack=False,
|
80
97
|
)
|
81
98
|
|
82
|
-
|
83
|
-
if not
|
99
|
+
jobs_to_pause = {**running_jobs, **paused_jobs}
|
100
|
+
if not jobs_to_pause:
|
84
101
|
return False, "No running jobs to pause. You can start jobs with `-d` or `start jobs`."
|
85
102
|
|
86
103
|
if not action:
|
87
104
|
if not force:
|
88
|
-
pprint_jobs(
|
105
|
+
pprint_jobs(running_jobs)
|
89
106
|
if not yes_no(
|
90
107
|
"Pause all running jobs?",
|
91
108
|
noask=noask, yes=yes, default='n'
|
@@ -93,9 +110,9 @@ def _pause_jobs(
|
|
93
110
|
return False, "No jobs were paused."
|
94
111
|
|
95
112
|
successes, fails = [], []
|
96
|
-
for
|
97
|
-
pause_success, pause_msg =
|
98
|
-
(successes if pause_success else fails).append(
|
113
|
+
for name, job in jobs_to_pause.items():
|
114
|
+
pause_success, pause_msg = job.pause()
|
115
|
+
(successes if pause_success else fails).append(name)
|
99
116
|
|
100
117
|
msg = (
|
101
118
|
(
|
@@ -0,0 +1,107 @@
|
|
1
|
+
#! /usr/bin/env python3
|
2
|
+
# vim:fenc=utf-8
|
3
|
+
|
4
|
+
"""
|
5
|
+
Restart stopped jobs which have not been manually stopped.
|
6
|
+
"""
|
7
|
+
|
8
|
+
from meerschaum.utils.typing import SuccessTuple, Optional, List, Any
|
9
|
+
|
10
|
+
def restart(
|
11
|
+
action: Optional[List[str]] = None,
|
12
|
+
executor_keys: Optional[str] = None,
|
13
|
+
**kwargs: Any
|
14
|
+
) -> SuccessTuple:
|
15
|
+
"""
|
16
|
+
Restart stopped jobs which have not been manually stopped.
|
17
|
+
"""
|
18
|
+
from meerschaum.actions import choose_subaction
|
19
|
+
attach_options = {
|
20
|
+
'jobs': _restart_jobs,
|
21
|
+
}
|
22
|
+
return choose_subaction(action, attach_options, executor_keys=executor_keys, **kwargs)
|
23
|
+
|
24
|
+
|
25
|
+
def _complete_restart(
|
26
|
+
action: Optional[List[str]] = None,
|
27
|
+
**kw: Any
|
28
|
+
) -> List[str]:
|
29
|
+
"""
|
30
|
+
Override the default Meerschaum `complete_` function.
|
31
|
+
"""
|
32
|
+
from functools import partial
|
33
|
+
from meerschaum.actions.delete import _complete_delete_jobs
|
34
|
+
|
35
|
+
if action is None:
|
36
|
+
action = []
|
37
|
+
|
38
|
+
_complete_restart_jobs = partial(
|
39
|
+
_complete_delete_jobs,
|
40
|
+
_get_job_method='restart',
|
41
|
+
)
|
42
|
+
|
43
|
+
options = {
|
44
|
+
'job': _complete_restart_jobs,
|
45
|
+
'jobs': _complete_restart_jobs,
|
46
|
+
}
|
47
|
+
|
48
|
+
if (
|
49
|
+
len(action) > 0 and action[0] in options
|
50
|
+
and kw.get('line', '').split(' ')[-1] != action[0]
|
51
|
+
):
|
52
|
+
sub = action[0]
|
53
|
+
del action[0]
|
54
|
+
return options[sub](action=action, **kw)
|
55
|
+
|
56
|
+
from meerschaum._internal.shell import default_action_completer
|
57
|
+
return default_action_completer(action=(['restart'] + action), **kw)
|
58
|
+
|
59
|
+
|
60
|
+
def _restart_jobs(
|
61
|
+
action: Optional[List[str]] = None,
|
62
|
+
executor_keys: Optional[str] = None,
|
63
|
+
loop: bool = False,
|
64
|
+
min_seconds: Optional[float] = 1.0,
|
65
|
+
debug: bool = False,
|
66
|
+
**kwargs: Any
|
67
|
+
) -> SuccessTuple:
|
68
|
+
"""
|
69
|
+
Restart stopped jobs which have not been manually stopped.
|
70
|
+
"""
|
71
|
+
import time
|
72
|
+
from meerschaum.jobs import (
|
73
|
+
get_restart_jobs,
|
74
|
+
get_filtered_jobs,
|
75
|
+
check_restart_jobs,
|
76
|
+
)
|
77
|
+
from meerschaum.utils.misc import items_str
|
78
|
+
from meerschaum.utils.warnings import info
|
79
|
+
action = action or []
|
80
|
+
|
81
|
+
while True:
|
82
|
+
jobs = get_filtered_jobs(executor_keys, action, include_hidden=True, debug=debug)
|
83
|
+
restart_jobs = get_restart_jobs(executor_keys, jobs, debug=debug) if not action else jobs
|
84
|
+
if not restart_jobs and not loop:
|
85
|
+
return True, "No jobs need to be restarted."
|
86
|
+
|
87
|
+
info(
|
88
|
+
"Checking job"
|
89
|
+
+ ('s' if len(restart_jobs) != 1 else '')
|
90
|
+
+ ' '
|
91
|
+
+ items_str(list(restart_jobs.keys()))
|
92
|
+
+ '...'
|
93
|
+
)
|
94
|
+
|
95
|
+
check_success, check_msg = check_restart_jobs(
|
96
|
+
executor_keys,
|
97
|
+
restart_jobs,
|
98
|
+
debug=debug,
|
99
|
+
)
|
100
|
+
if not loop:
|
101
|
+
break
|
102
|
+
|
103
|
+
if min_seconds is not None and min_seconds != 0.0:
|
104
|
+
info(f"Sleeping for {min_seconds} seconds...")
|
105
|
+
time.sleep(min_seconds)
|
106
|
+
|
107
|
+
return check_success, check_msg
|