Skip to content

Commit 3ca3ff7

Browse files
Ssh command line in RemoteOperations::execute is corrected
We use subprocess.list2cmdline(cmd) to pack a user command line. It allows PostgresNode::_psql to build PSQL command line without a "special case" for remote-host. Also RemoteOperations::execute raises exception if 'cmd' parameter has an unknown type.
1 parent 3224e21 commit 3ca3ff7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

testgres/node.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1125,10 +1125,7 @@ def _psql(
11251125

11261126
# select query source
11271127
if query:
1128-
if self.os_ops.remote:
1129-
psql_params.extend(("-c", '"{}"'.format(query)))
1130-
else:
1131-
psql_params.extend(("-c", query))
1128+
psql_params.extend(("-c", query))
11321129
elif filename:
11331130
psql_params.extend(("-f", filename))
11341131
else:

testgres/operations/remote_ops.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
8080
if isinstance(cmd, str):
8181
ssh_cmd = ['ssh', self.ssh_dest] + self.ssh_args + [cmd]
8282
elif isinstance(cmd, list):
83-
ssh_cmd = ['ssh', self.ssh_dest] + self.ssh_args + cmd
83+
ssh_cmd = ['ssh', self.ssh_dest] + self.ssh_args + [subprocess.list2cmdline(cmd)]
84+
else:
85+
raise ValueError("Invalid 'cmd' argument type - {0}".format(type(cmd).__name__))
86+
8487
process = subprocess.Popen(ssh_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
8588
assert not (process is None)
8689
if get_process:

0 commit comments

Comments
 (0)