|
27 | 27 | from lib.vdi import VDI |
28 | 28 | from lib.vif import VIF |
29 | 29 |
|
30 | | -from typing import TYPE_CHECKING, Iterable, List, Literal, cast, overload |
| 30 | +from typing import TYPE_CHECKING, Iterable, List, Literal, overload |
31 | 31 |
|
32 | 32 | if TYPE_CHECKING: |
33 | 33 | from lib.host import Host |
@@ -130,8 +130,8 @@ def ssh(self, cmd: str, *, check: bool = True, simple_output: bool = True, |
130 | 130 | ... |
131 | 131 |
|
132 | 132 | @overload |
133 | | - def ssh(self, cmd: str, *, check: bool = True, simple_output: bool = True, background: bool = False, |
134 | | - decode: bool = True) -> str | bytes | commands.SSHResult[str] | commands.SSHResult[bytes] | None: |
| 133 | + def ssh(self, cmd: str, *, check: bool = True, simple_output: bool = True, |
| 134 | + background: Literal[False] = False, decode: Literal[True] = True) -> str | commands.SSHResult[str]: |
135 | 135 | ... |
136 | 136 |
|
137 | 137 | def ssh(self, cmd: str, *, check: bool = True, simple_output: bool = True, background: bool = False, |
@@ -463,7 +463,7 @@ def execute_script(self, script_contents: str, simple_output: bool = True) -> st |
463 | 463 | logging.debug(f"[{self.ip}] # Will execute this temporary script:\n{script_contents.strip()}") |
464 | 464 | # Use bash to run the script, to avoid being hit by differences between shells, for example on FreeBSD |
465 | 465 | # It is a documented requirement that bash is present on all test VMs. |
466 | | - res = cast(str | commands.SSHResult, self.ssh(f'bash {f.name}', simple_output=simple_output)) |
| 466 | + res = self.ssh(f'bash {f.name}', simple_output=simple_output) |
467 | 467 | return res |
468 | 468 | finally: |
469 | 469 | self.ssh(f'rm -f {f.name}') |
@@ -801,10 +801,10 @@ def execute_powershell_script( |
801 | 801 | if prepend is not None: |
802 | 802 | script_contents = prepend + script_contents |
803 | 803 | cmd = commands.encode_powershell_command(script_contents) |
804 | | - return cast(str | commands.SSHResult, self.ssh( |
| 804 | + return self.ssh( |
805 | 805 | f"powershell.exe -nologo -noprofile -noninteractive -encodedcommand {cmd}", |
806 | 806 | simple_output=simple_output, |
807 | | - )) |
| 807 | + ) |
808 | 808 |
|
809 | 809 | def run_powershell_command(self, program: str, args: str) -> int: |
810 | 810 | """ |
|
0 commit comments