sshscript 5.0.0__py3-none-any.whl → 6.1.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.
- sshscript/__init__.py +5 -0
- sshscript/__init__.pyi +4 -1
- sshscript/_version.py +1 -1
- sshscript/channelgeneric.py +7 -2
- sshscript/dollarparser.py +3 -1
- sshscript/errorutils.py +0 -7
- sshscript/interactive.py +977 -0
- sshscript/interactive.pyi +71 -0
- sshscript/scriptcontrol.py +34 -0
- sshscript/session.py +24 -25
- sshscript/session.pyi +3 -0
- sshscript/sessionwrapper.py +3 -4
- sshscript/sessionwrapper.pyi +1 -0
- sshscript/spyimporter.py +10 -1
- sshscript/sshscript.py +27 -22
- {sshscript-5.0.0.dist-info → sshscript-6.1.0.dist-info}/METADATA +32 -11
- sshscript-6.1.0.dist-info/RECORD +39 -0
- sshscript-5.0.0.dist-info/RECORD +0 -36
- {sshscript-5.0.0.dist-info → sshscript-6.1.0.dist-info}/WHEEL +0 -0
- {sshscript-5.0.0.dist-info → sshscript-6.1.0.dist-info}/entry_points.txt +0 -0
- {sshscript-5.0.0.dist-info → sshscript-6.1.0.dist-info}/licenses/LICENSE.txt +0 -0
- {sshscript-5.0.0.dist-info → sshscript-6.1.0.dist-info}/top_level.txt +0 -0
sshscript/__init__.py
CHANGED
|
@@ -43,12 +43,14 @@ else:
|
|
|
43
43
|
_require_python()
|
|
44
44
|
|
|
45
45
|
if __package__:
|
|
46
|
+
from .interactive import Console, ConsoleUpdate, Environment, SwitchRequest, SwitchCredentials, SwitchOutcome, CredentialsRequiredError, ConsoleInitializationError, ConsoleCleanupError
|
|
46
47
|
from ._version import __version__
|
|
47
48
|
from . import sshscript
|
|
48
49
|
from . import session
|
|
49
50
|
from . import errorutils
|
|
50
51
|
from .spyimporter import spy_imports
|
|
51
52
|
else:
|
|
53
|
+
from interactive import Console, ConsoleUpdate, Environment, SwitchRequest, SwitchCredentials, SwitchOutcome, CredentialsRequiredError, ConsoleInitializationError, ConsoleCleanupError
|
|
52
54
|
from _version import __version__
|
|
53
55
|
import sshscript
|
|
54
56
|
import session
|
|
@@ -59,6 +61,7 @@ run_file = sshscript.run_file
|
|
|
59
61
|
check_file = sshscript.check_file
|
|
60
62
|
run_script = sshscript.run_script
|
|
61
63
|
Session = session.Session
|
|
64
|
+
ScriptResult = session.ScriptResult
|
|
62
65
|
CommandResult = session.CommandResult
|
|
63
66
|
CommandJob = session.CommandJob
|
|
64
67
|
CommandTimeoutError = session.CommandTimeoutError
|
|
@@ -84,11 +87,13 @@ SSHScriptException = errorutils.SSHScriptException
|
|
|
84
87
|
# return _global['____sshscript____'][0]
|
|
85
88
|
|
|
86
89
|
__all__ = [
|
|
90
|
+
'Console', 'ConsoleUpdate', 'Environment', 'SwitchRequest', 'SwitchCredentials', 'SwitchOutcome', 'CredentialsRequiredError', 'ConsoleInitializationError', 'ConsoleCleanupError',
|
|
87
91
|
'run_file',
|
|
88
92
|
'check_file',
|
|
89
93
|
'run_script',
|
|
90
94
|
'Session',
|
|
91
95
|
'CommandResult',
|
|
96
|
+
'ScriptResult',
|
|
92
97
|
'CommandJob',
|
|
93
98
|
'CommandTimeoutError',
|
|
94
99
|
'JobResult',
|
sshscript/__init__.pyi
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from typing import Any, ContextManager
|
|
2
2
|
from os import PathLike
|
|
3
3
|
from .session import Session as Session
|
|
4
|
+
from .scriptcontrol import ScriptResult as ScriptResult
|
|
4
5
|
from .commandresult import CommandResult as CommandResult
|
|
5
6
|
from .commandjob import CommandJob as CommandJob, JobResult as JobResult, CommandTimeoutError as CommandTimeoutError
|
|
6
7
|
from .errorutils import SSHScriptException as SSHScriptException
|
|
@@ -9,7 +10,9 @@ __version__: str
|
|
|
9
10
|
|
|
10
11
|
def check_file(script_path: str | PathLike[str]) -> int: ...
|
|
11
12
|
def run_file(script_path: str | PathLike[str], vars: dict[str, Any] | None = ..., showScript: bool = ...) -> int: ...
|
|
12
|
-
def run_script(script: str, varGlobals: dict[str, Any] | None = ..., showScript: bool = ...) ->
|
|
13
|
+
def run_script(script: str, varGlobals: dict[str, Any] | None = ..., showScript: bool = ...) -> ScriptResult: ...
|
|
13
14
|
def spy_imports() -> ContextManager[None]: ...
|
|
14
15
|
def get_logger() -> Any: ...
|
|
15
16
|
def set_logger(userlogger: Any = ..., logname: str | None = ...) -> Any: ...
|
|
17
|
+
|
|
18
|
+
from .interactive import (Console as Console, ConsoleUpdate as ConsoleUpdate, Environment as Environment, SwitchRequest as SwitchRequest, SwitchCredentials as SwitchCredentials, SwitchOutcome as SwitchOutcome, CredentialsRequiredError as CredentialsRequiredError, ConsoleInitializationError as ConsoleInitializationError, ConsoleCleanupError as ConsoleCleanupError)
|
sshscript/_version.py
CHANGED
sshscript/channelgeneric.py
CHANGED
|
@@ -1492,6 +1492,11 @@ class GenericChannel(object):
|
|
|
1492
1492
|
Existing newlines are retained. Use send() to write exact text instead.
|
|
1493
1493
|
A readiness/silence status does not establish command success.
|
|
1494
1494
|
"""
|
|
1495
|
+
return self._input_text(text, timeout=timeout, append_newline=True)
|
|
1496
|
+
|
|
1497
|
+
def _input_text(self, text, timeout=60, *, append_newline=True):
|
|
1498
|
+
"""Shared interactive protocol for lines and raw terminal control bytes."""
|
|
1499
|
+
payload = text + ('\n' if append_newline else '') if isinstance(text, str) else text
|
|
1495
1500
|
if not isinstance(text, str):
|
|
1496
1501
|
raise TypeError('input text must be str')
|
|
1497
1502
|
|
|
@@ -1504,7 +1509,7 @@ class GenericChannel(object):
|
|
|
1504
1509
|
)
|
|
1505
1510
|
|
|
1506
1511
|
if not self.hijacked:
|
|
1507
|
-
return self.send(
|
|
1512
|
+
return self.send(payload, timeout=timeout)
|
|
1508
1513
|
|
|
1509
1514
|
deadline = time.monotonic() + timeout
|
|
1510
1515
|
executing_lock = self.executing_lock
|
|
@@ -1555,7 +1560,7 @@ class GenericChannel(object):
|
|
|
1555
1560
|
stderr.set_callback(prompt_found, current_prompt)
|
|
1556
1561
|
|
|
1557
1562
|
self.send(
|
|
1558
|
-
|
|
1563
|
+
payload,
|
|
1559
1564
|
timeout=self._remaining(deadline),
|
|
1560
1565
|
)
|
|
1561
1566
|
|
sshscript/dollarparser.py
CHANGED
|
@@ -138,7 +138,7 @@ def _token_syntax_error(error, script_path, spyscript):
|
|
|
138
138
|
return _source_syntax_error(synthetic, script_path, spyscript)
|
|
139
139
|
|
|
140
140
|
|
|
141
|
-
def parse(script_path, spyscript):
|
|
141
|
+
def parse(script_path, spyscript, *, preprocess=None):
|
|
142
142
|
"""Return a transformed AST whose locations still refer to *spyscript*."""
|
|
143
143
|
_cache_source(script_path, spyscript)
|
|
144
144
|
try:
|
|
@@ -156,6 +156,8 @@ def parse(script_path, spyscript):
|
|
|
156
156
|
raise _source_syntax_error(error, script_path, spyscript) from None
|
|
157
157
|
|
|
158
158
|
try:
|
|
159
|
+
if preprocess is not None:
|
|
160
|
+
tree = preprocess.visit(tree)
|
|
159
161
|
py_tree = DollarChanger().visit(tree)
|
|
160
162
|
return ast.fix_missing_locations(py_tree)
|
|
161
163
|
except Exception as error:
|
sshscript/errorutils.py
CHANGED
|
@@ -32,13 +32,6 @@ class SSHScriptException(Exception):
|
|
|
32
32
|
def __str__(self):
|
|
33
33
|
return f'{self.message}(#{self.errno})'
|
|
34
34
|
|
|
35
|
-
class SSHScriptBreak(SSHScriptException):
|
|
36
|
-
"""Control-flow signal for $.break(status), handled by the script runner."""
|
|
37
|
-
pass
|
|
38
|
-
|
|
39
|
-
class SSHScriptExit(SSHScriptException):
|
|
40
|
-
"""Control-flow signal for $.exit(status), propagated to the command-line runner."""
|
|
41
|
-
pass
|
|
42
35
|
|
|
43
36
|
def dumpScript(source,tb_lineno=None,linerange=10):
|
|
44
37
|
"""Print source with line numbers and optional error-line context."""
|