speedtest-ssh 2.10.0__tar.gz → 2.10.2__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.
Files changed (21) hide show
  1. {speedtest_ssh-2.10.0/speedtest_ssh.egg-info → speedtest_ssh-2.10.2}/PKG-INFO +3 -2
  2. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/pyproject.toml +3 -2
  3. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/speedtest_ssh/__init__.py +1 -0
  4. speedtest_ssh-2.10.2/speedtest_ssh/_version.py +1 -0
  5. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/speedtest_ssh/data_transfer.py +5 -5
  6. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/speedtest_ssh/ping.py +0 -1
  7. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/speedtest_ssh/speedtest_ssh.py +17 -16
  8. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/speedtest_ssh/util.py +1 -2
  9. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2/speedtest_ssh.egg-info}/PKG-INFO +3 -2
  10. speedtest_ssh-2.10.0/speedtest_ssh/_version.py +0 -1
  11. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/LICENSE +0 -0
  12. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/README.md +0 -0
  13. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/setup.cfg +0 -0
  14. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/speedtest_ssh/config.py +0 -0
  15. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/speedtest_ssh/py.typed +0 -0
  16. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/speedtest_ssh/sftp_wrapper.py +0 -0
  17. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/speedtest_ssh.egg-info/SOURCES.txt +0 -0
  18. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/speedtest_ssh.egg-info/dependency_links.txt +0 -0
  19. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/speedtest_ssh.egg-info/entry_points.txt +0 -0
  20. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/speedtest_ssh.egg-info/requires.txt +0 -0
  21. {speedtest_ssh-2.10.0 → speedtest_ssh-2.10.2}/speedtest_ssh.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: speedtest_ssh
3
- Version: 2.10.0
3
+ Version: 2.10.2
4
4
  Summary: A tool meant to check inter-device speeds via ssh
5
5
  License: GPL
6
6
  Project-URL: Homepage, https://github.com/zwimer/speedtest_ssh
@@ -12,6 +12,7 @@ License-File: LICENSE
12
12
  Requires-Dist: argcomplete
13
13
  Requires-Dist: paramiko
14
14
  Requires-Dist: tqdm
15
+ Dynamic: license-file
15
16
 
16
17
  # speedtest\_ssh
17
18
  A simple tool for a quick and easy speedtest between two machines using ssh
@@ -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.per-file-ignores]
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]
@@ -1,3 +1,4 @@
1
+ # PYTHON_ARGCOMPLETE_OK
1
2
  from ._version import __version__
2
3
 
3
4
  from .speedtest_ssh import cli
@@ -0,0 +1 @@
1
+ __version__: str = "2.10.2"
@@ -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__ = ("DataTransfer", "SFTP", "Rsync")
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) -> DataTransfer:
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
@@ -4,7 +4,6 @@ from sys import platform
4
4
 
5
5
  from .util import find_exe, tee_cmd
6
6
 
7
-
8
7
  __all__ = ("PingFailed", "ping")
9
8
 
10
9
 
@@ -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 (Rsync if mode == "rsync" else SFTP)(conf) as remote:
76
- with NTF(prefix="speedtest_ssh.", dir="/tmp", delete_on_close=False) as ntf:
77
- ntf.close()
78
- temp = Path(ntf.name)
79
- log.debug("Created temporary file: %s", temp)
80
- print("Testing...")
81
- nano_sec: int = 0
82
- size: int = base_size
83
- remaining: int = int(1e9) * seconds
84
- while int(1.5 * nano_sec) < remaining - 1: # Try to get close to seconds
85
- size *= 2 ** (0 if not nano_sec else max(1, int(math.log(remaining / nano_sec, 2))))
86
- # ^ Faster than just *=2
87
- up_t, down_t = _iteration(temp, remote, size)
88
- nano_sec = up_t + down_t
89
- remaining -= nano_sec
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,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: speedtest_ssh
3
- Version: 2.10.0
3
+ Version: 2.10.2
4
4
  Summary: A tool meant to check inter-device speeds via ssh
5
5
  License: GPL
6
6
  Project-URL: Homepage, https://github.com/zwimer/speedtest_ssh
@@ -12,6 +12,7 @@ License-File: LICENSE
12
12
  Requires-Dist: argcomplete
13
13
  Requires-Dist: paramiko
14
14
  Requires-Dist: tqdm
15
+ Dynamic: license-file
15
16
 
16
17
  # speedtest\_ssh
17
18
  A simple tool for a quick and easy speedtest between two machines using ssh
@@ -1 +0,0 @@
1
- __version__: str = "2.10.0"
File without changes
File without changes
File without changes