From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BA90A45A48; Sat, 28 Sep 2024 00:15:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E8CF740B8F; Sat, 28 Sep 2024 00:13:50 +0200 (CEST) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by mails.dpdk.org (Postfix) with ESMTP id 853A04028C for ; Fri, 27 Sep 2024 18:09:00 +0200 (CEST) Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-42cbb08a1a5so21402635e9.3 for ; Fri, 27 Sep 2024 09:09:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1727453340; x=1728058140; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eY6AtQgPj6nI6Owf6/OGIiT5xUq3LzYyBz6sfFU8ZlQ=; b=vOQE3iVC8QHZJOClwO6H41XWW8MB775mOMqeMKrIgsgPx2Ulmex74KRKKtfnw49sM3 oNioq1iy6+Ypzyy1ZEOXNVJ9KL02Know+/3NIp4xcuU6nhtpGuTzCG2leeD3UTEZ8Iiz riR9sbtW+GOOzTYUdlRmuKksMAHQ3qyuenBCeXdV7KDeOeZlvD0BC5fpxAzl/GSM6Cgy uhtQlHhr0grl3RjZveYD/t8CZPzYppKEfR6QS/oyzrDrStzZ0/guODgbHVx5LVJb+vy9 fA02erJZXBGJPky7vI5AVvHOl4Mup0OlQS/f7BeFIO1a1tFQgLqZBxV+i6FFHCv8s5SU A9HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727453340; x=1728058140; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eY6AtQgPj6nI6Owf6/OGIiT5xUq3LzYyBz6sfFU8ZlQ=; b=ETx3+ehsUtxxRZGloDIiKrXQjgjLK8y4nanh/8p8EXBidth3YtbwXSue2PKNQ+rZSm W2xO0CoAft73qLdNmGUvDdfhKr1ue77OtqY0GfwZdRqrmK2Qg4HHyJZeDiTO7MjO85ON 1xY37ZmpSa/InxtOMxtxqQXdJZI3EsXVKw1SRT1YogmYWxCOLalqfzUqIZJ4x940lDAx tZM8/l2pu4x6CNfwao56ooJ580lDw+2vfC0y/JmkS8bDG3TDLAdokiXZpIwBiY5gkC5r m5DoUd0kHWkhYlvb8QBzJNnCryd0R7ROAF3A5GjvEx3vOZFOe2l0rr0Xdd2LS5mikRkO WxEQ== X-Gm-Message-State: AOJu0YzdGyQvYJkB93s5rvDJgILfYONK6AsMMl5fJsRTCwmn631CXXW/ bTHvL9CWmXBQv8/tNCXH5jjULU5PJfux3D3oSwqp74Jh3iCLgfyhEsoAr+pf6K71jLH6jnmV1Sq YdKg= X-Google-Smtp-Source: AGHT+IEcEl8JKwAG1TFSfx4Ow3ZZ0CL6Wx3pI/YaH9unJBS6TgXuehqlUhk0LLi6Fm02h0RygHLCcA== X-Received: by 2002:a05:600c:4f86:b0:42c:bae0:f066 with SMTP id 5b1f17b1804b1-42f58434768mr25469065e9.13.1727453339915; Fri, 27 Sep 2024 09:08:59 -0700 (PDT) Received: from fedora.. ([185.242.191.25]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd564bf8bsm2943471f8f.20.2024.09.27.09.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 09:08:59 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20=C4=8Eurovec?= To: dev@dpdk.org, Luca.Vizzarro@arm.com, probb@iol.unh.edu, npratte@iol.unh.edu, dmarx@iol.unh.edu Cc: =?UTF-8?q?Tom=C3=A1=C5=A1=20=C4=8Eurovec?= Subject: [PATCH 3/7] dts: fix remote session file transfer vars Date: Fri, 27 Sep 2024 18:08:50 +0200 Message-ID: <20240927160854.279253-4-tomas.durovec@pantheon.tech> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20240927160854.279253-1-tomas.durovec@pantheon.tech> References: <20240927160854.279253-1-tomas.durovec@pantheon.tech> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Sat, 28 Sep 2024 00:13:28 +0200 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The OSSession (and its subclasses) should accept PurePaths for remote paths to translate from OS-unaware (PurePath) to OS-aware (Path) only on the remote side. For local paths, they should accept Paths, as Python is OS-aware locally. Signed-off-by: Tomáš Ďurovec --- .../remote_session/remote_session.py | 24 ++++++---------- dts/framework/remote_session/ssh_session.py | 18 ++++-------- dts/framework/testbed_model/os_session.py | 28 ++++++++----------- dts/framework/testbed_model/posix_session.py | 18 ++++-------- 4 files changed, 30 insertions(+), 58 deletions(-) diff --git a/dts/framework/remote_session/remote_session.py b/dts/framework/remote_session/remote_session.py index 8c580b070f..ab83f5b266 100644 --- a/dts/framework/remote_session/remote_session.py +++ b/dts/framework/remote_session/remote_session.py @@ -12,7 +12,7 @@ from abc import ABC, abstractmethod from dataclasses import InitVar, dataclass, field -from pathlib import PurePath +from pathlib import Path, PurePath from framework.config import NodeConfiguration from framework.exception import RemoteCommandExecutionError @@ -196,35 +196,29 @@ def is_alive(self) -> bool: """Check whether the remote session is still responding.""" @abstractmethod - def copy_from( - self, - source_file: str | PurePath, - destination_file: str | PurePath, - ) -> None: + def copy_from(self, source_file: str | PurePath, destination_dir: str | Path) -> None: """Copy a file from the remote Node to the local filesystem. Copy `source_file` from the remote Node associated with this remote session - to `destination_file` on the local filesystem. + to `destination_dir` on the local filesystem. Args: source_file: The file on the remote Node. - destination_file: A file or directory path on the local filesystem. + destination_dir: The directory path on the local filesystem where the `source_file` + will be saved. """ @abstractmethod - def copy_to( - self, - source_file: str | PurePath, - destination_file: str | PurePath, - ) -> None: + def copy_to(self, source_file: str | Path, destination_dir: str | PurePath) -> None: """Copy a file from local filesystem to the remote Node. - Copy `source_file` from local filesystem to `destination_file` on the remote Node + Copy `source_file` from local filesystem to `destination_dir` on the remote Node associated with this remote session. Args: source_file: The file on the local filesystem. - destination_file: A file or directory path on the remote Node. + destination_dir: The directory path on the remote Node where the `source_file` + will be saved. """ @abstractmethod diff --git a/dts/framework/remote_session/ssh_session.py b/dts/framework/remote_session/ssh_session.py index 66f8176833..329121913f 100644 --- a/dts/framework/remote_session/ssh_session.py +++ b/dts/framework/remote_session/ssh_session.py @@ -5,7 +5,7 @@ import socket import traceback -from pathlib import PurePath +from pathlib import Path, PurePath from fabric import Connection # type: ignore[import-untyped] from invoke.exceptions import ( # type: ignore[import-untyped] @@ -103,21 +103,13 @@ def is_alive(self) -> bool: """Overrides :meth:`~.remote_session.RemoteSession.is_alive`.""" return self.session.is_connected - def copy_from( - self, - source_file: str | PurePath, - destination_file: str | PurePath, - ) -> None: + def copy_from(self, source_file: str | PurePath, destination_dir: str | Path) -> None: """Overrides :meth:`~.remote_session.RemoteSession.copy_from`.""" - self.session.get(str(destination_file), str(source_file)) + self.session.get(str(source_file), str(destination_dir)) - def copy_to( - self, - source_file: str | PurePath, - destination_file: str | PurePath, - ) -> None: + def copy_to(self, source_file: str | Path, destination_dir: str | PurePath) -> None: """Overrides :meth:`~.remote_session.RemoteSession.copy_to`.""" - self.session.put(str(source_file), str(destination_file)) + self.session.put(str(source_file), str(destination_dir)) def close(self) -> None: """Overrides :meth:`~.remote_session.RemoteSession.close`.""" diff --git a/dts/framework/testbed_model/os_session.py b/dts/framework/testbed_model/os_session.py index 79f56b289b..1aac3659bf 100644 --- a/dts/framework/testbed_model/os_session.py +++ b/dts/framework/testbed_model/os_session.py @@ -25,7 +25,7 @@ from abc import ABC, abstractmethod from collections.abc import Iterable from ipaddress import IPv4Interface, IPv6Interface -from pathlib import PurePath +from pathlib import Path, PurePath from typing import Union from framework.config import Architecture, NodeConfiguration, NodeInfo @@ -178,35 +178,29 @@ def join_remote_path(self, *args: str | PurePath) -> PurePath: """ @abstractmethod - def copy_from( - self, - source_file: str | PurePath, - destination_file: str | PurePath, - ) -> None: + def copy_from(self, source_file: str | PurePath, destination_dir: str | Path) -> None: """Copy a file from the remote node to the local filesystem. Copy `source_file` from the remote node associated with this remote - session to `destination_file` on the local filesystem. + session to `destination_dir` on the local filesystem. Args: - source_file: the file on the remote node. - destination_file: a file or directory path on the local filesystem. + source_file: The file on the remote node. + destination_dir: The directory path on the local filesystem where the `source_file` + will be saved. """ @abstractmethod - def copy_to( - self, - source_file: str | PurePath, - destination_file: str | PurePath, - ) -> None: + def copy_to(self, source_file: str | Path, destination_dir: str | PurePath) -> None: """Copy a file from local filesystem to the remote node. - Copy `source_file` from local filesystem to `destination_file` + Copy `source_file` from local filesystem to `destination_dir` on the remote node associated with this remote session. Args: - source_file: the file on the local filesystem. - destination_file: a file or directory path on the remote node. + source_file: The file on the local filesystem. + destination_dir: The directory path on the remote Node where the `source_file` + will be saved. """ @abstractmethod diff --git a/dts/framework/testbed_model/posix_session.py b/dts/framework/testbed_model/posix_session.py index d279bb8b53..2449c0ab35 100644 --- a/dts/framework/testbed_model/posix_session.py +++ b/dts/framework/testbed_model/posix_session.py @@ -13,7 +13,7 @@ import re from collections.abc import Iterable -from pathlib import PurePath, PurePosixPath +from pathlib import Path, PurePath, PurePosixPath from framework.config import Architecture, NodeInfo from framework.exception import DPDKBuildError, RemoteCommandExecutionError @@ -85,21 +85,13 @@ def join_remote_path(self, *args: str | PurePath) -> PurePosixPath: """Overrides :meth:`~.os_session.OSSession.join_remote_path`.""" return PurePosixPath(*args) - def copy_from( - self, - source_file: str | PurePath, - destination_file: str | PurePath, - ) -> None: + def copy_from(self, source_file: str | PurePath, destination_dir: str | Path) -> None: """Overrides :meth:`~.os_session.OSSession.copy_from`.""" - self.remote_session.copy_from(source_file, destination_file) + self.remote_session.copy_from(source_file, destination_dir) - def copy_to( - self, - source_file: str | PurePath, - destination_file: str | PurePath, - ) -> None: + def copy_to(self, source_file: str | Path, destination_dir: str | PurePath) -> None: """Overrides :meth:`~.os_session.OSSession.copy_to`.""" - self.remote_session.copy_to(source_file, destination_file) + self.remote_session.copy_to(source_file, destination_dir) def remove_remote_dir( self, -- 2.46.1