meerschaum 2.9.5__py3-none-any.whl → 3.0.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 +5 -2
- meerschaum/_internal/__init__.py +1 -0
- meerschaum/_internal/arguments/_parse_arguments.py +4 -4
- meerschaum/_internal/arguments/_parser.py +33 -4
- meerschaum/_internal/cli/__init__.py +6 -0
- meerschaum/_internal/cli/daemons.py +103 -0
- meerschaum/_internal/cli/entry.py +220 -0
- meerschaum/_internal/cli/workers.py +435 -0
- meerschaum/_internal/docs/index.py +48 -2
- meerschaum/_internal/entry.py +50 -14
- meerschaum/_internal/shell/Shell.py +121 -29
- meerschaum/_internal/shell/__init__.py +4 -1
- meerschaum/_internal/static.py +359 -0
- meerschaum/_internal/term/TermPageHandler.py +1 -2
- meerschaum/_internal/term/__init__.py +40 -6
- meerschaum/_internal/term/tools.py +33 -8
- meerschaum/actions/__init__.py +6 -4
- meerschaum/actions/api.py +53 -13
- meerschaum/actions/attach.py +1 -0
- meerschaum/actions/bootstrap.py +8 -8
- meerschaum/actions/delete.py +4 -2
- meerschaum/actions/edit.py +171 -25
- meerschaum/actions/login.py +8 -8
- meerschaum/actions/register.py +143 -6
- meerschaum/actions/reload.py +22 -5
- meerschaum/actions/restart.py +14 -0
- meerschaum/actions/show.py +184 -31
- meerschaum/actions/start.py +166 -17
- meerschaum/actions/stop.py +38 -2
- meerschaum/actions/sync.py +7 -2
- meerschaum/actions/tag.py +9 -8
- meerschaum/actions/verify.py +5 -8
- meerschaum/api/__init__.py +45 -15
- meerschaum/api/_events.py +46 -4
- meerschaum/api/_oauth2.py +162 -9
- meerschaum/api/_tokens.py +102 -0
- meerschaum/api/dash/__init__.py +0 -3
- meerschaum/api/dash/callbacks/__init__.py +1 -0
- meerschaum/api/dash/callbacks/custom.py +4 -3
- meerschaum/api/dash/callbacks/dashboard.py +198 -118
- meerschaum/api/dash/callbacks/jobs.py +14 -7
- meerschaum/api/dash/callbacks/login.py +10 -1
- meerschaum/api/dash/callbacks/pipes.py +194 -14
- meerschaum/api/dash/callbacks/plugins.py +0 -1
- meerschaum/api/dash/callbacks/register.py +10 -3
- meerschaum/api/dash/callbacks/settings/password_reset.py +2 -2
- meerschaum/api/dash/callbacks/tokens.py +389 -0
- meerschaum/api/dash/components.py +36 -15
- meerschaum/api/dash/jobs.py +1 -1
- meerschaum/api/dash/keys.py +35 -93
- meerschaum/api/dash/pages/__init__.py +2 -1
- meerschaum/api/dash/pages/dashboard.py +1 -20
- meerschaum/api/dash/pages/{job.py → jobs.py} +10 -7
- meerschaum/api/dash/pages/login.py +2 -2
- meerschaum/api/dash/pages/pipes.py +16 -5
- meerschaum/api/dash/pages/settings/password_reset.py +1 -1
- meerschaum/api/dash/pages/tokens.py +53 -0
- meerschaum/api/dash/pipes.py +382 -95
- meerschaum/api/dash/sessions.py +12 -0
- meerschaum/api/dash/tokens.py +603 -0
- meerschaum/api/dash/websockets.py +1 -1
- meerschaum/api/dash/webterm.py +18 -6
- meerschaum/api/models/__init__.py +23 -3
- meerschaum/api/models/_actions.py +22 -0
- meerschaum/api/models/_pipes.py +91 -7
- meerschaum/api/models/_tokens.py +81 -0
- meerschaum/api/resources/static/js/terminado.js +3 -0
- meerschaum/api/resources/static/js/xterm-addon-unicode11.js +2 -0
- meerschaum/api/resources/templates/termpage.html +13 -0
- meerschaum/api/routes/__init__.py +1 -0
- meerschaum/api/routes/_actions.py +3 -4
- meerschaum/api/routes/_connectors.py +3 -7
- meerschaum/api/routes/_jobs.py +26 -35
- meerschaum/api/routes/_login.py +120 -15
- meerschaum/api/routes/_misc.py +5 -10
- meerschaum/api/routes/_pipes.py +178 -143
- meerschaum/api/routes/_plugins.py +38 -28
- meerschaum/api/routes/_tokens.py +236 -0
- meerschaum/api/routes/_users.py +47 -35
- meerschaum/api/routes/_version.py +3 -3
- meerschaum/api/routes/_webterm.py +3 -3
- meerschaum/config/__init__.py +100 -30
- meerschaum/config/_default.py +132 -64
- meerschaum/config/_edit.py +38 -32
- meerschaum/config/_formatting.py +2 -0
- meerschaum/config/_patch.py +10 -8
- meerschaum/config/_paths.py +133 -13
- meerschaum/config/_read_config.py +87 -36
- meerschaum/config/_sync.py +6 -3
- meerschaum/config/_version.py +1 -1
- meerschaum/config/environment.py +262 -0
- meerschaum/config/stack/__init__.py +37 -15
- meerschaum/config/static.py +18 -0
- meerschaum/connectors/_Connector.py +11 -6
- meerschaum/connectors/__init__.py +41 -22
- meerschaum/connectors/api/_APIConnector.py +34 -6
- meerschaum/connectors/api/_actions.py +2 -2
- meerschaum/connectors/api/_jobs.py +12 -1
- meerschaum/connectors/api/_login.py +33 -7
- meerschaum/connectors/api/_misc.py +2 -2
- meerschaum/connectors/api/_pipes.py +23 -32
- meerschaum/connectors/api/_plugins.py +2 -2
- meerschaum/connectors/api/_request.py +1 -1
- meerschaum/connectors/api/_tokens.py +146 -0
- meerschaum/connectors/api/_users.py +70 -58
- meerschaum/connectors/instance/_InstanceConnector.py +83 -0
- meerschaum/connectors/instance/__init__.py +10 -0
- meerschaum/connectors/instance/_pipes.py +442 -0
- meerschaum/connectors/instance/_plugins.py +159 -0
- meerschaum/connectors/instance/_tokens.py +317 -0
- meerschaum/connectors/instance/_users.py +188 -0
- meerschaum/connectors/parse.py +5 -2
- meerschaum/connectors/sql/_SQLConnector.py +22 -5
- meerschaum/connectors/sql/_cli.py +12 -11
- meerschaum/connectors/sql/_create_engine.py +12 -168
- meerschaum/connectors/sql/_fetch.py +2 -18
- meerschaum/connectors/sql/_pipes.py +295 -278
- meerschaum/connectors/sql/_plugins.py +29 -0
- meerschaum/connectors/sql/_sql.py +46 -21
- meerschaum/connectors/sql/_users.py +36 -2
- meerschaum/connectors/sql/tables/__init__.py +254 -122
- meerschaum/connectors/valkey/_ValkeyConnector.py +5 -7
- meerschaum/connectors/valkey/_pipes.py +60 -31
- meerschaum/connectors/valkey/_plugins.py +2 -26
- meerschaum/core/Pipe/__init__.py +115 -85
- meerschaum/core/Pipe/_attributes.py +425 -124
- meerschaum/core/Pipe/_bootstrap.py +54 -24
- meerschaum/core/Pipe/_cache.py +555 -0
- meerschaum/core/Pipe/_clear.py +0 -11
- meerschaum/core/Pipe/_data.py +96 -68
- meerschaum/core/Pipe/_deduplicate.py +0 -13
- meerschaum/core/Pipe/_delete.py +12 -21
- meerschaum/core/Pipe/_drop.py +11 -23
- meerschaum/core/Pipe/_dtypes.py +49 -19
- meerschaum/core/Pipe/_edit.py +14 -4
- meerschaum/core/Pipe/_fetch.py +1 -1
- meerschaum/core/Pipe/_index.py +8 -14
- meerschaum/core/Pipe/_show.py +5 -5
- meerschaum/core/Pipe/_sync.py +123 -204
- meerschaum/core/Pipe/_verify.py +4 -4
- meerschaum/{plugins → core/Plugin}/_Plugin.py +16 -12
- meerschaum/core/Plugin/__init__.py +1 -1
- meerschaum/core/Token/_Token.py +220 -0
- meerschaum/core/Token/__init__.py +12 -0
- meerschaum/core/User/_User.py +35 -10
- meerschaum/core/User/__init__.py +9 -1
- meerschaum/core/__init__.py +1 -0
- meerschaum/jobs/_Executor.py +88 -4
- meerschaum/jobs/_Job.py +149 -38
- meerschaum/jobs/__init__.py +3 -2
- meerschaum/jobs/systemd.py +8 -3
- meerschaum/models/__init__.py +35 -0
- meerschaum/models/pipes.py +247 -0
- meerschaum/models/tokens.py +38 -0
- meerschaum/models/users.py +26 -0
- meerschaum/plugins/__init__.py +301 -88
- meerschaum/plugins/bootstrap.py +510 -4
- meerschaum/utils/_get_pipes.py +97 -30
- meerschaum/utils/daemon/Daemon.py +199 -43
- meerschaum/utils/daemon/FileDescriptorInterceptor.py +0 -1
- meerschaum/utils/daemon/RotatingFile.py +63 -36
- meerschaum/utils/daemon/StdinFile.py +53 -13
- meerschaum/utils/daemon/__init__.py +47 -6
- meerschaum/utils/daemon/_names.py +6 -3
- meerschaum/utils/dataframe.py +479 -81
- meerschaum/utils/debug.py +49 -19
- meerschaum/utils/dtypes/__init__.py +476 -34
- meerschaum/utils/dtypes/sql.py +369 -29
- meerschaum/utils/formatting/__init__.py +5 -2
- meerschaum/utils/formatting/_jobs.py +1 -1
- meerschaum/utils/formatting/_pipes.py +52 -50
- meerschaum/utils/formatting/_pprint.py +1 -0
- meerschaum/utils/formatting/_shell.py +44 -18
- meerschaum/utils/misc.py +268 -186
- meerschaum/utils/packages/__init__.py +25 -40
- meerschaum/utils/packages/_packages.py +42 -34
- meerschaum/utils/pipes.py +213 -0
- meerschaum/utils/process.py +2 -2
- meerschaum/utils/prompt.py +175 -144
- meerschaum/utils/schedule.py +2 -1
- meerschaum/utils/sql.py +134 -47
- meerschaum/utils/threading.py +42 -0
- meerschaum/utils/typing.py +1 -4
- meerschaum/utils/venv/_Venv.py +2 -2
- meerschaum/utils/venv/__init__.py +7 -7
- meerschaum/utils/warnings.py +19 -13
- {meerschaum-2.9.5.dist-info → meerschaum-3.0.0.dist-info}/METADATA +94 -96
- meerschaum-3.0.0.dist-info/RECORD +289 -0
- {meerschaum-2.9.5.dist-info → meerschaum-3.0.0.dist-info}/WHEEL +1 -1
- meerschaum-3.0.0.dist-info/licenses/NOTICE +2 -0
- meerschaum/api/models/_interfaces.py +0 -15
- meerschaum/api/models/_locations.py +0 -15
- meerschaum/api/models/_metrics.py +0 -15
- meerschaum/config/_environment.py +0 -145
- meerschaum/config/static/__init__.py +0 -186
- meerschaum-2.9.5.dist-info/RECORD +0 -263
- {meerschaum-2.9.5.dist-info → meerschaum-3.0.0.dist-info}/entry_points.txt +0 -0
- {meerschaum-2.9.5.dist-info → meerschaum-3.0.0.dist-info}/licenses/LICENSE +0 -0
- {meerschaum-2.9.5.dist-info → meerschaum-3.0.0.dist-info}/top_level.txt +0 -0
- {meerschaum-2.9.5.dist-info → meerschaum-3.0.0.dist-info}/zip-safe +0 -0
@@ -31,11 +31,13 @@ prompt_toolkit = attempt_import('prompt_toolkit', lazy=False, warn=False, instal
|
|
31
31
|
)
|
32
32
|
from meerschaum._internal.shell.ValidAutoSuggest import ValidAutoSuggest
|
33
33
|
from meerschaum._internal.shell.ShellCompleter import ShellCompleter
|
34
|
+
from meerschaum._internal.cli.daemons import get_cli_daemon, get_cli_session_id
|
34
35
|
_clear_screen = get_config('shell', 'clear_screen', patch=True)
|
35
36
|
from meerschaum.utils.misc import string_width, remove_ansi
|
36
37
|
from meerschaum.utils.warnings import warn
|
37
38
|
from meerschaum.jobs import get_executor_keys_from_context
|
38
|
-
from meerschaum.
|
39
|
+
from meerschaum._internal.static import STATIC_CONFIG
|
40
|
+
from meerschaum.utils.formatting._shell import clear_screen, flush_stdout
|
39
41
|
from meerschaum._internal.arguments._parse_arguments import (
|
40
42
|
split_chained_sysargs,
|
41
43
|
split_pipeline_sysargs,
|
@@ -81,6 +83,7 @@ ESCAPED_AND_KEY: str = STATIC_CONFIG['system']['arguments']['escaped_and_key']
|
|
81
83
|
PIPELINE_KEY: str = STATIC_CONFIG['system']['arguments']['pipeline_key']
|
82
84
|
ESCAPED_PIPELINE_KEY: str = STATIC_CONFIG['system']['arguments']['escaped_pipeline_key']
|
83
85
|
|
86
|
+
|
84
87
|
def _insert_shell_actions(
|
85
88
|
_shell: Optional['Shell'] = None,
|
86
89
|
actions: Optional[Dict[str, Callable[[Any], SuccessTuple]]] = None,
|
@@ -99,6 +102,10 @@ def _insert_shell_actions(
|
|
99
102
|
_shell_class = _shell if _shell is not None else shell_pkg.Shell
|
100
103
|
|
101
104
|
for a, f in actions.items():
|
105
|
+
existing_method = getattr(_shell_class, 'do_' + a, None)
|
106
|
+
if existing_method == f:
|
107
|
+
continue
|
108
|
+
|
102
109
|
add_method_to_class(
|
103
110
|
func = f,
|
104
111
|
class_def = _shell_class,
|
@@ -113,6 +120,35 @@ def _insert_shell_actions(
|
|
113
120
|
setattr(_shell_class, 'complete_' + a, completer)
|
114
121
|
|
115
122
|
|
123
|
+
def _remove_shell_actions(
|
124
|
+
_shell: Optional['Shell'] = None,
|
125
|
+
actions: Optional[Dict[str, Callable[[Any], SuccessTuple]]] = None,
|
126
|
+
) -> None:
|
127
|
+
"""
|
128
|
+
Remove the actions added to the shell.
|
129
|
+
"""
|
130
|
+
import meerschaum._internal.shell as shell_pkg
|
131
|
+
if actions is None:
|
132
|
+
from meerschaum.actions import actions as _actions
|
133
|
+
actions = _actions
|
134
|
+
|
135
|
+
_shell_class = _shell if _shell is not None else shell_pkg.Shell
|
136
|
+
|
137
|
+
for a, f in actions.items():
|
138
|
+
try:
|
139
|
+
delattr(_shell_class, 'do_' + a)
|
140
|
+
except AttributeError:
|
141
|
+
pass
|
142
|
+
|
143
|
+
if a in reserved_completers:
|
144
|
+
continue
|
145
|
+
|
146
|
+
try:
|
147
|
+
delattr(_shell_class, 'complete_' + a)
|
148
|
+
except AttributeError:
|
149
|
+
pass
|
150
|
+
|
151
|
+
|
116
152
|
def _completer_wrapper(
|
117
153
|
target: Callable[[Any], List[str]]
|
118
154
|
) -> Callable[['mrsm._internal.shell.Shell', str, str, int, int], Any]:
|
@@ -294,16 +330,19 @@ class Shell(cmd.Cmd):
|
|
294
330
|
pass
|
295
331
|
|
296
332
|
### NOTE: custom actions must be added to the self._actions dictionary
|
333
|
+
shell_attrs['_session_id'] = get_cli_session_id()
|
297
334
|
shell_attrs['_actions'] = actions
|
298
335
|
shell_attrs['_sysargs'] = sysargs
|
299
336
|
shell_attrs['_actions']['instance'] = self.do_instance
|
300
337
|
shell_attrs['_actions']['repo'] = self.do_repo
|
301
338
|
shell_attrs['_actions']['executor'] = self.do_executor
|
302
339
|
shell_attrs['_actions']['debug'] = self.do_debug
|
340
|
+
shell_attrs['_actions']['daemon'] = self.do_daemon
|
303
341
|
shell_attrs['_update_bottom_toolbar'] = True
|
304
342
|
shell_attrs['_old_bottom_toolbar'] = ''
|
305
343
|
shell_attrs['debug'] = False
|
306
344
|
shell_attrs['_reload'] = True
|
345
|
+
shell_attrs['daemon'] = get_config('system', 'experimental', 'cli_daemon')
|
307
346
|
self.load_config(instance=instance_keys)
|
308
347
|
self.hidden_commands = []
|
309
348
|
### update hidden commands list (cmd2 only)
|
@@ -353,7 +392,7 @@ class Shell(cmd.Cmd):
|
|
353
392
|
shell_attrs['instance'] = instance
|
354
393
|
shell_attrs['instance_keys'] = remove_ansi(str(instance))
|
355
394
|
if shell_attrs.get('repo_keys', None) is None:
|
356
|
-
shell_attrs['repo_keys'] = get_config('meerschaum', '
|
395
|
+
shell_attrs['repo_keys'] = get_config('meerschaum', 'repository', patch=patch)
|
357
396
|
if shell_attrs.get('executor_keys', None) is None:
|
358
397
|
shell_attrs['executor_keys'] = get_executor_keys_from_context()
|
359
398
|
|
@@ -496,8 +535,7 @@ class Shell(cmd.Cmd):
|
|
496
535
|
)
|
497
536
|
)
|
498
537
|
shell_attrs['prompt'] = self.prompt
|
499
|
-
|
500
|
-
print("", end="", flush=True)
|
538
|
+
flush_stdout()
|
501
539
|
|
502
540
|
|
503
541
|
def precmd(self, line: str):
|
@@ -530,7 +568,6 @@ class Shell(cmd.Cmd):
|
|
530
568
|
|
531
569
|
### if the user specifies, clear the screen before executing any commands
|
532
570
|
if _clear_screen:
|
533
|
-
from meerschaum.utils.formatting._shell import clear_screen
|
534
571
|
clear_screen(debug=shell_attrs['debug'])
|
535
572
|
|
536
573
|
### return blank commands (spaces break argparse)
|
@@ -618,7 +655,7 @@ class Shell(cmd.Cmd):
|
|
618
655
|
if key == 'mrsm_instance':
|
619
656
|
default_value = get_config('meerschaum', 'instance')
|
620
657
|
elif key == 'repository':
|
621
|
-
default_value = get_config('meerschaum', '
|
658
|
+
default_value = get_config('meerschaum', 'repository')
|
622
659
|
elif key == 'executor_keys':
|
623
660
|
default_value = get_executor_keys_from_context()
|
624
661
|
else:
|
@@ -672,7 +709,12 @@ class Shell(cmd.Cmd):
|
|
672
709
|
([':'] + pipeline_args) if pipeline_args else []
|
673
710
|
)
|
674
711
|
try:
|
675
|
-
success_tuple = entry(
|
712
|
+
success_tuple = entry(
|
713
|
+
sysargs_to_execute,
|
714
|
+
_patch_args=patch_args,
|
715
|
+
_session_id=shell_attrs.get('session_id', None),
|
716
|
+
_use_cli_daemon=shell_attrs.get('daemon', False),
|
717
|
+
)
|
676
718
|
except Exception as e:
|
677
719
|
success_tuple = False, str(e)
|
678
720
|
|
@@ -732,6 +774,35 @@ class Shell(cmd.Cmd):
|
|
732
774
|
|
733
775
|
info(f"Debug mode is {'on' if shell_attrs['debug'] else 'off'}.")
|
734
776
|
|
777
|
+
def do_daemon(self, action: Optional[List[str]] = None, executor_keys=None, **kw):
|
778
|
+
"""
|
779
|
+
Toggle whether to route commands through the CLI daemon.
|
780
|
+
|
781
|
+
Command:
|
782
|
+
`debug {on/true | off/false}`
|
783
|
+
Ommitting on / off will toggle the existing value.
|
784
|
+
"""
|
785
|
+
from meerschaum.utils.warnings import info
|
786
|
+
on_commands = {'on', 'true', 'True'}
|
787
|
+
off_commands = {'off', 'false', 'False'}
|
788
|
+
if action is None:
|
789
|
+
action = []
|
790
|
+
try:
|
791
|
+
state = action[0]
|
792
|
+
except (IndexError, AttributeError):
|
793
|
+
state = ''
|
794
|
+
if state == '':
|
795
|
+
shell_attrs['daemon'] = not shell_attrs['daemon']
|
796
|
+
elif state.lower() in on_commands:
|
797
|
+
shell_attrs['daemon'] = True
|
798
|
+
elif state.lower() in off_commands:
|
799
|
+
shell_attrs['daemon'] = False
|
800
|
+
else:
|
801
|
+
info(f"Unknown state '{state}'. Ignoring...")
|
802
|
+
|
803
|
+
info(f"CLI daemon mode is {'on' if shell_attrs['daemon'] else 'off'}.")
|
804
|
+
return True, "Success"
|
805
|
+
|
735
806
|
def do_instance(
|
736
807
|
self,
|
737
808
|
action: Optional[List[str]] = None,
|
@@ -781,10 +852,11 @@ class Shell(cmd.Cmd):
|
|
781
852
|
instance_keys += ':main'
|
782
853
|
|
783
854
|
conn_attrs = parse_instance_keys(instance_keys, construct=False, debug=debug)
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
855
|
+
conn_keys = (
|
856
|
+
str(get_connector(debug=debug))
|
857
|
+
if conn_attrs is None
|
858
|
+
else instance_keys
|
859
|
+
)
|
788
860
|
|
789
861
|
shell_attrs['instance_keys'] = conn_keys
|
790
862
|
|
@@ -832,7 +904,7 @@ class Shell(cmd.Cmd):
|
|
832
904
|
"""
|
833
905
|
Temporarily set a default Meerschaum repository for the duration of the shell.
|
834
906
|
The default repository (mrsm.io) is loaded from the Meerschaum configuraton file
|
835
|
-
(at keys 'meerschaum
|
907
|
+
(at keys 'meerschaum.repository').
|
836
908
|
|
837
909
|
You can change the default repository with `edit config`.
|
838
910
|
|
@@ -863,7 +935,7 @@ class Shell(cmd.Cmd):
|
|
863
935
|
except (IndexError, AttributeError):
|
864
936
|
repo_keys = ''
|
865
937
|
if repo_keys == '':
|
866
|
-
repo_keys = get_config('meerschaum', '
|
938
|
+
repo_keys = get_config('meerschaum', 'repository', patch=True)
|
867
939
|
|
868
940
|
conn = parse_repo_keys(repo_keys, debug=debug)
|
869
941
|
if conn is None or not conn:
|
@@ -946,7 +1018,7 @@ class Shell(cmd.Cmd):
|
|
946
1018
|
show pipes -h
|
947
1019
|
```
|
948
1020
|
"""
|
949
|
-
from meerschaum.actions import
|
1021
|
+
from meerschaum.actions import get_action
|
950
1022
|
from meerschaum._internal.arguments._parser import parse_help
|
951
1023
|
from meerschaum._internal.arguments._parse_arguments import parse_line
|
952
1024
|
import textwrap
|
@@ -955,12 +1027,15 @@ class Shell(cmd.Cmd):
|
|
955
1027
|
del args['action']
|
956
1028
|
shell_attrs['_actions']['show'](['actions'], **args)
|
957
1029
|
return ""
|
1030
|
+
|
958
1031
|
if args['action'][0] not in shell_attrs['_actions']:
|
1032
|
+
action_func = get_action(args['action'])
|
959
1033
|
try:
|
960
|
-
print(textwrap.dedent(
|
1034
|
+
print(textwrap.dedent(action_func.__doc__))
|
961
1035
|
except Exception:
|
962
|
-
print(f"No help on '{args['action']
|
1036
|
+
print(f"No help on '{shlex.join(args['action'])}'.")
|
963
1037
|
return ""
|
1038
|
+
|
964
1039
|
parse_help(args)
|
965
1040
|
return ""
|
966
1041
|
|
@@ -1028,7 +1103,6 @@ class Shell(cmd.Cmd):
|
|
1028
1103
|
|
1029
1104
|
### if the user specifies, clear the screen before initializing the shell
|
1030
1105
|
if _clear_screen:
|
1031
|
-
from meerschaum.utils.formatting._shell import clear_screen
|
1032
1106
|
clear_screen(debug=shell_attrs['debug'])
|
1033
1107
|
|
1034
1108
|
### if sysargs are provided, skip printing the intro and execute instead
|
@@ -1044,9 +1118,10 @@ def input_with_sigint(_input, session, shell: Optional[Shell] = None):
|
|
1044
1118
|
Replace built-in `input()` with prompt_toolkit.prompt.
|
1045
1119
|
"""
|
1046
1120
|
from meerschaum.utils.formatting import CHARSET, ANSI, colored, UNICODE
|
1047
|
-
from meerschaum.connectors import
|
1121
|
+
from meerschaum.connectors import connectors
|
1048
1122
|
from meerschaum.utils.misc import remove_ansi, truncate_text_for_display
|
1049
1123
|
from meerschaum.config import get_config
|
1124
|
+
|
1050
1125
|
import platform
|
1051
1126
|
if shell is None:
|
1052
1127
|
from meerschaum.actions import get_shell
|
@@ -1061,8 +1136,16 @@ def input_with_sigint(_input, session, shell: Optional[Shell] = None):
|
|
1061
1136
|
return None
|
1062
1137
|
if not shell_attrs['_update_bottom_toolbar'] and platform.system() == 'Windows':
|
1063
1138
|
return shell_attrs['_old_bottom_toolbar']
|
1064
|
-
|
1065
|
-
|
1139
|
+
try:
|
1140
|
+
size = os.get_terminal_size()
|
1141
|
+
num_cols, num_lines = size.columns, size.lines
|
1142
|
+
except Exception:
|
1143
|
+
from meerschaum.utils.misc import is_int
|
1144
|
+
num_cols, num_lines = os.environ.get('COLUMNS', 80), os.environ.get('LINES', 120)
|
1145
|
+
if is_int(str(num_cols)):
|
1146
|
+
num_cols = int(num_cols)
|
1147
|
+
if is_int(str(num_lines)):
|
1148
|
+
num_lines = int(num_lines)
|
1066
1149
|
truncation_suffix = (
|
1067
1150
|
'…'
|
1068
1151
|
if UNICODE
|
@@ -1111,24 +1194,34 @@ def input_with_sigint(_input, session, shell: Optional[Shell] = None):
|
|
1111
1194
|
|
1112
1195
|
try:
|
1113
1196
|
typ, label = shell_attrs['instance_keys'].split(':', maxsplit=1)
|
1114
|
-
|
1197
|
+
cli_worker = (
|
1198
|
+
get_cli_daemon()
|
1199
|
+
if shell_attrs.get('daemon', False)
|
1200
|
+
else None
|
1201
|
+
)
|
1202
|
+
connected = (
|
1203
|
+
cli_worker.job.status == 'running'
|
1204
|
+
if cli_worker is not None
|
1205
|
+
else (typ in connectors and label in connectors[typ])
|
1206
|
+
)
|
1115
1207
|
except Exception:
|
1116
1208
|
connected = False
|
1117
1209
|
last_connected = connected
|
1118
1210
|
connected_str = truncate_text_for_display(
|
1119
|
-
('
|
1211
|
+
('daemon' if cli_worker is not None else remove_ansi(shell_attrs['instance_keys'])),
|
1120
1212
|
**truncation_kwargs
|
1121
1213
|
)
|
1214
|
+
connected_status_str = 'disconnected' if not connected else 'connected'
|
1122
1215
|
connected_icon = get_config(
|
1123
|
-
'formatting',
|
1216
|
+
'formatting', connected_status_str, CHARSET, 'icon', warn=False,
|
1124
1217
|
) or ''
|
1125
1218
|
connection_text = (
|
1126
|
-
|
1127
|
-
colored(connected_str
|
1128
|
-
'formatting',
|
1219
|
+
(
|
1220
|
+
colored(connected_str, 'on ' + (get_config(
|
1221
|
+
'formatting', connected_status_str, 'ansi', 'rich', 'style',
|
1129
1222
|
warn=False,
|
1130
|
-
) or '') + ' ') if ANSI else (colored(connected_str
|
1131
|
-
)
|
1223
|
+
) or '') + ' ') if ANSI else (colored(connected_str, 'on white') + ' ')
|
1224
|
+
) + ' ' + connected_icon
|
1132
1225
|
)
|
1133
1226
|
|
1134
1227
|
left = (
|
@@ -1163,7 +1256,6 @@ def input_with_sigint(_input, session, shell: Optional[Shell] = None):
|
|
1163
1256
|
### NOTE: would it be better to do nothing instead?
|
1164
1257
|
if len(parsed.strip()) == 0:
|
1165
1258
|
if _clear_screen:
|
1166
|
-
from meerschaum.utils.formatting._shell import clear_screen
|
1167
1259
|
clear_screen()
|
1168
1260
|
except KeyboardInterrupt:
|
1169
1261
|
print("^C")
|
@@ -8,5 +8,8 @@ Import the Shell class definition
|
|
8
8
|
|
9
9
|
from meerschaum._internal.shell.Shell import Shell
|
10
10
|
from meerschaum._internal.shell.Shell import (
|
11
|
-
default_action_completer,
|
11
|
+
default_action_completer,
|
12
|
+
_completer_wrapper,
|
13
|
+
_insert_shell_actions,
|
14
|
+
_remove_shell_actions,
|
12
15
|
)
|