meerschaum 2.2.5.dev0__py3-none-any.whl → 2.2.5.dev3__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/_internal/arguments/_parse_arguments.py +23 -14
- meerschaum/_internal/arguments/_parser.py +4 -2
- meerschaum/_internal/docs/index.py +31 -125
- meerschaum/_internal/shell/Shell.py +0 -3
- meerschaum/actions/bootstrap.py +14 -235
- meerschaum/actions/edit.py +98 -15
- meerschaum/actions/show.py +13 -4
- meerschaum/actions/stack.py +12 -12
- meerschaum/actions/uninstall.py +24 -29
- meerschaum/api/__init__.py +0 -1
- meerschaum/api/dash/__init__.py +0 -1
- meerschaum/api/dash/callbacks/custom.py +1 -1
- meerschaum/api/dash/plugins.py +5 -6
- meerschaum/config/__init__.py +16 -6
- meerschaum/config/_version.py +1 -1
- meerschaum/core/Pipe/_fetch.py +25 -21
- meerschaum/core/Pipe/_sync.py +89 -59
- meerschaum/plugins/bootstrap.py +333 -0
- meerschaum/utils/formatting/__init__.py +22 -10
- meerschaum/utils/prompt.py +11 -4
- meerschaum/utils/warnings.py +1 -0
- {meerschaum-2.2.5.dev0.dist-info → meerschaum-2.2.5.dev3.dist-info}/METADATA +1 -1
- {meerschaum-2.2.5.dev0.dist-info → meerschaum-2.2.5.dev3.dist-info}/RECORD +29 -29
- meerschaum/actions/backup.py +0 -43
- {meerschaum-2.2.5.dev0.dist-info → meerschaum-2.2.5.dev3.dist-info}/LICENSE +0 -0
- {meerschaum-2.2.5.dev0.dist-info → meerschaum-2.2.5.dev3.dist-info}/NOTICE +0 -0
- {meerschaum-2.2.5.dev0.dist-info → meerschaum-2.2.5.dev3.dist-info}/WHEEL +0 -0
- {meerschaum-2.2.5.dev0.dist-info → meerschaum-2.2.5.dev3.dist-info}/entry_points.txt +0 -0
- {meerschaum-2.2.5.dev0.dist-info → meerschaum-2.2.5.dev3.dist-info}/top_level.txt +0 -0
- {meerschaum-2.2.5.dev0.dist-info → meerschaum-2.2.5.dev3.dist-info}/zip-safe +0 -0
meerschaum/actions/edit.py
CHANGED
@@ -7,6 +7,7 @@ Functions for editing elements belong here.
|
|
7
7
|
"""
|
8
8
|
|
9
9
|
from __future__ import annotations
|
10
|
+
import meerschaum as mrsm
|
10
11
|
from meerschaum.utils.typing import List, Any, SuccessTuple, Optional, Dict
|
11
12
|
|
12
13
|
def edit(
|
@@ -22,19 +23,22 @@ def edit(
|
|
22
23
|
'pipes' : _edit_pipes,
|
23
24
|
'definition': _edit_definition,
|
24
25
|
'users' : _edit_users,
|
26
|
+
'plugins' : _edit_plugins,
|
25
27
|
}
|
26
28
|
return choose_subaction(action, options, **kw)
|
27
29
|
|
28
30
|
|
29
31
|
def _complete_edit(
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
action: Optional[List[str]] = None,
|
33
|
+
**kw: Any
|
34
|
+
) -> List[str]:
|
33
35
|
"""
|
34
36
|
Override the default Meerschaum `complete_` function.
|
35
37
|
"""
|
36
38
|
options = {
|
37
39
|
'config': _complete_edit_config,
|
40
|
+
'plugin': _complete_edit_plugins,
|
41
|
+
'plugins': _complete_edit_plugins,
|
38
42
|
}
|
39
43
|
|
40
44
|
if action is None:
|
@@ -78,7 +82,7 @@ def _edit_config(action : Optional[List[str]] = None, **kw : Any) -> SuccessTupl
|
|
78
82
|
action.append('meerschaum')
|
79
83
|
return edit_config(keys=action, **kw)
|
80
84
|
|
81
|
-
def _complete_edit_config(action: Optional[List[str]] = None, **kw
|
85
|
+
def _complete_edit_config(action: Optional[List[str]] = None, **kw: Any) -> List[str]:
|
82
86
|
from meerschaum.config._read_config import get_possible_keys
|
83
87
|
keys = get_possible_keys()
|
84
88
|
if not action:
|
@@ -172,9 +176,9 @@ def _edit_pipes(
|
|
172
176
|
|
173
177
|
|
174
178
|
def _edit_definition(
|
175
|
-
|
176
|
-
|
177
|
-
|
179
|
+
action: Optional[List[str]] = None,
|
180
|
+
**kw
|
181
|
+
) -> SuccessTuple:
|
178
182
|
"""
|
179
183
|
Edit pipes' definitions.
|
180
184
|
Alias for `edit pipes definition`.
|
@@ -183,13 +187,13 @@ def _edit_definition(
|
|
183
187
|
|
184
188
|
|
185
189
|
def _edit_users(
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
190
|
+
action: Optional[List[str]] = None,
|
191
|
+
mrsm_instance: Optional[str] = None,
|
192
|
+
yes: bool = False,
|
193
|
+
noask: bool = False,
|
194
|
+
debug: bool = False,
|
195
|
+
**kw: Any
|
196
|
+
) -> SuccessTuple:
|
193
197
|
"""
|
194
198
|
Edit users' registration information.
|
195
199
|
"""
|
@@ -262,7 +266,7 @@ def _edit_users(
|
|
262
266
|
if not action:
|
263
267
|
return False, "No users to edit."
|
264
268
|
|
265
|
-
success =
|
269
|
+
success = {}
|
266
270
|
for username in action:
|
267
271
|
try:
|
268
272
|
user = build_user(username)
|
@@ -289,6 +293,85 @@ def _edit_users(
|
|
289
293
|
info(msg)
|
290
294
|
return True, msg
|
291
295
|
|
296
|
+
|
297
|
+
def _edit_plugins(
|
298
|
+
action: Optional[List[str]] = None,
|
299
|
+
debug: bool = False,
|
300
|
+
**kwargs: Any
|
301
|
+
):
|
302
|
+
"""
|
303
|
+
Edit a plugin's source code.
|
304
|
+
"""
|
305
|
+
import pathlib
|
306
|
+
from meerschaum.utils.warnings import warn
|
307
|
+
from meerschaum.utils.prompt import prompt, yes_no
|
308
|
+
from meerschaum.utils.misc import edit_file
|
309
|
+
from meerschaum.utils.packages import reload_meerschaum
|
310
|
+
from meerschaum.actions import actions
|
311
|
+
|
312
|
+
if not action:
|
313
|
+
return False, "Specify which plugin to edit."
|
314
|
+
|
315
|
+
for plugin_name in action:
|
316
|
+
plugin = mrsm.Plugin(plugin_name)
|
317
|
+
|
318
|
+
if not plugin.is_installed():
|
319
|
+
warn(f"Plugin '{plugin_name}' is not installed.", stack=False)
|
320
|
+
|
321
|
+
if not yes_no(
|
322
|
+
f"Would you like to create a new plugin '{plugin_name}'?",
|
323
|
+
**kwargs
|
324
|
+
):
|
325
|
+
return False, f"Plugin '{plugin_name}' does not exist."
|
326
|
+
|
327
|
+
actions['bootstrap'](
|
328
|
+
['plugins', plugin_name],
|
329
|
+
debug = debug,
|
330
|
+
**kwargs
|
331
|
+
)
|
332
|
+
continue
|
333
|
+
|
334
|
+
plugin_file_path = pathlib.Path(plugin.__file__).resolve()
|
335
|
+
|
336
|
+
try:
|
337
|
+
_ = prompt(f"Press [Enter] to open '{plugin_file_path}':", icon=False)
|
338
|
+
except (KeyboardInterrupt, Exception):
|
339
|
+
continue
|
340
|
+
|
341
|
+
edit_file(plugin_file_path)
|
342
|
+
reload_meerschaum(debug=debug)
|
343
|
+
|
344
|
+
return True, "Success"
|
345
|
+
|
346
|
+
|
347
|
+
def _complete_edit_plugins(
|
348
|
+
action: Optional[List[str]] = None,
|
349
|
+
line: Optional[str] = None,
|
350
|
+
**kw: Any
|
351
|
+
) -> List[str]:
|
352
|
+
from meerschaum.plugins import get_plugins_names
|
353
|
+
plugins_names = get_plugins_names(try_import=False)
|
354
|
+
if not action:
|
355
|
+
return plugins_names
|
356
|
+
|
357
|
+
last_word = action[-1]
|
358
|
+
if last_word in plugins_names and (line or '')[-1] == ' ':
|
359
|
+
return [
|
360
|
+
plugin_name
|
361
|
+
for plugin_name in plugins_names
|
362
|
+
if plugin_name not in action
|
363
|
+
]
|
364
|
+
|
365
|
+
possibilities = []
|
366
|
+
for plugin_name in plugins_names:
|
367
|
+
if (
|
368
|
+
plugin_name.startswith(last_word)
|
369
|
+
and plugin_name not in action
|
370
|
+
):
|
371
|
+
possibilities.append(plugin_name)
|
372
|
+
return possibilities
|
373
|
+
|
374
|
+
|
292
375
|
### NOTE: This must be the final statement of the module.
|
293
376
|
### Any subactions added below these lines will not
|
294
377
|
### be added to the `help` docstring.
|
meerschaum/actions/show.py
CHANGED
@@ -219,15 +219,24 @@ def _show_connectors(
|
|
219
219
|
from meerschaum.config import get_config
|
220
220
|
from meerschaum.utils.formatting import make_header
|
221
221
|
from meerschaum.utils.formatting import pprint
|
222
|
+
|
223
|
+
conn_type = action[0].split(':')[0] if action else None
|
224
|
+
|
222
225
|
if not nopretty:
|
223
|
-
print(make_header(
|
224
|
-
|
225
|
-
|
226
|
+
print(make_header(
|
227
|
+
f"""\nConfigured {"'" + (conn_type + "' ") if conn_type else ''}Connectors:"""
|
228
|
+
))
|
229
|
+
|
230
|
+
keys = ['meerschaum', 'connectors']
|
231
|
+
if conn_type:
|
232
|
+
keys.append(conn_type)
|
233
|
+
pprint(get_config(*keys), nopretty=nopretty)
|
234
|
+
if not nopretty and not conn_type:
|
226
235
|
print(make_header("\nActive connectors:"))
|
227
236
|
pprint(connectors, nopretty=nopretty)
|
228
237
|
|
229
238
|
from meerschaum.connectors.parse import parse_instance_keys
|
230
|
-
if action:
|
239
|
+
if action and ':' in action[0]:
|
231
240
|
attr, keys = parse_instance_keys(action[0], construct=False, as_tuple=True, debug=debug)
|
232
241
|
if attr:
|
233
242
|
if not nopretty:
|
meerschaum/actions/stack.py
CHANGED
@@ -7,7 +7,7 @@ Functions for running the Docker Compose stack
|
|
7
7
|
"""
|
8
8
|
|
9
9
|
from __future__ import annotations
|
10
|
-
from meerschaum.utils.typing import SuccessTuple, Any, List, Optional
|
10
|
+
from meerschaum.utils.typing import SuccessTuple, Any, List, Optional, Union
|
11
11
|
|
12
12
|
def stack(
|
13
13
|
action: Optional[List[str]] = None,
|
@@ -19,7 +19,7 @@ def stack(
|
|
19
19
|
debug: bool = False,
|
20
20
|
_capture_output: bool = False,
|
21
21
|
**kw: Any
|
22
|
-
) -> SuccessTuple:
|
22
|
+
) -> Union[SuccessTuple, 'subprocess.Popen']:
|
23
23
|
"""
|
24
24
|
Control the Meerschaum stack with Docker Compose.
|
25
25
|
Usage: `stack {command}`
|
@@ -147,18 +147,18 @@ def stack(
|
|
147
147
|
['docker', 'compose'] if has_builtin_compose
|
148
148
|
else ['docker-compose']
|
149
149
|
) + cmd_list,
|
150
|
-
cwd
|
151
|
-
stdout
|
152
|
-
stderr
|
153
|
-
env
|
150
|
+
cwd=STACK_COMPOSE_PATH.parent,
|
151
|
+
stdout=stdout,
|
152
|
+
stderr=stderr,
|
153
|
+
env=stack_env_dict,
|
154
154
|
) if (has_builtin_compose or has_binary_compose) else run_python_package(
|
155
155
|
'compose',
|
156
|
-
args
|
157
|
-
cwd
|
158
|
-
venv
|
159
|
-
capture_output
|
160
|
-
as_proc
|
161
|
-
env
|
156
|
+
args=cmd_list,
|
157
|
+
cwd=STACK_COMPOSE_PATH.parent,
|
158
|
+
venv=_compose_venv,
|
159
|
+
capture_output=_capture_output,
|
160
|
+
as_proc=True,
|
161
|
+
env=stack_env_dict,
|
162
162
|
)
|
163
163
|
try:
|
164
164
|
rc = proc.wait() if proc is not None else 1
|
meerschaum/actions/uninstall.py
CHANGED
@@ -25,9 +25,9 @@ def uninstall(
|
|
25
25
|
|
26
26
|
|
27
27
|
def _complete_uninstall(
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
action: Optional[List[str]] = None,
|
29
|
+
**kw: Any
|
30
|
+
) -> List[str]:
|
31
31
|
"""
|
32
32
|
Override the default Meerschaum `complete_` function.
|
33
33
|
"""
|
@@ -49,15 +49,16 @@ def _complete_uninstall(
|
|
49
49
|
from meerschaum._internal.shell import default_action_completer
|
50
50
|
return default_action_completer(action=(['uninstall'] + action), **kw)
|
51
51
|
|
52
|
+
|
52
53
|
def _uninstall_plugins(
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
54
|
+
action: Optional[List[str]] = None,
|
55
|
+
repository: Optional[str] = None,
|
56
|
+
yes: bool = False,
|
57
|
+
force: bool = False,
|
58
|
+
noask: bool = False,
|
59
|
+
debug: bool = False,
|
60
|
+
**kw: Any
|
61
|
+
) -> SuccessTuple:
|
61
62
|
"""
|
62
63
|
Remove installed plugins. Does not affect repository registrations.
|
63
64
|
"""
|
@@ -135,26 +136,20 @@ def _uninstall_plugins(
|
|
135
136
|
|
136
137
|
|
137
138
|
def _complete_uninstall_plugins(action: Optional[List[str]] = None, **kw) -> List[str]:
|
138
|
-
from meerschaum.
|
139
|
-
|
140
|
-
|
141
|
-
return _plugin_names
|
142
|
-
possibilities = []
|
143
|
-
for name in _plugin_names:
|
144
|
-
if name.startswith(action[0]) and action[0] != name:
|
145
|
-
possibilities.append(name)
|
146
|
-
return possibilities
|
139
|
+
from meerschaum.actions.edit import _complete_edit_plugins
|
140
|
+
return _complete_edit_plugins(action=action, **kw)
|
141
|
+
|
147
142
|
|
148
143
|
def _uninstall_packages(
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
144
|
+
action: Optional[List[str]] = None,
|
145
|
+
sub_args: Optional[List[str]] = None,
|
146
|
+
venv: Optional[str] = 'mrsm',
|
147
|
+
yes: bool = False,
|
148
|
+
force: bool = False,
|
149
|
+
noask: bool = False,
|
150
|
+
debug: bool = False,
|
151
|
+
**kw: Any
|
152
|
+
) -> SuccessTuple:
|
158
153
|
"""
|
159
154
|
Uninstall PyPI packages from the Meerschaum virtual environment.
|
160
155
|
|
meerschaum/api/__init__.py
CHANGED
meerschaum/api/dash/__init__.py
CHANGED
meerschaum/api/dash/plugins.py
CHANGED
@@ -7,7 +7,7 @@ Functions for interacting with plugins via the web interface.
|
|
7
7
|
"""
|
8
8
|
|
9
9
|
from __future__ import annotations
|
10
|
-
from meerschaum.utils.typing import List, Tuple, SuccessTuple
|
10
|
+
from meerschaum.utils.typing import List, Tuple, SuccessTuple, Optional, WebState, Dict, Any
|
11
11
|
from meerschaum.utils.packages import import_dcc, import_html
|
12
12
|
from meerschaum.api import get_api_connector, endpoints, CHECK_UPDATE
|
13
13
|
html, dcc = import_html(check_update=CHECK_UPDATE), import_dcc(check_update=CHECK_UPDATE)
|
@@ -17,10 +17,10 @@ from meerschaum.api.dash import dash_app, debug, active_sessions
|
|
17
17
|
|
18
18
|
|
19
19
|
def get_plugins_cards(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
state: Optional[WebState] = None,
|
21
|
+
search_term: Optional[str] = None,
|
22
|
+
session_data: Optional[Dict[str, Any]] = None,
|
23
|
+
) -> Tuple[List[dbc.Card], List[SuccessTuple]]:
|
24
24
|
"""
|
25
25
|
Return the cards and alerts for plugins.
|
26
26
|
"""
|
@@ -96,4 +96,3 @@ def is_plugin_owner(plugin_name: str, session_data: Dict['str', Any]) -> bool:
|
|
96
96
|
_username is not None
|
97
97
|
and _username == _plugin_username
|
98
98
|
)
|
99
|
-
|
meerschaum/config/__init__.py
CHANGED
@@ -12,7 +12,7 @@ from __future__ import annotations
|
|
12
12
|
import os, shutil, sys, pathlib, copy
|
13
13
|
from meerschaum.utils.typing import Any, Dict, Optional, Union
|
14
14
|
from meerschaum.utils.threading import RLock
|
15
|
-
from meerschaum.utils.warnings import warn
|
15
|
+
from meerschaum.utils.warnings import warn, error
|
16
16
|
|
17
17
|
from meerschaum.config._version import __version__
|
18
18
|
from meerschaum.config._edit import edit_config, write_config
|
@@ -239,17 +239,28 @@ def get_config(
|
|
239
239
|
return c
|
240
240
|
|
241
241
|
|
242
|
-
def get_plugin_config(
|
242
|
+
def get_plugin_config(
|
243
|
+
*keys: str,
|
244
|
+
warn: bool = False,
|
245
|
+
**kw: Any
|
246
|
+
) -> Optional[Any]:
|
243
247
|
"""
|
244
248
|
This may only be called from within a Meerschaum plugin.
|
245
249
|
See `meerschaum.config.get_config` for arguments.
|
246
250
|
"""
|
247
|
-
from meerschaum.utils.warnings import warn, error
|
248
251
|
from meerschaum.plugins import _get_parent_plugin
|
249
252
|
parent_plugin_name = _get_parent_plugin(2)
|
250
253
|
if parent_plugin_name is None:
|
251
|
-
error(
|
252
|
-
|
254
|
+
error(
|
255
|
+
"You may only call `get_plugin_config()` "
|
256
|
+
"from within a Meerschaum plugin."
|
257
|
+
)
|
258
|
+
|
259
|
+
return get_config(
|
260
|
+
*(['plugins', parent_plugin_name] + list(keys)),
|
261
|
+
warn=warn,
|
262
|
+
**kw
|
263
|
+
)
|
253
264
|
|
254
265
|
|
255
266
|
def write_plugin_config(
|
@@ -259,7 +270,6 @@ def write_plugin_config(
|
|
259
270
|
"""
|
260
271
|
Write a plugin's configuration dictionary.
|
261
272
|
"""
|
262
|
-
from meerschaum.utils.warnings import warn, error
|
263
273
|
from meerschaum.plugins import _get_parent_plugin
|
264
274
|
parent_plugin_name = _get_parent_plugin(2)
|
265
275
|
if parent_plugin_name is None:
|
meerschaum/config/_version.py
CHANGED
meerschaum/core/Pipe/_fetch.py
CHANGED
@@ -12,6 +12,7 @@ import meerschaum as mrsm
|
|
12
12
|
from meerschaum.utils.typing import Optional, Any, Union, SuccessTuple, Iterator
|
13
13
|
from meerschaum.config import get_config
|
14
14
|
from meerschaum.utils.warnings import warn
|
15
|
+
from meerschaum.utils.misc import filter_keywords
|
15
16
|
|
16
17
|
def fetch(
|
17
18
|
self,
|
@@ -75,25 +76,28 @@ def fetch(
|
|
75
76
|
with mrsm.Venv(get_connector_plugin(self.connector)):
|
76
77
|
df = self.connector.fetch(
|
77
78
|
self,
|
78
|
-
|
79
|
-
self,
|
80
|
-
begin
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
79
|
+
**filter_keywords(
|
80
|
+
self.connector.fetch,
|
81
|
+
begin=_determine_begin(
|
82
|
+
self,
|
83
|
+
begin,
|
84
|
+
check_existing=check_existing,
|
85
|
+
debug=debug,
|
86
|
+
),
|
87
|
+
end=end,
|
88
|
+
chunk_hook=_chunk_hook,
|
89
|
+
debug=debug,
|
90
|
+
**kw
|
91
|
+
)
|
88
92
|
)
|
89
93
|
return df
|
90
94
|
|
91
95
|
|
92
96
|
def get_backtrack_interval(
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
+
self,
|
98
|
+
check_existing: bool = True,
|
99
|
+
debug: bool = False,
|
100
|
+
) -> Union[timedelta, int]:
|
97
101
|
"""
|
98
102
|
Get the chunk interval to use for this pipe.
|
99
103
|
|
@@ -127,17 +131,17 @@ def get_backtrack_interval(
|
|
127
131
|
|
128
132
|
|
129
133
|
def _determine_begin(
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
134
|
+
pipe: mrsm.Pipe,
|
135
|
+
begin: Union[datetime, int, str, None] = '',
|
136
|
+
check_existing: bool = True,
|
137
|
+
debug: bool = False,
|
138
|
+
) -> Union[datetime, int, None]:
|
135
139
|
"""
|
136
140
|
Apply the backtrack interval if `--begin` is not provided.
|
137
141
|
|
138
142
|
Parameters
|
139
143
|
----------
|
140
|
-
begin: Union[datetime, int, str], default ''
|
144
|
+
begin: Union[datetime, int, str, None], default ''
|
141
145
|
The provided begin timestamp.
|
142
146
|
|
143
147
|
check_existing: bool, default True
|
@@ -160,4 +164,4 @@ def _determine_begin(
|
|
160
164
|
return sync_time - backtrack_interval
|
161
165
|
except Exception as e:
|
162
166
|
warn(f"Unable to substract backtrack interval {backtrack_interval} from {sync_time}.")
|
163
|
-
|
167
|
+
return sync_time
|