shelltastic 0.9.0__tar.gz → 0.9.1__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.
- {shelltastic-0.9.0 → shelltastic-0.9.1}/PKG-INFO +1 -1
- {shelltastic-0.9.0 → shelltastic-0.9.1}/pyproject.toml +1 -1
- {shelltastic-0.9.0 → shelltastic-0.9.1}/pyproject.toml.orig +1 -1
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/backend/base.py +0 -2
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/enum.py +2 -0
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/frontend/shell.py +59 -13
- {shelltastic-0.9.0 → shelltastic-0.9.1}/LICENSE +0 -0
- {shelltastic-0.9.0 → shelltastic-0.9.1}/README.md +0 -0
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/__init__.py +5 -5
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/backend/__init__.py +3 -3
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/backend/default/__init__.py +0 -0
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/backend/default/common.py +0 -0
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/backend/default/local.py +0 -0
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/backend/default/remote.py +0 -0
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/display.py +0 -0
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/exception.py +0 -0
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/frontend/__init__.py +0 -0
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/frontend/common.py +0 -0
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/frontend/git.py +0 -0
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/frontend/scp.py +0 -0
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/host.py +0 -0
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/io.py +0 -0
- {shelltastic-0.9.0 → shelltastic-0.9.1}/src/shelltastic/result.py +0 -0
|
@@ -92,12 +92,10 @@ _backend_shims: list[BackendShim] = []
|
|
|
92
92
|
|
|
93
93
|
def clear_shims():
|
|
94
94
|
"""Clear all shims"""
|
|
95
|
-
global _backend_shims
|
|
96
95
|
_backend_shims.clear()
|
|
97
96
|
|
|
98
97
|
def add_shim(shim: BackendShim):
|
|
99
98
|
"""Add a shim to manipulate `ShellBackend` params before any `ShellBackend` runs"""
|
|
100
|
-
global _backend_shims
|
|
101
99
|
_backend_shims.append(shim)
|
|
102
100
|
|
|
103
101
|
|
|
@@ -18,8 +18,11 @@ if TYPE_CHECKING:
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class ShellFrontend:
|
|
21
|
+
__slots__ = ("_backend", "_cached_system_type")
|
|
22
|
+
|
|
21
23
|
def __init__(self, backend: ShellBackend) -> None:
|
|
22
24
|
self._backend = backend
|
|
25
|
+
self._cached_system_type = None
|
|
23
26
|
|
|
24
27
|
def which(self, command: str) -> Path | None:
|
|
25
28
|
"""Return the path to the command or None if the command is not on the path."""
|
|
@@ -34,12 +37,20 @@ class ShellFrontend:
|
|
|
34
37
|
|
|
35
38
|
def file_exists(self, path: str | Path) -> bool:
|
|
36
39
|
"""Returns true if the file at the given path exists and false if it doesn't."""
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
if self.system_type() == SystemType.WINDOWS:
|
|
41
|
+
result = self.run(
|
|
42
|
+
f'IF EXIST "{path}" (exit 0) ELSE (exit 1)',
|
|
43
|
+
check=False,
|
|
44
|
+
stdout=CaptureMode.DEVNULL,
|
|
45
|
+
stderr=CaptureMode.DEVNULL,
|
|
46
|
+
)
|
|
47
|
+
else:
|
|
48
|
+
result = self.run(
|
|
49
|
+
f'stat "{path}"',
|
|
50
|
+
check=False,
|
|
51
|
+
stdout=CaptureMode.DEVNULL,
|
|
52
|
+
stderr=CaptureMode.DEVNULL,
|
|
53
|
+
)
|
|
43
54
|
return result.returncode == 0
|
|
44
55
|
|
|
45
56
|
def home_dir(self) -> Path:
|
|
@@ -50,20 +61,55 @@ class ShellFrontend:
|
|
|
50
61
|
assert result.stdout is not None
|
|
51
62
|
return Path(result.stdout.decode().strip())
|
|
52
63
|
|
|
53
|
-
def
|
|
54
|
-
"""Return system type"""
|
|
64
|
+
def _system_type(self) -> SystemType:
|
|
55
65
|
if (
|
|
66
|
+
"Linux"
|
|
67
|
+
in self.run(
|
|
68
|
+
"uname -o",
|
|
69
|
+
check=False,
|
|
70
|
+
stdout=CaptureMode.PIPE,
|
|
71
|
+
stderr=CaptureMode.DEVNULL,
|
|
72
|
+
).stdout.decode("utf-8") # type: ignore
|
|
73
|
+
):
|
|
74
|
+
# Linux
|
|
75
|
+
if (
|
|
76
|
+
self.run(
|
|
77
|
+
"stat /etc/debian_version",
|
|
78
|
+
check=False,
|
|
79
|
+
stdout=CaptureMode.DEVNULL,
|
|
80
|
+
stderr=CaptureMode.DEVNULL,
|
|
81
|
+
).returncode
|
|
82
|
+
== 0
|
|
83
|
+
):
|
|
84
|
+
return SystemType.DEBIAN_BASED
|
|
85
|
+
|
|
86
|
+
if "cachyos" in self.run(
|
|
87
|
+
"uname -r",
|
|
88
|
+
check=False,
|
|
89
|
+
stdout=CaptureMode.PIPE,
|
|
90
|
+
stderr=CaptureMode.DEVNULL,
|
|
91
|
+
).stdout.decode("utf-8"): # type: ignore
|
|
92
|
+
return SystemType.CACHYOS
|
|
93
|
+
elif (
|
|
56
94
|
self.run(
|
|
57
|
-
"
|
|
95
|
+
"echo %OS%",
|
|
58
96
|
check=False,
|
|
59
|
-
stdout=CaptureMode.
|
|
97
|
+
stdout=CaptureMode.PIPE,
|
|
60
98
|
stderr=CaptureMode.DEVNULL,
|
|
61
|
-
)
|
|
62
|
-
|
|
99
|
+
)
|
|
100
|
+
.stdout.decode("utf-8") # type: ignore
|
|
101
|
+
.strip()
|
|
102
|
+
== "Windows_NT"
|
|
63
103
|
):
|
|
64
|
-
return SystemType.
|
|
104
|
+
return SystemType.WINDOWS
|
|
65
105
|
return SystemType.UNKNOWN
|
|
66
106
|
|
|
107
|
+
def system_type(self) -> SystemType:
|
|
108
|
+
"""Return system type"""
|
|
109
|
+
if not self._cached_system_type:
|
|
110
|
+
self._cached_system_type = self._system_type()
|
|
111
|
+
return self._cached_system_type
|
|
112
|
+
|
|
67
113
|
def run(
|
|
68
114
|
self,
|
|
69
115
|
cmd: str | list[str],
|
|
File without changes
|
|
File without changes
|
|
@@ -6,14 +6,14 @@ from shelltastic.host import Host
|
|
|
6
6
|
from shelltastic.result import ShellResult
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
9
|
-
"shell",
|
|
10
|
-
"scp",
|
|
11
|
-
"git",
|
|
12
|
-
"DisplayMode",
|
|
13
9
|
"CaptureMode",
|
|
14
|
-
"
|
|
10
|
+
"DisplayMode",
|
|
15
11
|
"Host",
|
|
16
12
|
"ShellResult",
|
|
13
|
+
"SystemType",
|
|
14
|
+
"git",
|
|
15
|
+
"scp",
|
|
16
|
+
"shell",
|
|
17
17
|
]
|
|
18
18
|
|
|
19
19
|
shell = LocalShellFrontend()
|
|
@@ -11,16 +11,16 @@ from shelltastic.backend.default.remote import DefaultRemoteBackend
|
|
|
11
11
|
from shelltastic.host import Host
|
|
12
12
|
|
|
13
13
|
__all__ = [
|
|
14
|
+
"BackendShim",
|
|
14
15
|
"LocalShellBackend",
|
|
15
16
|
"RemoteShellBackend",
|
|
16
|
-
"BackendShim",
|
|
17
17
|
"ShellBackend",
|
|
18
|
-
"register_default_local_backend",
|
|
19
|
-
"register_default_remote_backend",
|
|
20
18
|
"add_shim",
|
|
21
19
|
"clear_shims",
|
|
22
20
|
"get_local_backend",
|
|
23
21
|
"get_remote_backend",
|
|
22
|
+
"register_default_local_backend",
|
|
23
|
+
"register_default_remote_backend",
|
|
24
24
|
]
|
|
25
25
|
|
|
26
26
|
_default_local_backend: type[LocalShellBackend] = DefaultLocalBackend
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|