From: "Tomáš Ďurovec" <tomas.durovec@pantheon.tech>
To: dev@dpdk.org, Luca.Vizzarro@arm.com, probb@iol.unh.edu,
npratte@iol.unh.edu, dmarx@iol.unh.edu
Cc: "Tomáš Ďurovec" <tomas.durovec@pantheon.tech>
Subject: [PATCH 3/7] dts: fix remote session file transfer vars
Date: Fri, 27 Sep 2024 18:08:50 +0200 [thread overview]
Message-ID: <20240927160854.279253-4-tomas.durovec@pantheon.tech> (raw)
In-Reply-To: <20240927160854.279253-1-tomas.durovec@pantheon.tech>
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 <tomas.durovec@pantheon.tech>
---
.../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
next prev parent reply other threads:[~2024-09-27 22:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-27 16:08 [PATCH 0/7] DTS external DPDK build Tomáš Ďurovec
2024-09-27 16:08 ` [PATCH 1/7] dts: rename build target to " Tomáš Ďurovec
2024-09-27 16:08 ` [PATCH 2/7] dts: one dpdk build per test run Tomáš Ďurovec
2024-09-27 16:08 ` Tomáš Ďurovec [this message]
2024-09-27 16:08 ` [PATCH 4/7] dts: add the ability to copy directories via remote Tomáš Ďurovec
2024-09-27 16:08 ` [PATCH 5/7] dts: add support for externally compiled DPDK Tomáš Ďurovec
2024-09-27 16:08 ` [PATCH 6/7] doc: update argument options for external DPDK build Tomáš Ďurovec
2024-09-27 16:08 ` [PATCH 7/7] dts: remove git ref option Tomáš Ďurovec
-- strict thread matches above, loose matches on Subject: below --
2024-09-30 16:18 [PATCH 0/7] DTS external DPDK build Tomáš Ďurovec
2024-09-30 16:18 ` [PATCH 3/7] dts: fix remote session file transfer vars Tomáš Ďurovec
2024-09-30 16:01 [PATCH 0/7] DTS external DPDK build Tomáš Ďurovec
2024-09-30 16:02 ` [PATCH 3/7] dts: fix remote session file transfer vars Tomáš Ďurovec
2024-09-27 15:38 [PATCH 1/7] dts: rename build target to DPDK build Tomáš Ďurovec
2024-09-27 15:38 ` [PATCH 3/7] dts: fix remote session file transfer vars Tomáš Ďurovec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240927160854.279253-4-tomas.durovec@pantheon.tech \
--to=tomas.durovec@pantheon.tech \
--cc=Luca.Vizzarro@arm.com \
--cc=dev@dpdk.org \
--cc=dmarx@iol.unh.edu \
--cc=npratte@iol.unh.edu \
--cc=probb@iol.unh.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).