21 lines
651 B
Python
21 lines
651 B
Python
# core/commands/check.py
|
|
from core.connection import BuzzerError
|
|
|
|
def execute(conn, path: str) -> dict:
|
|
"""Holt die CRC32 einer datei und gibt sie als Int zurück."""
|
|
lines = conn.send_command("check " + path)
|
|
if not lines:
|
|
raise BuzzerError("Keine Antwort auf 'check' empfangen.")
|
|
|
|
parts = lines[0].split()
|
|
if len(parts) != 3 or parts[0] != "CRC32":
|
|
raise BuzzerError(f"Unerwartetes Check-Format: {lines[0]}")
|
|
|
|
if parts[1] != path:
|
|
raise BuzzerError(f"Unerwarteter Pfad in Check-Antwort: {parts[1]} (erwartet: {path})")
|
|
|
|
crc32 = int(parts[2], 16)
|
|
|
|
return {
|
|
"crc32": crc32
|
|
} |