etho-python 1.2.5__py3-none-any.whl → 1.3__py3-none-any.whl

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.
etho/app.py CHANGED
@@ -10,9 +10,10 @@ import time
10
10
  import psutil
11
11
  import threading
12
12
  import queue
13
+ from codecs import getincrementaldecoder
13
14
 
14
15
  from qtpy import QtWidgets
15
- from qtpy.QtGui import QIcon, QPalette
16
+ from qtpy.QtGui import QIcon, QPalette, QTextCursor
16
17
  from qtpy.QtWidgets import (
17
18
  QApplication,
18
19
  QTableView,
@@ -28,9 +29,10 @@ from qtpy.QtWidgets import (
28
29
  QLabel,
29
30
  QSplitter,
30
31
  QProgressBar,
32
+ QPlainTextEdit,
31
33
  )
32
34
 
33
- from qtpy.QtCore import QAbstractTableModel, Qt, QTimer
35
+ from qtpy.QtCore import QAbstractTableModel, QProcess, Qt, QTimer
34
36
 
35
37
  from pyqtgraph.parametertree import Parameter, ParameterTree
36
38
 
@@ -221,6 +223,54 @@ def kill_child_processes():
221
223
  # os.kill(child.pid, signal.SIGKILL)
222
224
 
223
225
 
226
+ class HardwareDialog(QDialog):
227
+ def __init__(self, parent):
228
+ super().__init__(parent)
229
+ self.setWindowTitle("Hardware")
230
+ self.resize(640, 400)
231
+
232
+ self.status = QLabel("Scanning local hardware…")
233
+ self.results = QPlainTextEdit()
234
+ self.results.setReadOnly(True)
235
+ buttons = QDialogButtonBox(QDialogButtonBox.Close)
236
+ buttons.rejected.connect(self.reject)
237
+
238
+ layout = QVBoxLayout(self)
239
+ layout.addWidget(self.status)
240
+ layout.addWidget(self.results)
241
+ layout.addWidget(buttons)
242
+
243
+ self._decoder = getincrementaldecoder("utf-8")(errors="replace")
244
+ self._scan = QProcess(self)
245
+ self._scan.setProcessChannelMode(QProcess.MergedChannels)
246
+ self._scan.readyReadStandardOutput.connect(self._read_scan_output)
247
+ self._scan.finished.connect(self._scan_finished)
248
+ self._scan.errorOccurred.connect(self._scan_error)
249
+ self._scan.start(sys.executable, ["-X", "utf8", "-u", "-m", "etho.cli", "hardware"])
250
+
251
+ def _read_scan_output(self, *, final=False):
252
+ output = self._decoder.decode(bytes(self._scan.readAllStandardOutput()), final=final)
253
+ cursor = QTextCursor(self.results.document())
254
+ cursor.movePosition(QTextCursor.End)
255
+ cursor.insertText(output)
256
+
257
+ def _scan_finished(self, exit_code, exit_status):
258
+ self._read_scan_output(final=True)
259
+ complete = exit_status == QProcess.NormalExit and exit_code == 0
260
+ self.status.setText("Scan complete." if complete else "Hardware scan failed.")
261
+
262
+ def _scan_error(self, error):
263
+ if error == QProcess.FailedToStart:
264
+ self.status.setText("Could not start the hardware scan.")
265
+ self.results.appendPlainText(self._scan.errorString())
266
+
267
+ def done(self, result):
268
+ if self._scan.state() != QProcess.NotRunning:
269
+ self._scan.kill()
270
+ self._scan.waitForFinished(250)
271
+ super().done(result)
272
+
273
+
224
274
  class RunDialog(QDialog):
225
275
  def __init__(self, stop_event, done_event, queue_total):
226
276
  super().__init__()
@@ -343,6 +393,9 @@ class MainWindow(QMainWindow):
343
393
  # Layout
344
394
  self.layout = QGridLayout()
345
395
  self.layout.addLayout(buttons, 0, 0)
396
+ self.button["Hardware"] = QPushButton("Enumerate hardware")
397
+ self.button["Hardware"].clicked.connect(self.show_hardware)
398
+ self.layout.addWidget(self.button["Hardware"], 1, 0, Qt.AlignBottom)
346
399
  self.refresh_lists(init=True)
347
400
 
348
401
  self.layout.setColumnMinimumWidth(1, 200)
@@ -358,6 +411,11 @@ class MainWindow(QMainWindow):
358
411
  def on_protocol_changed(self, param, changes):
359
412
  self.current_protocol = to_yaml(param)
360
413
 
414
+ def show_hardware(self):
415
+ dialog = HardwareDialog(self)
416
+ dialog.setAttribute(Qt.WA_DeleteOnClose)
417
+ dialog.open()
418
+
361
419
  def refresh_lists(self, init: bool = False):
362
420
  playlist_files = sorted(self.playlist_folder.glob("*.txt"))
363
421
  if len(playlist_files) == 0:
@@ -1,23 +1,23 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256" fill="none">
2
- <title>etho minimal pipeline glyph dark mode</title>
3
- <g shape-rendering="geometricPrecision">
4
- <rect x="28" y="52" width="44" height="32" rx="8" fill="#F3F5F7"/>
5
- <rect x="34" y="58" width="12" height="8" rx="2" fill="#1F2430"/>
6
- <rect x="104" y="62" width="8" height="12" rx="2" fill="#6FB64F"/>
7
- <rect x="118" y="50" width="8" height="36" rx="2" fill="#6FB64F"/>
8
- <rect x="132" y="38" width="8" height="60" rx="2" fill="#6FB64F"/>
9
- <rect x="146" y="50" width="8" height="36" rx="2" fill="#6FB64F"/>
10
- <rect x="160" y="62" width="8" height="12" rx="2" fill="#6FB64F"/>
11
- <path d="M192 54L224 74L192 94Z" fill="#6FB64F"/>
12
- <rect x="84" y="70" width="12" height="4" rx="2" fill="#F3F5F7"/>
13
- <rect x="174" y="70" width="12" height="4" rx="2" fill="#F3F5F7"/>
14
- <path d="M48 96V120C48 124.418 51.582 128 56 128H124M208 96V120C208 124.418 204.418 128 200 128H132" stroke="#F3F5F7" stroke-width="8" stroke-linecap="round" stroke-linejoin="round"/>
15
- <path d="M128 112V160" stroke="#F3F5F7" stroke-width="8" stroke-linecap="round"/>
16
- <circle cx="128" cy="128" r="6" fill="#F3F5F7"/>
17
- <ellipse cx="128" cy="180" rx="36" ry="12" fill="#6FB64F"/>
18
- <path d="M92 180V212C92 218.627 108.118 224 128 224C147.882 224 164 218.627 164 212V180" fill="#F3F5F7"/>
19
- <path d="M92 196C92 202.627 108.118 208 128 208C147.882 208 164 202.627 164 196" stroke="#1F2430" stroke-width="4" stroke-linecap="round"/>
20
- <circle cx="154" cy="198" r="3" fill="#1F2430"/>
21
- <circle cx="154" cy="214" r="3" fill="#1F2430"/>
22
- </g>
23
- </svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256" fill="none">
2
+ <title>etho minimal pipeline glyph dark mode</title>
3
+ <g shape-rendering="geometricPrecision">
4
+ <rect x="28" y="52" width="44" height="32" rx="8" fill="#F3F5F7"/>
5
+ <rect x="34" y="58" width="12" height="8" rx="2" fill="#1F2430"/>
6
+ <rect x="104" y="62" width="8" height="12" rx="2" fill="#6FB64F"/>
7
+ <rect x="118" y="50" width="8" height="36" rx="2" fill="#6FB64F"/>
8
+ <rect x="132" y="38" width="8" height="60" rx="2" fill="#6FB64F"/>
9
+ <rect x="146" y="50" width="8" height="36" rx="2" fill="#6FB64F"/>
10
+ <rect x="160" y="62" width="8" height="12" rx="2" fill="#6FB64F"/>
11
+ <path d="M192 54L224 74L192 94Z" fill="#6FB64F"/>
12
+ <rect x="84" y="70" width="12" height="4" rx="2" fill="#F3F5F7"/>
13
+ <rect x="174" y="70" width="12" height="4" rx="2" fill="#F3F5F7"/>
14
+ <path d="M48 96V120C48 124.418 51.582 128 56 128H124M208 96V120C208 124.418 204.418 128 200 128H132" stroke="#F3F5F7" stroke-width="8" stroke-linecap="round" stroke-linejoin="round"/>
15
+ <path d="M128 112V160" stroke="#F3F5F7" stroke-width="8" stroke-linecap="round"/>
16
+ <circle cx="128" cy="128" r="6" fill="#F3F5F7"/>
17
+ <ellipse cx="128" cy="180" rx="36" ry="12" fill="#6FB64F"/>
18
+ <path d="M92 180V212C92 218.627 108.118 224 128 224C147.882 224 164 218.627 164 212V180" fill="#F3F5F7"/>
19
+ <path d="M92 196C92 202.627 108.118 208 128 208C147.882 208 164 202.627 164 196" stroke="#1F2430" stroke-width="4" stroke-linecap="round"/>
20
+ <circle cx="154" cy="198" r="3" fill="#1F2430"/>
21
+ <circle cx="154" cy="214" r="3" fill="#1F2430"/>
22
+ </g>
23
+ </svg>
@@ -1,30 +1,30 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256" fill="none">
2
- <title>etho minimal pipeline glyph</title>
3
- <g shape-rendering="geometricPrecision">
4
- <!-- camera -->
5
- <rect x="28" y="52" width="44" height="32" rx="8" fill="#1F2430"/>
6
- <rect x="34" y="58" width="12" height="8" rx="2" fill="#F3F5F7"/>
7
- <!-- signal -->
8
- <rect x="104" y="62" width="8" height="12" rx="2" fill="#6FB64F"/>
9
- <rect x="118" y="50" width="8" height="36" rx="2" fill="#6FB64F"/>
10
- <rect x="132" y="38" width="8" height="60" rx="2" fill="#6FB64F"/>
11
- <rect x="146" y="50" width="8" height="36" rx="2" fill="#6FB64F"/>
12
- <rect x="160" y="62" width="8" height="12" rx="2" fill="#6FB64F"/>
13
- <!-- opto triangle -->
14
- <path d="M192 54L224 74L192 94Z" fill="#6FB64F"/>
15
- <!-- tiny separators -->
16
- <rect x="84" y="70" width="12" height="4" rx="2" fill="#1F2430"/>
17
- <rect x="174" y="70" width="12" height="4" rx="2" fill="#1F2430"/>
18
- <!-- bus -->
19
- <path d="M48 96V120C48 124.418 51.582 128 56 128H124M208 96V120C208 124.418 204.418 128 200 128H132" stroke="#1F2430" stroke-width="8" stroke-linecap="round" stroke-linejoin="round"/>
20
- <path d="M128 112V160" stroke="#1F2430" stroke-width="8" stroke-linecap="round"/>
21
- <!-- junction -->
22
- <circle cx="128" cy="128" r="6" fill="#1F2430"/>
23
- <!-- database -->
24
- <ellipse cx="128" cy="180" rx="36" ry="12" fill="#6FB64F"/>
25
- <path d="M92 180V212C92 218.627 108.118 224 128 224C147.882 224 164 218.627 164 212V180" fill="#1F2430"/>
26
- <path d="M92 196C92 202.627 108.118 208 128 208C147.882 208 164 202.627 164 196" stroke="#F3F5F7" stroke-width="4" stroke-linecap="round"/>
27
- <circle cx="154" cy="198" r="3" fill="#F3F5F7"/>
28
- <circle cx="154" cy="214" r="3" fill="#F3F5F7"/>
29
- </g>
30
- </svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256" fill="none">
2
+ <title>etho minimal pipeline glyph</title>
3
+ <g shape-rendering="geometricPrecision">
4
+ <!-- camera -->
5
+ <rect x="28" y="52" width="44" height="32" rx="8" fill="#1F2430"/>
6
+ <rect x="34" y="58" width="12" height="8" rx="2" fill="#F3F5F7"/>
7
+ <!-- signal -->
8
+ <rect x="104" y="62" width="8" height="12" rx="2" fill="#6FB64F"/>
9
+ <rect x="118" y="50" width="8" height="36" rx="2" fill="#6FB64F"/>
10
+ <rect x="132" y="38" width="8" height="60" rx="2" fill="#6FB64F"/>
11
+ <rect x="146" y="50" width="8" height="36" rx="2" fill="#6FB64F"/>
12
+ <rect x="160" y="62" width="8" height="12" rx="2" fill="#6FB64F"/>
13
+ <!-- opto triangle -->
14
+ <path d="M192 54L224 74L192 94Z" fill="#6FB64F"/>
15
+ <!-- tiny separators -->
16
+ <rect x="84" y="70" width="12" height="4" rx="2" fill="#1F2430"/>
17
+ <rect x="174" y="70" width="12" height="4" rx="2" fill="#1F2430"/>
18
+ <!-- bus -->
19
+ <path d="M48 96V120C48 124.418 51.582 128 56 128H124M208 96V120C208 124.418 204.418 128 200 128H132" stroke="#1F2430" stroke-width="8" stroke-linecap="round" stroke-linejoin="round"/>
20
+ <path d="M128 112V160" stroke="#1F2430" stroke-width="8" stroke-linecap="round"/>
21
+ <!-- junction -->
22
+ <circle cx="128" cy="128" r="6" fill="#1F2430"/>
23
+ <!-- database -->
24
+ <ellipse cx="128" cy="180" rx="36" ry="12" fill="#6FB64F"/>
25
+ <path d="M92 180V212C92 218.627 108.118 224 128 224C147.882 224 164 218.627 164 212V180" fill="#1F2430"/>
26
+ <path d="M92 196C92 202.627 108.118 208 128 208C147.882 208 164 202.627 164 196" stroke="#F3F5F7" stroke-width="4" stroke-linecap="round"/>
27
+ <circle cx="154" cy="198" r="3" fill="#F3F5F7"/>
28
+ <circle cx="154" cy="214" r="3" fill="#F3F5F7"/>
29
+ </g>
30
+ </svg>
etho/cli.py CHANGED
@@ -1,5 +1,6 @@
1
1
  import defopt
2
2
  import logging
3
+ import math
3
4
  import platform
4
5
  import importlib
5
6
  import yaml
@@ -67,23 +68,35 @@ def res_gui(protocol_folder: Optional[str] = None, playlist_folder: Optional[str
67
68
  return res_app.main(protocol_folder=protocol_folder, playlist_folder=playlist_folder)
68
69
 
69
70
 
70
- def govee(duration: float = 10.0):
71
- """Lists nearby Govee H5075 sensors and their protocol addresses/readings."""
72
- import asyncio
71
+ def hardware(*, ble_duration: float = 10.0):
72
+ """Lists hardware detected by local etho services.
73
73
 
74
- from .services.GOVZeroService import discover_h5075_sensors
74
+ Args:
75
+ ble_duration: Time in seconds to listen for Bluetooth advertisements.
76
+ """
77
+ from .services.hardware import discover_hardware
78
+
79
+ if not math.isfinite(ble_duration) or ble_duration <= 0:
80
+ raise SystemExit("--ble-duration must be a finite number greater than zero.")
81
+
82
+ print(f"Scanning local hardware (Bluetooth scan: {ble_duration:g} seconds)...", flush=True)
83
+ for result in discover_hardware(ble_duration=ble_duration):
84
+ label = f"{result.service} / {result.probe}" if result.probe else result.service
85
+ if result.error is not None:
86
+ message = str(result.error).strip() or type(result.error).__name__
87
+ print(f"{label}: unavailable ({message})", flush=True)
88
+ elif not result.devices:
89
+ print(f"{label}: no devices found", flush=True)
90
+ else:
91
+ print(label)
92
+ for device in result.devices:
93
+ fields = [f"{key}={value}" for key, value in device.protocol.items()]
94
+ if device.details:
95
+ fields.append(device.details)
96
+ suffix = f" ({', '.join(fields)})" if fields else ""
97
+ print(f" {device.name}{suffix}", flush=True)
75
98
 
76
- print(f"Scanning for Govee sensors for {duration:g} seconds...", flush=True)
77
- sensors = asyncio.run(discover_h5075_sensors(duration))
78
- if not sensors:
79
- print("No Govee H5075 sensors found.")
80
- return
81
99
 
82
- print(f"{'Address (use as GOV.address)':<38} {'Name':<16} {'Temperature':>11} {'Humidity':>9}")
83
- for address, name, measurement in sensors:
84
- print(f"{address:<38} {(name or '-'):<16} {measurement.temperature_c:>10.1f}°C {measurement.humidity:>8.1f}%")
85
-
86
-
87
100
  def version(*, debug: bool = False):
88
101
  """Displays system, version, and hardware info.
89
102
 
@@ -238,11 +251,11 @@ def init():
238
251
 
239
252
 
240
253
  def main():
241
- """Command line interface for DAS."""
254
+ """Command line interface for etho."""
242
255
  subcommands = {
243
256
  "version": version,
244
257
  "init": init,
245
- "govee": govee,
258
+ "hardware": hardware,
246
259
  }
247
260
 
248
261
  if client is not None:
@@ -266,3 +279,7 @@ def main():
266
279
 
267
280
  logging.basicConfig(level=logging.INFO, force=True)
268
281
  defopt.run(subcommands, show_defaults=False)
282
+
283
+
284
+ if __name__ == "__main__":
285
+ main()