speedtest-ssh 2.10.1__tar.gz → 2.11.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {speedtest_ssh-2.10.1/speedtest_ssh.egg-info → speedtest_ssh-2.11.0}/PKG-INFO +1 -1
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0}/pyproject.toml +3 -2
- speedtest_ssh-2.11.0/speedtest_ssh/_version.py +1 -0
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0}/speedtest_ssh/data_transfer.py +5 -5
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0}/speedtest_ssh/ping.py +0 -1
- speedtest_ssh-2.11.0/speedtest_ssh/py.typed +1 -0
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0}/speedtest_ssh/speedtest_ssh.py +17 -16
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0}/speedtest_ssh/util.py +1 -2
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0/speedtest_ssh.egg-info}/PKG-INFO +1 -1
- speedtest_ssh-2.10.1/speedtest_ssh/_version.py +0 -1
- speedtest_ssh-2.10.1/speedtest_ssh/py.typed +0 -1
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0}/LICENSE +0 -0
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0}/README.md +0 -0
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0}/setup.cfg +0 -0
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0}/speedtest_ssh/__init__.py +0 -0
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0}/speedtest_ssh/config.py +0 -0
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0}/speedtest_ssh/sftp_wrapper.py +0 -0
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0}/speedtest_ssh.egg-info/SOURCES.txt +0 -0
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0}/speedtest_ssh.egg-info/dependency_links.txt +0 -0
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0}/speedtest_ssh.egg-info/entry_points.txt +0 -0
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0}/speedtest_ssh.egg-info/requires.txt +0 -0
- {speedtest_ssh-2.10.1 → speedtest_ssh-2.11.0}/speedtest_ssh.egg-info/top_level.txt +0 -0
|
@@ -55,9 +55,10 @@ line-length = 120
|
|
|
55
55
|
target-version = ["py312"]
|
|
56
56
|
|
|
57
57
|
[tool.ruff]
|
|
58
|
-
ignore = ["E731"]
|
|
59
58
|
line-length = 120
|
|
60
|
-
[tool.ruff.
|
|
59
|
+
[tool.ruff.lint]
|
|
60
|
+
ignore = ["E731", "I001"]
|
|
61
|
+
[tool.ruff.lint.per-file-ignores]
|
|
61
62
|
"__init__.py" = ["F401", "F403"]
|
|
62
63
|
|
|
63
64
|
[tool.bandit]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__: str = "2.11.0"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from subprocess import CalledProcessError, PIPE
|
|
3
3
|
from logging import getLogger, DEBUG, INFO
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
5
|
-
from datetime import datetime
|
|
4
|
+
from typing import TYPE_CHECKING, Self
|
|
5
|
+
from datetime import UTC, datetime
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
import random
|
|
8
8
|
import string
|
|
@@ -19,7 +19,7 @@ if TYPE_CHECKING:
|
|
|
19
19
|
from paramiko import SFTPClient
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
__all__ = ("
|
|
22
|
+
__all__ = ("SFTP", "DataTransfer", "Rsync")
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
_dict = string.ascii_uppercase + string.ascii_lowercase + string.digits
|
|
@@ -61,14 +61,14 @@ class DataTransfer:
|
|
|
61
61
|
:param config: The Config object the DataTransfer instance should use
|
|
62
62
|
"""
|
|
63
63
|
self._l = getLogger(self._LOG)
|
|
64
|
-
self._remote_f: str = f"/tmp/speedtest-ssh_{datetime.now()}_{_rand_str(8)}.tmp"
|
|
64
|
+
self._remote_f: str = f"/tmp/speedtest-ssh_{datetime.now(tz=UTC)}_{_rand_str(8)}.tmp"
|
|
65
65
|
self._remote_f = self._remote_f.replace(":", "-").replace(" ", "_")
|
|
66
66
|
# We promise that _remote_f components match: ^[a-zA-Z\d_.-]+$ (old rsync args suck)
|
|
67
67
|
self._l.debug("Parsing ssh config and loading keys...")
|
|
68
68
|
self._sftp_cm = sftp_wrapper(config)
|
|
69
69
|
self._sftp: SFTPClient # Defined in __enter__
|
|
70
70
|
|
|
71
|
-
def __enter__(self) ->
|
|
71
|
+
def __enter__(self) -> Self:
|
|
72
72
|
self._l.debug("Chosen remote file name: %s", self._remote_f)
|
|
73
73
|
self._sftp = self._sftp_cm.__enter__()
|
|
74
74
|
return self
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -14,7 +14,6 @@ from .data_transfer import DataTransfer, SFTP, Rsync
|
|
|
14
14
|
from .ping import ping as ping_test
|
|
15
15
|
from ._version import __version__
|
|
16
16
|
|
|
17
|
-
|
|
18
17
|
base_size = 2 * (1024**2)
|
|
19
18
|
_password_env_name = "SPEEDTEST_SSH_PASSWORD" # nosec B105
|
|
20
19
|
_LOG_VERBOSITY: dict[int, int] = {0: WARNING, 1: INFO, 2: DEBUG}
|
|
@@ -72,21 +71,23 @@ def speedtest_ssh(seconds: int, ping: bool, mode: str, conf: Config) -> None:
|
|
|
72
71
|
log = getLogger(_LOG)
|
|
73
72
|
ping_delay: float | None = ping_test(conf.host) if ping else None
|
|
74
73
|
print("Connecting...")
|
|
75
|
-
with (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
74
|
+
with (
|
|
75
|
+
(Rsync if mode == "rsync" else SFTP)(conf) as remote,
|
|
76
|
+
NTF(prefix="speedtest_ssh.", dir="/tmp", delete_on_close=False) as ntf,
|
|
77
|
+
):
|
|
78
|
+
ntf.close()
|
|
79
|
+
temp = Path(ntf.name)
|
|
80
|
+
log.debug("Created temporary file: %s", temp)
|
|
81
|
+
print("Testing...")
|
|
82
|
+
nano_sec: int = 0
|
|
83
|
+
size: int = base_size
|
|
84
|
+
remaining: int = int(1e9) * seconds
|
|
85
|
+
while int(1.5 * nano_sec) < remaining - 1: # Try to get close to seconds
|
|
86
|
+
size *= 2 ** (0 if not nano_sec else max(1, int(math.log2(remaining / nano_sec))))
|
|
87
|
+
# ^ Faster than just *=2
|
|
88
|
+
up_t, down_t = _iteration(temp, remote, size)
|
|
89
|
+
nano_sec = up_t + down_t
|
|
90
|
+
remaining -= nano_sec
|
|
90
91
|
log.debug(f"\n{'*'*30} Final Results {'*'*30}")
|
|
91
92
|
_print_results(ping_delay, up_t, down_t, size)
|
|
92
93
|
|
|
@@ -5,7 +5,6 @@ import subprocess
|
|
|
5
5
|
import shlex
|
|
6
6
|
import os
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
__all__ = ("find_exe", "run_cmd")
|
|
10
9
|
|
|
11
10
|
|
|
@@ -43,7 +42,7 @@ def run_cmd(cmd: Path, *args: str | Path, **kwargs) -> subprocess.CompletedProce
|
|
|
43
42
|
:return: Completed process
|
|
44
43
|
"""
|
|
45
44
|
_log_cmd(cmd, args)
|
|
46
|
-
return subprocess.run((cmd, *args), **kwargs) # nosec B603
|
|
45
|
+
return subprocess.run((cmd, *args), **kwargs) # nosec B603 # noqa: PLW1510
|
|
47
46
|
|
|
48
47
|
|
|
49
48
|
def tee_cmd(cmd: Path, *args: str | Path, level: int, **kwargs) -> tuple[subprocess.Popen, str]:
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__: str = "2.10.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
PARTIAL
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|