Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
RemoteOperations::exec_command updated
- Exact enumeration of supported 'cmd' types
- Refactoring
  • Loading branch information
dmitry-lipetsk committed Feb 20, 2025
commit f5fe166eec93c2b727b4ee0145eecdf77d9b38d6
13 changes: 8 additions & 5 deletions testgres/operations/remote_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,17 @@ def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,

assert input_prepared is None or (type(input_prepared) == bytes) # noqa: E721

ssh_cmd = []
if isinstance(cmd, str):
ssh_cmd = ['ssh', self.ssh_dest] + self.ssh_args + [cmd]
elif isinstance(cmd, list):
ssh_cmd = ['ssh', self.ssh_dest] + self.ssh_args + [subprocess.list2cmdline(cmd)]
if type(cmd) == str: # noqa: E721
cmd_s = cmd
elif type(cmd) == list: # noqa: E721
cmd_s = subprocess.list2cmdline(cmd)
else:
raise ValueError("Invalid 'cmd' argument type - {0}".format(type(cmd).__name__))

assert type(cmd_s) == str # noqa: E721

ssh_cmd = ['ssh', self.ssh_dest] + self.ssh_args + [cmd_s]

process = subprocess.Popen(ssh_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
assert not (process is None)
if get_process:
Expand Down