Skip to content

Commit 7dc47d1

Browse files
committed
revert 979311c (abandon new show hash proposal) but improve typing
1 parent d9fdad3 commit 7dc47d1

File tree

4 files changed

+9
-34
lines changed

4 files changed

+9
-34
lines changed

src/flockwave/server/ext/crazyflie/driver.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,7 @@ async def handle_command_trick(self, uav: "CrazyflieUAV", *params: str) -> str:
392392
)
393393

394394
async def handle_command___show_upload(
395-
self,
396-
uav: "CrazyflieUAV",
397-
*,
398-
show: ShowSpecification,
399-
show_hash: str | None = None,
395+
self, uav: "CrazyflieUAV", *, show: ShowSpecification
400396
):
401397
"""Handles a drone show upload request for the given UAV.
402398
@@ -405,7 +401,6 @@ async def handle_command___show_upload(
405401
406402
Parameters:
407403
show: the show data for a single UAV
408-
show_hash: the hash of the entire show data for all UAVs
409404
"""
410405
await uav.upload_show(show, remember=True)
411406
if self.preferred_controller is not None:

src/flockwave/server/ext/mavlink/driver.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,7 @@ async def handle_command_show(self, uav: "MAVLinkUAV", command: str | None = Non
385385
raise RuntimeError(f"Unknown subcommand: {command!r}")
386386

387387
async def handle_command___show_upload(
388-
self,
389-
uav: "MAVLinkUAV",
390-
*,
391-
show: ShowSpecification,
392-
show_hash: str | None = None,
388+
self, uav: "MAVLinkUAV", *, show: ShowSpecification
393389
):
394390
"""Handles a drone show upload request for the given UAV.
395391
@@ -398,7 +394,6 @@ async def handle_command___show_upload(
398394
399395
Parameters:
400396
show: the show data for a single UAV
401-
show_hash: optional hash of the entire global show configuration
402397
"""
403398
try:
404399
await uav.upload_show(show)

src/flockwave/server/ext/show/logging.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ class ShowUploadLoggingMiddleware:
4747
Used to decide whether it's a new show upload or most likely not.
4848
"""
4949

50-
_last_show_upload_hash: str | None = None
51-
"""The hash of the last show upload that was seen by the middleware."""
52-
5350
_log: Logger
5451
"""Logger that the middleware will write to."""
5552

@@ -63,14 +60,13 @@ def __init__(self, log: Logger):
6360
self._log = log
6461

6562
def __call__(self, message: FlockwaveMessage, sender: Client) -> FlockwaveMessage:
66-
show, show_hash = self._extract_show_and_hash(message)
63+
show = self._extract_show(message)
6764
if show:
6865
now = monotonic()
6966
fingerprint = self._get_show_fingerprint(show)
7067

7168
should_log = (
72-
show_hash != self._last_show_upload_hash
73-
or fingerprint != self._last_show_upload_fingerprint
69+
fingerprint != self._last_show_upload_fingerprint
7470
or now - self._last_show_upload_command_at >= 30
7571
)
7672
if should_log:
@@ -85,26 +81,20 @@ def __call__(self, message: FlockwaveMessage, sender: Client) -> FlockwaveMessag
8581

8682
self._last_show_upload_command_at = now
8783
self._last_show_upload_fingerprint = fingerprint
88-
self._last_show_upload_hash = show_hash
8984

9085
return message
9186

92-
def _extract_show_and_hash(
93-
self, message: FlockwaveMessage
94-
) -> tuple[ShowSpecification | None, str | None]:
87+
def _extract_show(self, message: FlockwaveMessage) -> ShowSpecification | None:
9588
"""Checks whether the given message is a show upload and extracts the
96-
show specification and the show hash out of the message if it is.
89+
show specification out of the message if it is.
9790
"""
9891
type = message.get_type()
9992
if type == "OBJ-CMD":
10093
cmd = message.body.get("command", "")
10194
if cmd == "__show_upload":
10295
kwds = message.body.get("kwds", {})
103-
if isinstance(kwds, dict):
104-
show = kwds.get("show", None)
105-
show_hash = kwds.get("show_hash", None)
106-
return show, show_hash
107-
return None, None
96+
if isinstance(kwds, dict) and "show" in kwds:
97+
return kwds["show"]
10898

10999
@property
110100
def last_show_metadata(self) -> ShowMetadata | None:

src/flockwave/server/ext/virtual_uavs/driver.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,11 +1166,7 @@ async def handle_command___mission_upload(
11661166
await sleep(0.25 + random() * 0.5)
11671167

11681168
async def handle_command___show_upload(
1169-
self,
1170-
uav: VirtualUAV,
1171-
*,
1172-
show: ShowSpecification,
1173-
show_hash: str | None = None,
1169+
self, uav: VirtualUAV, *, show: ShowSpecification
11741170
) -> None:
11751171
"""Handles a drone show upload request for the given UAV.
11761172
@@ -1179,7 +1175,6 @@ async def handle_command___show_upload(
11791175
11801176
Parameters:
11811177
show: the show data for a single UAV
1182-
show_hash: optional hash of the entire global show configuration
11831178
"""
11841179
uav.handle_show_upload(show)
11851180
await sleep(0.25 + random() * 0.5)

0 commit comments

Comments
 (0)