koebelt-dash-scripts 1.3.0b2__tar.gz → 1.3.0b3__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.
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/PKG-INFO +1 -1
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts/__init__.py +1 -1
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts/client.py +23 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts/errors.py +3 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts.egg-info/PKG-INFO +1 -1
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/pyproject.toml +1 -1
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/tests/test_errors.py +10 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/LICENSE +0 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/README.md +0 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts/__main__.py +0 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts/camera.py +0 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts/host.py +0 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts/py.typed +0 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts/tools.py +0 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts.egg-info/SOURCES.txt +0 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts.egg-info/dependency_links.txt +0 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts.egg-info/entry_points.txt +0 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts.egg-info/requires.txt +0 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts.egg-info/top_level.txt +0 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/setup.cfg +0 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/tests/test_camera.py +0 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/tests/test_client.py +0 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/tests/test_host.py +0 -0
- {koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/tests/test_tools.py +0 -0
{koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts/__init__.py
RENAMED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
dev.sticks(throttle=0.3)
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
-
__version__ = "1.3.
|
|
9
|
+
__version__ = "1.3.0b3"
|
|
10
10
|
|
|
11
11
|
from .camera import Camera, CameraError, decode_jpeg # noqa: E402
|
|
12
12
|
from .client import Device, Released, ScriptError, Setting, Telemetry, connect, every, wait # noqa: E402
|
{koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts/client.py
RENAMED
|
@@ -526,11 +526,34 @@ def connect(device: Optional[str] = None, *, url: Optional[str] = None, token: O
|
|
|
526
526
|
ws.close()
|
|
527
527
|
raise ScriptError("E0012", {"reason": welcome.get("why") or "no reason given"})
|
|
528
528
|
dev = Device(ws, welcome, name)
|
|
529
|
+
_check_version(welcome.get("app"))
|
|
529
530
|
dev._use(device)
|
|
530
531
|
_current = dev
|
|
531
532
|
return dev
|
|
532
533
|
|
|
533
534
|
|
|
535
|
+
def _version_key(v: str):
|
|
536
|
+
"""1.3.0b2 or 1.3.0-beta.2 → a sortable tuple (a release after its betas)."""
|
|
537
|
+
import re
|
|
538
|
+
m = re.match(r"^(\d+)\.(\d+)\.(\d+)(?:-?(a|alpha|b|beta|rc)\.?(\d+))?", v or "")
|
|
539
|
+
if not m:
|
|
540
|
+
return None
|
|
541
|
+
stage = {"a": 0, "alpha": 0, "b": 1, "beta": 1, "rc": 2}.get(m.group(4) or "", 3)
|
|
542
|
+
return (int(m.group(1)), int(m.group(2)), int(m.group(3)), stage, int(m.group(5) or 0))
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
def _check_version(app: Optional[str]) -> None:
|
|
546
|
+
"""Warns once when this library is older than the dash it talks to."""
|
|
547
|
+
from . import __version__
|
|
548
|
+
have, want = _version_key(__version__), _version_key(app or "")
|
|
549
|
+
if have is None or want is None or have >= want:
|
|
550
|
+
return
|
|
551
|
+
# The package is released with the app, at its version: ask for at least that one.
|
|
552
|
+
major, minor, patch, stage, n = want
|
|
553
|
+
pep = f"{major}.{minor}.{patch}" + ("" if stage == 3 else f"{['a', 'b', 'rc'][stage]}{n}")
|
|
554
|
+
warn_once("W0102", "version", {"have": __version__, "app": app, "spec": f">={pep},<2"})
|
|
555
|
+
|
|
556
|
+
|
|
534
557
|
def every(seconds: float) -> Iterator[int]:
|
|
535
558
|
"""A steady loop: ``for i in every(0.05): ...`` runs the body every 50 ms
|
|
536
559
|
(or as fast as it can), and reports the real rate to dash."""
|
{koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts/errors.py
RENAMED
|
@@ -139,6 +139,9 @@ CATALOG: Dict[str, Tuple[str, str, str]] = {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
WARNINGS: Dict[str, Tuple[str, str, str]] = {
|
|
142
|
+
"W0102": ("koebelt-dash-scripts {have} is older than koebelt dash {app}",
|
|
143
|
+
"a newer library may fix bugs or add what this dash offers; this one still works with it",
|
|
144
|
+
"pip install --upgrade \"koebelt-dash-scripts{spec}\" (in dash: the script's panel > Update)"),
|
|
142
145
|
"W0201": ("{name}={value} is outside −1…1: dash uses {clamped}",
|
|
143
146
|
"sticks go from −1 to 1",
|
|
144
147
|
"clamp it yourself (koebelt_dash_scripts.clamp) to silence this"),
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "koebelt-dash-scripts"
|
|
7
|
-
version = "1.3.
|
|
7
|
+
version = "1.3.0b3"
|
|
8
8
|
description = "Control drones, robots and test rigs connected in the koebelt/dash app from Python."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -89,3 +89,13 @@ def test_an_uncaught_error_prints_rust_style_without_the_librarys_traceback(tmp_
|
|
|
89
89
|
assert "--> my_script.py:4" in r.stderr and "k.connect()" in r.stderr
|
|
90
90
|
assert "called from: my_script.py:6 <module>()" in r.stderr
|
|
91
91
|
assert "Traceback" not in r.stderr and "client.py" not in r.stderr
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_warns_when_older_than_dash(dash, capsys): # noqa: F811
|
|
95
|
+
from koebelt_dash_scripts import client
|
|
96
|
+
client._check_version("9.0.0")
|
|
97
|
+
assert "warning[W0102]: koebelt-dash-scripts" in capsys.readouterr().err
|
|
98
|
+
client._check_version("0.1.0")
|
|
99
|
+
client._check_version(k.__version__)
|
|
100
|
+
assert capsys.readouterr().err == "", "not older: no warning"
|
|
101
|
+
assert client._version_key("1.3.0b2") < client._version_key("1.3.0-beta.3") < client._version_key("1.3.0rc1") < client._version_key("1.3.0")
|
|
File without changes
|
|
File without changes
|
{koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts/__main__.py
RENAMED
|
File without changes
|
{koebelt_dash_scripts-1.3.0b2 → koebelt_dash_scripts-1.3.0b3}/koebelt_dash_scripts/camera.py
RENAMED
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|