dutchmate-cli 0.1.0__tar.gz → 0.2.0__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 (26) hide show
  1. dutchmate_cli-0.2.0/LICENSE +18 -0
  2. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/PKG-INFO +3 -3
  3. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/pyproject.toml +3 -3
  4. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/pyproject.toml.orig +3 -3
  5. dutchmate_cli-0.2.0/src/dutchmate_cli/capture.py +9 -0
  6. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/src/dutchmate_cli/client.py +159 -31
  7. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/src/dutchmate_cli/config.py +5 -9
  8. dutchmate_cli-0.2.0/src/dutchmate_cli/console.py +90 -0
  9. dutchmate_cli-0.2.0/src/dutchmate_cli/follow.py +100 -0
  10. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/src/dutchmate_cli/lifecycle.py +33 -9
  11. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/src/dutchmate_cli/main.py +172 -59
  12. dutchmate_cli-0.2.0/src/dutchmate_cli/monitor.py +42 -0
  13. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/src/dutchmate_cli/send.py +9 -13
  14. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/src/dutchmate_cli/sessions.py +11 -2
  15. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/src/dutchmate_cli/status.py +90 -5
  16. dutchmate_cli-0.2.0/src/dutchmate_cli/wait.py +9 -0
  17. dutchmate_cli-0.1.0/LICENSE +0 -73
  18. dutchmate_cli-0.1.0/src/dutchmate_cli/capture.py +0 -94
  19. dutchmate_cli-0.1.0/src/dutchmate_cli/wait.py +0 -41
  20. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/src/dutchmate_cli/__init__.py +0 -0
  21. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/src/dutchmate_cli/baseline.py +0 -0
  22. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/src/dutchmate_cli/devices.py +0 -0
  23. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/src/dutchmate_cli/dut.py +0 -0
  24. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/src/dutchmate_cli/gpio.py +0 -0
  25. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/src/dutchmate_cli/logs.py +0 -0
  26. {dutchmate_cli-0.1.0 → dutchmate_cli-0.2.0}/src/dutchmate_cli/mcp.py +0 -0
