From 3ca3ff7eef2687c717c3cbcedc04f37b98ec7ed9 Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Tue, 24 Dec 2024 22:43:39 +0300 Subject: [PATCH] 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. --- testgres/node.py | 5 +---- testgres/operations/remote_ops.py | 5 ++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/testgres/node.py b/testgres/node.py index f7d6e839..3d023399 100644 --- a/testgres/node.py +++ b/testgres/node.py @@ -1125,10 +1125,7 @@ def _psql( # select query source if query: - if self.os_ops.remote: - psql_params.extend(("-c", '"{}"'.format(query))) - else: - psql_params.extend(("-c", query)) + psql_params.extend(("-c", query)) elif filename: psql_params.extend(("-f", filename)) else: diff --git a/testgres/operations/remote_ops.py b/testgres/operations/remote_ops.py index 3aa2d8c4..fb5dd4b2 100644 --- a/testgres/operations/remote_ops.py +++ b/testgres/operations/remote_ops.py @@ -80,7 +80,10 @@ def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False, 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 + cmd + ssh_cmd = ['ssh', self.ssh_dest] + self.ssh_args + [subprocess.list2cmdline(cmd)] + else: + raise ValueError("Invalid 'cmd' argument type - {0}".format(type(cmd).__name__)) + process = subprocess.Popen(ssh_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) assert not (process is None) if get_process: 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