feat: localize K1 console to Russian
This commit is contained in:
+18
-11
@@ -80,7 +80,7 @@ class ConsoleService:
|
||||
message = runtime["message"]
|
||||
elif selected_device_id is not None:
|
||||
phase = "device_selected"
|
||||
message = "K1 selected; Wi-Fi credentials have not been written."
|
||||
message = "K1 выбран. Теперь введите название и пароль Wi-Fi."
|
||||
else:
|
||||
phase = "idle"
|
||||
message = runtime["message"]
|
||||
@@ -107,7 +107,7 @@ class ConsoleService:
|
||||
}
|
||||
|
||||
async def scan_ble(self, duration_seconds: float) -> dict[str, Any]:
|
||||
self._set_operation("scanning", "Scanning for nearby K1 BLE advertisements.")
|
||||
self._set_operation("scanning", "Ищем K1 по Bluetooth (BLE)…")
|
||||
try:
|
||||
result = await scan(duration_seconds)
|
||||
devices = [
|
||||
@@ -125,7 +125,9 @@ class ConsoleService:
|
||||
self._devices = devices
|
||||
if len(devices) == 1:
|
||||
self._selected_device_id = str(devices[0]["device_id"])
|
||||
self._operation_message = f"BLE scan complete: {len(devices)} K1 candidate(s)."
|
||||
self._operation_message = (
|
||||
f"Поиск завершён. Найдено устройств K1: {len(devices)}."
|
||||
)
|
||||
finally:
|
||||
with self._lock:
|
||||
self._operation_phase = None
|
||||
@@ -134,10 +136,10 @@ class ConsoleService:
|
||||
async def connect(self, request: ConnectRequest) -> dict[str, Any]:
|
||||
known_ids = {str(item["device_id"]) for item in self.state()["devices"]}
|
||||
if request.device_id not in known_ids:
|
||||
raise ValueError("device_id must come from the latest K1 BLE scan")
|
||||
raise ValueError("сначала найдите и выберите K1 через Bluetooth")
|
||||
self._set_operation(
|
||||
"provisioning",
|
||||
"Sending one explicitly requested Wi-Fi provisioning write.",
|
||||
"Передаём в K1 настройки Wi-Fi одним подтверждённым запросом.",
|
||||
)
|
||||
session_dir = _new_operation_session_dir(
|
||||
self.repository_root,
|
||||
@@ -170,12 +172,12 @@ class ConsoleService:
|
||||
)
|
||||
if ipv4 is None:
|
||||
raise RuntimeError(
|
||||
"K1 did not report a non-AP LAN address; no automatic retry was made"
|
||||
"K1 не сообщил адрес в локальной сети; автоматического повтора не было"
|
||||
)
|
||||
with self._lock:
|
||||
self._selected_device_id = request.device_id
|
||||
self._k1_ip = ipv4
|
||||
self._operation_message = "K1 joined the LAN and reported its private address."
|
||||
self._operation_message = "K1 подключён к Wi-Fi и сообщил локальный адрес."
|
||||
finally:
|
||||
password = ""
|
||||
with self._lock:
|
||||
@@ -185,7 +187,9 @@ class ConsoleService:
|
||||
def start_live(self, host: str | None, duration_seconds: float) -> dict[str, Any]:
|
||||
target = host or self.state()["k1_ip"]
|
||||
if not isinstance(target, str) or not target:
|
||||
raise ValueError("live host is required until BLE provisioning reports a K1 address")
|
||||
raise ValueError(
|
||||
"сначала подключите K1 к Wi-Fi или укажите его локальный адрес"
|
||||
)
|
||||
target = validate_private_ipv4(target)
|
||||
out_dir = new_live_session_dir(self.repository_root)
|
||||
self.runtime.start_live(target, out_dir, duration_seconds=duration_seconds)
|
||||
@@ -194,7 +198,7 @@ class ConsoleService:
|
||||
def start_replay(self, path: str, speed: float, loop: bool) -> dict[str, Any]:
|
||||
replay_path = Path(path).expanduser().resolve()
|
||||
if not replay_path.is_relative_to(self.repository_root):
|
||||
raise ValueError("replay path must remain inside this repository")
|
||||
raise ValueError("файл записи должен находиться внутри репозитория")
|
||||
self.runtime.start_replay(replay_path, speed=speed, loop=loop)
|
||||
return self.state()
|
||||
|
||||
@@ -238,7 +242,7 @@ async def scan_ble(request: BleScanRequest) -> dict[str, Any]:
|
||||
try:
|
||||
return await service.scan_ble(request.duration_seconds)
|
||||
except (BleakError, OSError, RuntimeError, ValueError) as exc:
|
||||
raise HTTPException(status_code=502, detail=f"BLE scan failed: {exc}") from exc
|
||||
raise HTTPException(status_code=502, detail=f"Ошибка поиска BLE: {exc}") from exc
|
||||
|
||||
|
||||
@app.post("/api/connect")
|
||||
@@ -246,7 +250,10 @@ async def connect(request: ConnectRequest) -> dict[str, Any]:
|
||||
try:
|
||||
return await service.connect(request)
|
||||
except (BleakError, OSError, TimeoutError, RuntimeError, ValueError) as exc:
|
||||
raise HTTPException(status_code=502, detail=f"Wi-Fi provisioning failed: {exc}") from exc
|
||||
raise HTTPException(
|
||||
status_code=502,
|
||||
detail=f"Ошибка подключения K1 к Wi-Fi: {exc}",
|
||||
) from exc
|
||||
|
||||
|
||||
@app.post("/api/session/live")
|
||||
|
||||
Reference in New Issue
Block a user