@@ -0,0 +1,18 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nahit Pawar and DUTchMate contributors.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
+ associated documentation files (the "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial
12
+ portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
16
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dutchmate-cli
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: DUTchMate command-line interface.
5
5
  Author: Nahit Pawar
6
- License-Expression: Apache-2.0
6
+ License-Expression: MIT
7
7
  License-File: LICENSE
8
- Requires-Dist: dutchmate-core==0.1.0
8
+ Requires-Dist: dutchmate-core==0.2.0
9
9
  Requires-Dist: httpx>=0.27
10
10
  Requires-Dist: tomli>=2.0 ; python_full_version < '3.11'
11
11
  Requires-Dist: typer>=0.12
@@ -1,12 +1,12 @@
1
1
  [project]
2
2
  name = "dutchmate-cli"
3
- version = "0.1.0"
3
+ version = "0.2.0"
4
4
  description = "DUTchMate command-line interface."
5
5
  requires-python = ">=3.10"
6
- license = "Apache-2.0"
6
+ license = "MIT"
7
7
  license-files = ["LICENSE"]
8
8
  dependencies = [
9
- "dutchmate-core==0.1.0",
9
+ "dutchmate-core==0.2.0",
10
10
  "httpx>=0.27",
11
11
  "tomli>=2.0; python_version < '3.11'",
12
12
  "typer>=0.12",
@@ -1,13 +1,13 @@
1
1
  [project]
2
2
  name = "dutchmate-cli"
3
- version = "0.1.0"
3
+ version = "0.2.0"
4
4
  description = "DUTchMate command-line interface."
5
5
  requires-python = ">=3.10"
6
- license = "Apache-2.0"
6
+ license = "MIT"
7
7
  license-files = ["LICENSE"]
8
8
  authors = [{ name = "Nahit Pawar" }]
9
9
  dependencies = [
10
- "dutchmate-core==0.1.0",
10
+ "dutchmate-core==0.2.0",
11
11
  "httpx>=0.27",
12
12
  "tomli>=2.0; python_version < '3.11'",
13
13
  "typer>=0.12",
@@ -0,0 +1,9 @@
1
+ """CLI formatting for the thin capture Monitor alias."""
2
+
3
+ from collections.abc import Mapping
4
+
5
+ from dutchmate_cli.monitor import format_monitor_result
6
+
7
+
8
+ def format_capture_result(payload: Mapping[str, object]) -> str:
9
+ return format_monitor_result(payload).replace("Monitor", "Capture", 1)
@@ -8,8 +8,11 @@ from urllib.parse import quote
8
8
 
9
9
  import httpx
10
10
 
11
+ from dutchmate_core.evidence.tail import validate_evidence_query
12
+ from dutchmate_core.operations import MonitorCondition
13
+ from dutchmate_core.operations.monitor import validate_monitor_request
11
14
  from dutchmate_core.validation import (
12
- prepare_uart_send_payload,
15
+ prepare_uart_tx_payload,
13
16
  validate_capture_duration,
14
17
  validate_gpio_configuration,
15
18
  validate_session_id,
@@ -54,6 +57,46 @@ def fetch_status(
54
57
  return _response_payload(response, description="status payload")
55
58
 
56
59
 
60
+ def change_connection(
61
+ action: str,
62
+ *,
63
+ service_url: str = DEFAULT_SERVICE_URL,
64
+ transport: httpx.BaseTransport | None = None,
65
+ ) -> dict[str, object]:
66
+ """Request atomic ownership transfer; no local serial access."""
67
+ if action not in {"release", "reacquire"}:
68
+ raise ValueError("Unknown connection lifecycle action")
69
+ response = _request_service(
70
+ method="POST",
71
+ path=f"/connection/{action}",
72
+ service_url=service_url,
73
+ transport=transport,
74
+ timeout_s=65.0,
75
+ )
76
+ return _response_payload(response, description="connection boundary")
77
+
78
+
79
+ def fetch_evidence(
80
+ *,
81
+ cursor: str | None = None,
82
+ limit: int = 100,
83
+ wait_s: float = 1.0,
84
+ service_url: str = DEFAULT_SERVICE_URL,
85
+ transport: httpx.BaseTransport | None = None,
86
+ ) -> dict[str, object]:
87
+ """Page the authoritative durable tail; the service owns the opaque cursor."""
88
+
89
+ validate_evidence_query(cursor=cursor, limit=limit, wait_s=wait_s)
90
+ params: dict[str, str | int | float] = {"limit": limit, "wait_s": wait_s}
91
+ if cursor is not None:
92
+ params["cursor"] = cursor
93
+ response = _request_service(
94
+ method="GET", path="/dut/evidence", service_url=service_url,
95
+ transport=transport, params=params, timeout_s=wait_s + DEFAULT_TIMEOUT_SECONDS,
96
+ )
97
+ return _response_payload(response, description="evidence page")
98
+
99
+
57
100
  def list_debug_sessions(
58
101
  *,
59
102
  limit: int = 50,
@@ -183,33 +226,126 @@ def wait_for_pattern(
183
226
  return _response_payload(response, description="wait-pattern response")
184
227
 
185
228
 
229
+ def _bounded_request(
230
+ *,
231
+ path: str,
232
+ payload: dict[str, object],
233
+ duration_s: object | None,
234
+ until: object | None,
235
+ timeout_s: object | None,
236
+ service_url: str,
237
+ transport: httpx.BaseTransport | None,
238
+ ) -> dict[str, object]:
239
+ if until is not None and not isinstance(until, str):
240
+ raise ValueError("Completion condition must be a string")
241
+ request = validate_monitor_request(
242
+ duration_s=duration_s,
243
+ conditions=(MonitorCondition(pattern=until),) if isinstance(until, str) else None,
244
+ timeout_s=timeout_s,
245
+ )
246
+ if request.mode == "duration":
247
+ payload["duration_s"] = request.duration_s
248
+ else:
249
+ payload.update(
250
+ {
251
+ "conditions": [{"pattern": item.pattern} for item in request.conditions],
252
+ "timeout_s": request.timeout_s,
253
+ }
254
+ )
255
+ bound_s = request.duration_s or request.timeout_s
256
+ assert bound_s is not None
257
+ response = _request_service(
258
+ method="POST",
259
+ path=path,
260
+ service_url=service_url,
261
+ transport=transport,
262
+ json=payload,
263
+ timeout_s=max(DEFAULT_TIMEOUT_SECONDS, bound_s + CAPTURE_TIMEOUT_GRACE_SECONDS),
264
+ )
265
+ return _response_payload(response, description="bounded operation response")
266
+
267
+
268
+ def monitor_uart(
269
+ *,
270
+ duration_s: object | None = None,
271
+ until: object | None = None,
272
+ timeout_s: object | None = None,
273
+ service_url: str = DEFAULT_SERVICE_URL,
274
+ transport: httpx.BaseTransport | None = None,
275
+ ) -> dict[str, object]:
276
+ """Run one bounded Monitor through the service."""
277
+
278
+ return _bounded_request(
279
+ path="/dut/monitor",
280
+ payload={},
281
+ duration_s=duration_s,
282
+ until=until,
283
+ timeout_s=timeout_s,
284
+ service_url=service_url,
285
+ transport=transport,
286
+ )
287
+
288
+
289
+ def _tx_request(
290
+ *,
291
+ data_b64: object = None,
292
+ text: object = None,
293
+ line_ending: object = None,
294
+ ) -> dict[str, object]:
295
+ prepare_uart_tx_payload(data_b64=data_b64, text=text, line_ending=line_ending)
296
+ return (
297
+ {"data_b64": data_b64}
298
+ if data_b64 is not None
299
+ else {"text": text, "line_ending": line_ending}
300
+ )
301
+
302
+
186
303
  def send_uart_command(
187
- cmd: str,
188
304
  *,
189
- append_newline: bool = True,
190
- force: bool = False,
305
+ data_b64: object = None,
306
+ text: object = None,
307
+ line_ending: object = None,
191
308
  service_url: str = DEFAULT_SERVICE_URL,
192
309
  transport: httpx.BaseTransport | None = None,
193
310
  ) -> dict[str, object]:
194
- """Send one validated text command through the Device Core Service."""
311
+ """Send one exact, audited payload through the service."""
195
312
 
196
- prepare_uart_send_payload(cmd, append_newline=append_newline)
197
- if not isinstance(force, bool):
198
- raise ValueError("UART send force must be a boolean")
313
+ payload = _tx_request(data_b64=data_b64, text=text, line_ending=line_ending)
199
314
  response = _request_service(
200
315
  method="POST",
201
316
  path="/dut/uart/send",
202
317
  service_url=service_url,
203
318
  transport=transport,
204
- json={
205
- "cmd": cmd,
206
- "append_newline": append_newline,
207
- "force": force,
208
- },
319
+ json=payload,
209
320
  )
210
321
  return _response_payload(response, description="UART-send response")
211
322
 
212
323
 
324
+ def interact_uart(
325
+ *,
326
+ data_b64: object = None,
327
+ text: object = None,
328
+ line_ending: object = None,
329
+ duration_s: object | None = None,
330
+ until: object | None = None,
331
+ timeout_s: object | None = None,
332
+ service_url: str = DEFAULT_SERVICE_URL,
333
+ transport: httpx.BaseTransport | None = None,
334
+ ) -> dict[str, object]:
335
+ """Send once and observe under the service's Interact lease."""
336
+
337
+ payload = _tx_request(data_b64=data_b64, text=text, line_ending=line_ending)
338
+ return _bounded_request(
339
+ path="/dut/interact",
340
+ payload=payload,
341
+ duration_s=duration_s,
342
+ until=until,
343
+ timeout_s=timeout_s,
344
+ service_url=service_url,
345
+ transport=transport,
346
+ )
347
+
348
+
213
349
  def configure_gpio_mode(
214
350
  *,
215
351
  channel: str,
@@ -308,23 +444,6 @@ def capture_uart(
308
444
  )
309
445
 
310
446
 
311
- def run_boot_test(
312
- *,
313
- duration_s: float,
314
- service_url: str = DEFAULT_SERVICE_URL,
315
- transport: httpx.BaseTransport | None = None,
316
- ) -> dict[str, object]:
317
- """Reset the DUT and capture boot evidence through the Device Core Service."""
318
-
319
- return _run_timed_capture_request(
320
- path="/dut/boot-test",
321
- description="boot-test",
322
- duration_s=duration_s,
323
- service_url=service_url,
324
- transport=transport,
325
- )
326
-
327
-
328
447
  def _run_timed_capture_request(
329
448
  *,
330
449
  path: str,
@@ -359,7 +478,7 @@ def _request_service(
359
478
  service_url: str,
360
479
  transport: httpx.BaseTransport | None = None,
361
480
  json: Mapping[str, object] | None = None,
362
- params: Mapping[str, str | int] | None = None,
481
+ params: Mapping[str, str | int | float] | None = None,
363
482
  timeout_s: float = DEFAULT_TIMEOUT_SECONDS,
364
483
  ) -> httpx.Response:
365
484
  try:
@@ -406,6 +525,15 @@ def _response_error_message(response: httpx.Response) -> str:
406
525
  error = payload.get("error")
407
526
  if isinstance(detail, str) and detail:
408
527
  suffix = _uart_send_error_suffix(payload.get("context"))
528
+ context = payload.get("context")
529
+ reason = context.get("reason") if isinstance(context, Mapping) else None
530
+ if reason in (
531
+ "cleanup_unconfirmed",
532
+ "ambiguous_device",
533
+ "device_not_found",
534
+ "open_failed",
535
+ ):
536
+ suffix += f" [{reason}]"
409
537
  if isinstance(error, str) and error:
410
538
  return f"{prefix} [{error}]: {detail}{suffix}"
411
539
  return f"{prefix}: {detail}{suffix}"
@@ -8,11 +8,7 @@ from dataclasses import dataclass
8
8
  from pathlib import Path
9
9
  from typing import Any, Final, cast
10
10
 
11
- from dutchmate_core.backends.settings import (
12
- BackendConfig,
13
- BackendConfigError,
14
- parse_backend_config,
15
- )
11
+ from dutchmate_core.profile import DutProfileConfig, DutProfileError, parse_dut_profile_config
16
12
  from dutchmate_core.validation import (
17
13
  DEFAULT_SESSION_MAX_SIZE_MB,
18
14
  validate_session_max_size_mb,
@@ -51,7 +47,7 @@ class CliConfig:
51
47
 
52
48
  daemon: DaemonConfig = DaemonConfig()
53
49
  sessions: SessionsConfig = SessionsConfig()
54
- backend: BackendConfig = BackendConfig()
50
+ profile: DutProfileConfig = DutProfileConfig()
55
51
 
56
52
  @property
57
53
  def service_url(self) -> str:
@@ -78,10 +74,10 @@ def parse_cli_config(raw_config: Mapping[str, object]) -> CliConfig:
78
74
  daemon = _parse_daemon_config(_optional_table(raw_config, "daemon"))
79
75
  sessions = _parse_sessions_config(_optional_table(raw_config, "sessions"))
80
76
  try:
81
- backend = parse_backend_config(raw_config)
82
- except BackendConfigError as exc:
77
+ profile = parse_dut_profile_config(raw_config)
78
+ except DutProfileError as exc:
83
79
  raise CliConfigError(str(exc)) from exc
84
- return CliConfig(daemon=daemon, sessions=sessions, backend=backend)
80
+ return CliConfig(daemon=daemon, sessions=sessions, profile=profile)
85
81
 
86
82
 
87
83
  def _parse_daemon_config(raw_daemon: Mapping[str, object]) -> DaemonConfig:
@@ -0,0 +1,90 @@
1
+ """Line-oriented human console using only Device Core Service APIs."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import sys
6
+ from collections.abc import Callable, Mapping
7
+ from threading import Event, Thread
8
+ from typing import TextIO
9
+
10
+ import httpx
11
+
12
+ from dutchmate_cli.client import (
13
+ DEFAULT_SERVICE_URL,
14
+ ServiceClientError,
15
+ fetch_status,
16
+ send_uart_command,
17
+ )
18
+ from dutchmate_cli.follow import _EvidenceView, write_view
19
+ from dutchmate_core.validation import prepare_uart_tx_payload
20
+
21
+
22
+ def _resolve_ending(status: Mapping[str, object], requested: str) -> str:
23
+ if requested != "profile_default":
24
+ return requested
25
+ value = status.get("effective_profile")
26
+ for key in ("hardware", "uart", "default_line_ending"):
27
+ value = value.get(key) if isinstance(value, Mapping) else None
28
+ if not isinstance(value, str) or value not in {"none", "lf", "cr", "crlf"}:
29
+ raise ServiceClientError("Service status does not expose the profile default line ending")
30
+ return value
31
+
32
+
33
+ def run_console(
34
+ *,
35
+ service_url: str = DEFAULT_SERVICE_URL,
36
+ line_ending: str = "profile_default",
37
+ input_stream: TextIO | None = None,
38
+ transport: httpx.BaseTransport | None = None,
39
+ emit: Callable[[str], None] = write_view,
40
+ ) -> None:
41
+ """Follow durable evidence while sending complete input lines through audited TX."""
42
+
43
+ prepare_uart_tx_payload(text="validate", line_ending=line_ending)
44
+ status = fetch_status(service_url=service_url, transport=transport)
45
+ capabilities = status.get("capabilities")
46
+ if not isinstance(capabilities, list) or "uart_send" not in capabilities:
47
+ raise ServiceClientError("Console requires effective uart_send [unsupported_capability]")
48
+ # Resolve the immutable service profile once; every request names the exact ending.
49
+ ending = _resolve_ending(status, line_ending)
50
+ view = _EvidenceView(service_url=service_url, cursor=None, transport=transport, emit=emit)
51
+ view.poll(wait_s=0)
52
+ stopped = Event()
53
+ failures: list[ServiceClientError] = []
54
+
55
+ def follow() -> None:
56
+ try:
57
+ view.run(stopped)
58
+ # Include the last completed send's evidence on EOF without another long poll.
59
+ view.poll(wait_s=0)
60
+ except ServiceClientError as exc:
61
+ failures.append(exc)
62
+ stopped.set()
63
+ emit(f"\n{exc}\n")
64
+
65
+ worker = Thread(target=follow, name="dutchmate-console-view")
66
+ worker.start()
67
+ try:
68
+ stream = input_stream if input_stream is not None else sys.stdin
69
+ while not stopped.is_set():
70
+ line = stream.readline()
71
+ if not line or stopped.is_set():
72
+ break
73
+ text = line.removesuffix("\n").removesuffix("\r")
74
+ try:
75
+ send_uart_command(
76
+ text=text,
77
+ line_ending=ending,
78
+ service_url=service_url,
79
+ transport=transport,
80
+ )
81
+ except (ServiceClientError, ValueError) as exc:
82
+ # Rejections (including operation_active) do not retry or end observation.
83
+ emit(f"\n{exc}\n")
84
+ except KeyboardInterrupt:
85
+ pass
86
+ finally:
87
+ stopped.set()
88
+ worker.join()
89
+ if failures:
90
+ raise failures[0]
@@ -0,0 +1,100 @@
1
+ """Human views of durable service evidence; never owns a physical reader."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import sys
6
+ from collections.abc import Callable, Mapping
7
+ from contextlib import suppress
8
+ from threading import Event
9
+
10
+ import httpx
11
+
12
+ from dutchmate_cli.client import DEFAULT_SERVICE_URL, ServiceClientError, fetch_evidence
13
+
14
+
15
+ def write_view(text: str) -> None:
16
+ sys.stdout.write(text)
17
+ sys.stdout.flush()
18
+
19
+
20
+ def format_evidence(record: Mapping[str, object]) -> str:
21
+ """Display lossy RX text and bounded markers from the authoritative projection."""
22
+
23
+ if record.get("type") == "uart_rx":
24
+ text = record.get("display_text")
25
+ return (
26
+ "".join(c for c in text if c.isprintable() or c in "\n\r\t")
27
+ if isinstance(text, str)
28
+ else ""
29
+ )
30
+ fields = [str(record.get("type", "evidence"))]
31
+ for key in (
32
+ "session_id",
33
+ "evidence_seq",
34
+ "operation_type",
35
+ "outcome",
36
+ "status",
37
+ "accepted_bytes",
38
+ ):
39
+ if key in record:
40
+ fields.append(f"{key}={record[key]}")
41
+ if record.get("type") == "uart_tx_attempt":
42
+ fields.append(f"text={str(record.get('display_text', ''))[:160]!r}")
43
+ marker = " ".join(fields)
44
+ return "\n[" + "".join(c for c in marker[:768] if c.isprintable()) + "]\n"
45
+
46
+
47
+ class _EvidenceView:
48
+ def __init__(
49
+ self,
50
+ *,
51
+ service_url: str,
52
+ cursor: str | None,
53
+ transport: httpx.BaseTransport | None,
54
+ emit: Callable[[str], None],
55
+ ) -> None:
56
+ self.service_url = service_url
57
+ self.cursor = cursor
58
+ self.transport = transport
59
+ self.emit = emit
60
+
61
+ def poll(self, *, wait_s: float) -> bool:
62
+ page = fetch_evidence(
63
+ cursor=self.cursor,
64
+ wait_s=wait_s,
65
+ service_url=self.service_url,
66
+ transport=self.transport,
67
+ )
68
+ records = page.get("records")
69
+ next_cursor = page.get("next_cursor")
70
+ if not isinstance(records, list) or not isinstance(next_cursor, str) or not next_cursor:
71
+ raise ServiceClientError("Device Core Service returned an invalid evidence page")
72
+ for record in records:
73
+ if not isinstance(record, Mapping):
74
+ raise ServiceClientError("Device Core Service returned an invalid evidence record")
75
+ self.emit(format_evidence(record))
76
+ omitted = page.get("omitted_records")
77
+ if isinstance(omitted, int) and omitted > 0:
78
+ self.emit(f"\n[{omitted} whole records deferred by response cap; continuing cursor]\n")
79
+ # Advance only after rendering. Slow output is recovered by the next durable request.
80
+ self.cursor = next_cursor
81
+ return bool(records)
82
+
83
+ def run(self, stopped: Event) -> None:
84
+ while not stopped.is_set():
85
+ if not self.poll(wait_s=1.0):
86
+ stopped.wait(0.05)
87
+
88
+
89
+ def run_follow(
90
+ *,
91
+ service_url: str = DEFAULT_SERVICE_URL,
92
+ cursor: str | None = None,
93
+ transport: httpx.BaseTransport | None = None,
94
+ emit: Callable[[str], None] = write_view,
95
+ ) -> None:
96
+ """Attach at tail by default; Ctrl-C closes only this client view."""
97
+
98
+ view = _EvidenceView(service_url=service_url, cursor=cursor, transport=transport, emit=emit)
99
+ with suppress(KeyboardInterrupt):
100
+ view.run(Event())
@@ -19,7 +19,7 @@ from dutchmate_cli.config import (
19
19
  DEFAULT_DAEMON_PORT,
20
20
  DEFAULT_SESSION_PATH,
21
21
  )
22
- from dutchmate_core.backends.settings import BackendSettings
22
+ from dutchmate_core.profile import DutProfile
23
23
  from dutchmate_core.validation import DEFAULT_SESSION_MAX_SIZE_MB
24
24
 
25
25
  DEFAULT_HOST: Final = DEFAULT_DAEMON_HOST
@@ -62,7 +62,7 @@ class ServiceStopResult:
62
62
 
63
63
  def start_service(
64
64
  *,
65
- backend_settings: BackendSettings,
65
+ profile: DutProfile,
66
66
  host: str = DEFAULT_HOST,
67
67
  port: int = DEFAULT_PORT,
68
68
  config_path: Path = DEFAULT_CONFIG_PATH,
@@ -90,6 +90,7 @@ def start_service(
90
90
  pid_file.parent.mkdir(parents=True, exist_ok=True)
91
91
  log_file.parent.mkdir(parents=True, exist_ok=True)
92
92
  if command is None:
93
+ backend_settings = profile.backend_settings
93
94
  service_command = [
94
95
  "dutchmate-service",
95
96
  "--host",
@@ -103,19 +104,42 @@ def start_service(
103
104
  "--config",
104
105
  str(config_path),
105
106
  "--backend",
106
- backend_settings.mode,
107
+ profile.backend_mode,
108
+ "--topology",
109
+ profile.topology,
107
110
  "--baudrate",
108
- str(backend_settings.baudrate),
111
+ str(profile.uart.baudrate),
109
112
  "--data-bits",
110
- str(backend_settings.data_bits),
113
+ str(profile.uart.data_bits),
111
114
  "--parity",
112
- backend_settings.parity,
115
+ profile.uart.parity,
113
116
  "--stop-bits",
114
- str(backend_settings.stop_bits),
117
+ str(profile.uart.stop_bits),
115
118
  "--reconnect-timeout-s",
116
- str(backend_settings.reconnect_timeout_s),
117
- "--tx-enabled" if backend_settings.tx_enabled else "--no-tx-enabled",
119
+ str(profile.reconnect_timeout_s),
120
+ "--rtscts" if profile.uart.rtscts else "--no-rtscts",
121
+ "--xonxoff" if profile.uart.xonxoff else "--no-xonxoff",
122
+ "--tx-enabled" if profile.uart.tx_enabled else "--no-tx-enabled",
123
+ "--default-line-ending",
124
+ profile.uart.default_line_ending,
125
+ "--dtr-on-open",
126
+ profile.uart.dtr_on_open,
127
+ "--rts-on-open",
128
+ profile.uart.rts_on_open,
118
129
  ]
130
+ if profile.selector.strategy == "usb_identity":
131
+ service_command.extend(
132
+ [
133
+ "--usb-vid",
134
+ str(profile.selector.vid),
135
+ "--usb-pid",
136
+ str(profile.selector.pid),
137
+ "--usb-serial-number",
138
+ str(profile.selector.serial_number),
139
+ ]
140
+ )
141
+ if profile.name is not None:
142
+ service_command.extend(["--profile-name", profile.name])
119
143
  if backend_settings.serial_port is not None:
120
144
  service_command.extend(["--serial-port", backend_settings.serial_port])
121
145
  if session_max_count is not None: