From 7c0f1846205c89acc96139fca50b24b76dad4a28 Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Wed, 25 Dec 2024 12:33:38 +0300 Subject: [PATCH] RemoteOperations is updated (read_binary, get_file_size) get_file_size and get_file_size use a list for command list arguments. It allows to use standard way to escape a filename. Our bicycle "_escape_path" is deleted. --- testgres/operations/remote_ops.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/testgres/operations/remote_ops.py b/testgres/operations/remote_ops.py index fb5dd4b2..128a2a21 100644 --- a/testgres/operations/remote_ops.py +++ b/testgres/operations/remote_ops.py @@ -347,7 +347,7 @@ def read_binary(self, filename, start_pos): assert type(start_pos) == int # noqa: E721 assert start_pos >= 0 - cmd = "tail -c +{} {}".format(start_pos + 1, __class__._escape_path(filename)) + cmd = ["tail", "-c", "+{}".format(start_pos + 1), filename] r = self.exec_command(cmd) assert type(r) == bytes # noqa: E721 return r @@ -367,7 +367,7 @@ def get_file_size(self, filename): assert filename is not None assert type(filename) == str # noqa: E721 - cmd = "du -b " + __class__._escape_path(filename) + cmd = ["du", "-b", filename] s = self.exec_command(cmd, encoding=get_default_encoding()) assert type(s) == str # noqa: E721 @@ -462,15 +462,6 @@ def db_connect(self, dbname, user, password=None, host="localhost", port=5432): ) return conn - def _escape_path(path): - assert type(path) == str # noqa: E721 - assert path != "" # Ok? - - r = "'" - r += path - r += "'" - return r - def normalize_error(error): if isinstance(error, bytes):