dais-shell 0.1.10__tar.gz → 0.2.0__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.
- {dais_shell-0.1.10 → dais_shell-0.2.0}/PKG-INFO +1 -1
- {dais_shell-0.1.10 → dais_shell-0.2.0}/pyproject.toml +1 -1
- {dais_shell-0.1.10 → dais_shell-0.2.0}/src/dais_shell/runtimes/BashRuntime.py +4 -11
- {dais_shell-0.1.10 → dais_shell-0.2.0}/src/dais_shell/runtimes/PowershellRuntime.py +5 -12
- {dais_shell-0.1.10 → dais_shell-0.2.0}/src/dais_shell/types/command_step.py +1 -1
- {dais_shell-0.1.10 → dais_shell-0.2.0}/README.md +0 -0
- {dais_shell-0.1.10 → dais_shell-0.2.0}/src/dais_shell/__init__.py +0 -0
- {dais_shell-0.1.10 → dais_shell-0.2.0}/src/dais_shell/constants.py +0 -0
- {dais_shell-0.1.10 → dais_shell-0.2.0}/src/dais_shell/env_builder.py +0 -0
- {dais_shell-0.1.10 → dais_shell-0.2.0}/src/dais_shell/iostream_reader.py +0 -0
- {dais_shell-0.1.10 → dais_shell-0.2.0}/src/dais_shell/py.typed +0 -0
- {dais_shell-0.1.10 → dais_shell-0.2.0}/src/dais_shell/runtimes/BaseShellRuntime.py +0 -0
- {dais_shell-0.1.10 → dais_shell-0.2.0}/src/dais_shell/runtimes/__init__.py +0 -0
- {dais_shell-0.1.10 → dais_shell-0.2.0}/src/dais_shell/types/__init__.py +0 -0
- {dais_shell-0.1.10 → dais_shell-0.2.0}/src/dais_shell/types/exceptions.py +0 -0
- {dais_shell-0.1.10 → dais_shell-0.2.0}/src/dais_shell/utils/__init__.py +0 -0
- {dais_shell-0.1.10 → dais_shell-0.2.0}/src/dais_shell/utils/env_expander.py +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
import shlex
|
|
2
3
|
import shutil
|
|
3
4
|
from dataclasses import asdict, dataclass
|
|
4
5
|
|
|
@@ -15,7 +16,7 @@ class BashCommandStep(CommandStep):
|
|
|
15
16
|
return cls(**asdict(step))
|
|
16
17
|
|
|
17
18
|
def to_wrapper_script(self):
|
|
18
|
-
return
|
|
19
|
+
return f"exec {shlex.quote(self.command)} {self.args}"
|
|
19
20
|
|
|
20
21
|
# --- --- --- --- --- ---
|
|
21
22
|
|
|
@@ -36,21 +37,13 @@ class BashRuntime(BaseShellRuntime):
|
|
|
36
37
|
self._shell,
|
|
37
38
|
"-c",
|
|
38
39
|
step.to_wrapper_script(),
|
|
39
|
-
"--",
|
|
40
|
-
step.command,
|
|
41
|
-
*step.args
|
|
42
40
|
]
|
|
43
41
|
|
|
44
42
|
def _prepare_cmd(self, step: CommandStep) -> list[str]:
|
|
45
43
|
env_expander = EnvExpander(step.env or {})
|
|
46
|
-
step.args =
|
|
44
|
+
step.args = env_expander.expand(step.args)
|
|
47
45
|
step = BashCommandStep.from_command_step(step)
|
|
48
|
-
|
|
49
|
-
is_shell_command = resolved is None
|
|
50
|
-
if is_shell_command:
|
|
51
|
-
return self._make_bash_commands(step)
|
|
52
|
-
else:
|
|
53
|
-
return [resolved, *step.args]
|
|
46
|
+
return self._make_bash_commands(step)
|
|
54
47
|
|
|
55
48
|
def run_sync(self,
|
|
56
49
|
step: CommandStep,
|
|
@@ -20,19 +20,9 @@ class PowerShellCommandStep(CommandStep):
|
|
|
20
20
|
return cls(**asdict(step))
|
|
21
21
|
|
|
22
22
|
def to_wrapper_script(self):
|
|
23
|
-
|
|
24
23
|
def ps_quote(s: str) -> str:
|
|
25
24
|
return "'" + s.replace("'", "''") + "'"
|
|
26
25
|
|
|
27
|
-
def fmt_arg(s: str) -> str:
|
|
28
|
-
return s if re.match(r"^-[a-zA-Z]", s) else ps_quote(s)
|
|
29
|
-
|
|
30
|
-
def ps_encode(s: str) -> str:
|
|
31
|
-
return base64.b64encode(s.encode("utf-8")).decode("ascii")
|
|
32
|
-
|
|
33
|
-
args_str = (" " + " ".join(fmt_arg(a) for a in self.args)) if self.args else ""
|
|
34
|
-
invocation = f"& {ps_quote(self.command)}{args_str}"
|
|
35
|
-
|
|
36
26
|
script = f"""
|
|
37
27
|
$ErrorActionPreference = "Stop"
|
|
38
28
|
$PSNativeCommandArgumentPassing = "Standard"
|
|
@@ -42,7 +32,10 @@ $OutputEncoding = [System.Text.Encoding]::UTF8
|
|
|
42
32
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
43
33
|
[Console]::InputEncoding = [System.Text.Encoding]::UTF8
|
|
44
34
|
|
|
45
|
-
{
|
|
35
|
+
$command = {ps_quote(self.command)}
|
|
36
|
+
|
|
37
|
+
& $command {self.args}
|
|
38
|
+
|
|
46
39
|
exit $LASTEXITCODE"""
|
|
47
40
|
return script.strip()
|
|
48
41
|
|
|
@@ -111,7 +104,7 @@ class PowerShellRuntime(BaseShellRuntime):
|
|
|
111
104
|
|
|
112
105
|
def _prepare_cmd(self, step: CommandStep) -> list[str]:
|
|
113
106
|
env_expander = EnvExpander(step.env or {})
|
|
114
|
-
step.args =
|
|
107
|
+
step.args = env_expander.expand(step.args)
|
|
115
108
|
step = PowerShellCommandStep.from_command_step(step)
|
|
116
109
|
script = step.to_wrapper_script()
|
|
117
110
|
encoded = self._encode(script)
|
|
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
|