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

Lines changed: 1 addition & 4 deletions
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

Lines changed: 4 additions & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy