python-ember-mug 1.4.0b1__tar.gz → 1.4.0b2__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.
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/PKG-INFO +3 -3
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/ember_mug/__init__.py +1 -1
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/ember_mug/cli/commands.py +17 -6
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/ember_mug/scanner.py +11 -6
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/pyproject.toml +3 -3
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/.gitignore +0 -0
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/LICENSE +0 -0
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/README.md +0 -0
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/ember_mug/__main__.py +0 -0
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/ember_mug/cli/__init__.py +0 -0
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/ember_mug/cli/helpers.py +0 -0
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/ember_mug/consts.py +0 -0
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/ember_mug/data.py +0 -0
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/ember_mug/formatting.py +0 -0
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/ember_mug/mug.py +0 -0
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/ember_mug/py.typed +0 -0
- {python_ember_mug-1.4.0b1 → python_ember_mug-1.4.0b2}/ember_mug/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-ember-mug
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.0b2
|
|
4
4
|
Summary: Python Library for Ember Mugs.
|
|
5
5
|
Project-URL: Changelog, https://sopelj.github.io/python-ember-mug/changelog/
|
|
6
6
|
Project-URL: Documentation, https://sopelj.github.io/python-ember-mug/
|
|
@@ -18,8 +18,8 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.14
|
|
20
20
|
Requires-Python: >=3.11
|
|
21
|
-
Requires-Dist: bleak-retry-connector>=4.0
|
|
22
|
-
Requires-Dist: bleak>=
|
|
21
|
+
Requires-Dist: bleak-retry-connector>=4.6.0
|
|
22
|
+
Requires-Dist: bleak>=3.0.2
|
|
23
23
|
Provides-Extra: dev
|
|
24
24
|
Requires-Dist: ipython; extra == 'dev'
|
|
25
25
|
Provides-Extra: docs
|
|
@@ -7,8 +7,9 @@ import contextlib
|
|
|
7
7
|
import logging
|
|
8
8
|
import re
|
|
9
9
|
import sys
|
|
10
|
-
from argparse import ArgumentParser, ArgumentTypeError,
|
|
11
|
-
from
|
|
10
|
+
from argparse import ArgumentParser, ArgumentTypeError, Namespace
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import IO, TYPE_CHECKING, ClassVar
|
|
12
13
|
|
|
13
14
|
from bleak import BleakError
|
|
14
15
|
|
|
@@ -216,9 +217,8 @@ class EmberMugCli:
|
|
|
216
217
|
)
|
|
217
218
|
self.parser.add_argument(
|
|
218
219
|
"--log-file",
|
|
219
|
-
type=
|
|
220
|
+
type=Path,
|
|
220
221
|
nargs="?",
|
|
221
|
-
default=sys.stdout,
|
|
222
222
|
help="File to write logs too (Will be overwritten)",
|
|
223
223
|
)
|
|
224
224
|
self.parser.add_argument("--version", action="version", version=__version__)
|
|
@@ -256,12 +256,23 @@ class EmberMugCli:
|
|
|
256
256
|
async def run(self) -> None:
|
|
257
257
|
"""Run the specified command based on subparser."""
|
|
258
258
|
args = self.parser.parse_args()
|
|
259
|
+
out_file: IO[str] | None = None
|
|
259
260
|
if IS_LINUX is False:
|
|
260
261
|
args.adapter = None # Set for other platforms
|
|
261
262
|
if args.debug:
|
|
263
|
+
if args.log_file:
|
|
264
|
+
try:
|
|
265
|
+
out_file = args.log_file.open("w")
|
|
266
|
+
except OSError as e:
|
|
267
|
+
self.parser.error(f"Failed to open '{args.log_file}': {e}")
|
|
268
|
+
|
|
262
269
|
logging.basicConfig(
|
|
263
|
-
stream=
|
|
270
|
+
stream=out_file or sys.stdout,
|
|
264
271
|
level=logging.DEBUG,
|
|
265
272
|
format="[%(asctime)s] %(levelname)s [%(filename)s.%(funcName)s:%(lineno)d] %(message)s",
|
|
266
273
|
)
|
|
267
|
-
|
|
274
|
+
try:
|
|
275
|
+
await self._commands[args.command](args)
|
|
276
|
+
finally:
|
|
277
|
+
if out_file is not None:
|
|
278
|
+
out_file.close()
|
|
@@ -5,7 +5,7 @@ from __future__ import annotations
|
|
|
5
5
|
import asyncio
|
|
6
6
|
import contextlib
|
|
7
7
|
import logging
|
|
8
|
-
from typing import TYPE_CHECKING
|
|
8
|
+
from typing import TYPE_CHECKING
|
|
9
9
|
|
|
10
10
|
from bleak import BleakScanner
|
|
11
11
|
|
|
@@ -14,13 +14,14 @@ from .consts import DEVICE_SERVICE_UUIDS, IS_LINUX
|
|
|
14
14
|
if TYPE_CHECKING:
|
|
15
15
|
from typing import NotRequired, TypedDict
|
|
16
16
|
|
|
17
|
+
from bleak import BlueZScannerArgs
|
|
17
18
|
from bleak.backends.device import BLEDevice
|
|
18
19
|
from bleak.backends.scanner import AdvertisementData
|
|
19
20
|
|
|
20
|
-
class
|
|
21
|
+
class BleakScannerKwargs(TypedDict):
|
|
21
22
|
"""Optional kwargs for scanner."""
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
bluez: NotRequired[BlueZScannerArgs]
|
|
24
25
|
service_uuids: NotRequired[list[str]]
|
|
25
26
|
|
|
26
27
|
|
|
@@ -29,13 +30,17 @@ DEFAULT_TIMEOUT = 30
|
|
|
29
30
|
logger = logging.getLogger(__name__)
|
|
30
31
|
|
|
31
32
|
|
|
32
|
-
def build_scanner_kwargs(adapter: str | None = None, *, service_uuids: list[str] | None = None) ->
|
|
33
|
+
def build_scanner_kwargs(adapter: str | None = None, *, service_uuids: list[str] | None = None) -> BleakScannerKwargs:
|
|
33
34
|
"""Add Adapter to kwargs for scanner if specified and using BlueZ."""
|
|
34
35
|
if adapter and IS_LINUX is not True:
|
|
35
36
|
msg = "The adapter option is only valid for the Linux BlueZ Backend."
|
|
36
37
|
raise ValueError(msg)
|
|
37
|
-
kwargs
|
|
38
|
-
|
|
38
|
+
kwargs: BleakScannerKwargs = {}
|
|
39
|
+
if service_uuids:
|
|
40
|
+
kwargs |= {"service_uuids": service_uuids}
|
|
41
|
+
if adapter:
|
|
42
|
+
kwargs |= {"bluez": {"adapter": adapter}}
|
|
43
|
+
return kwargs
|
|
39
44
|
|
|
40
45
|
|
|
41
46
|
async def discover_devices(
|
|
@@ -17,8 +17,8 @@ classifiers = [
|
|
|
17
17
|
'Programming Language :: Python :: 3.14',
|
|
18
18
|
]
|
|
19
19
|
dependencies = [
|
|
20
|
-
"bleak-retry-connector>=4.0
|
|
21
|
-
"bleak>=
|
|
20
|
+
"bleak-retry-connector>=4.6.0",
|
|
21
|
+
"bleak>=3.0.2",
|
|
22
22
|
]
|
|
23
23
|
|
|
24
24
|
[project.optional-dependencies]
|
|
@@ -76,7 +76,7 @@ features = ["test"]
|
|
|
76
76
|
|
|
77
77
|
[[tool.hatch.envs.test.matrix]]
|
|
78
78
|
python = ["3.11", "3.12", "3.13", "3.14"]
|
|
79
|
-
bleak = ["
|
|
79
|
+
bleak = ["3.0.2"]
|
|
80
80
|
|
|
81
81
|
[tool.hatch.envs.test.scripts]
|
|
82
82
|
cov = "pytest -vvv --asyncio-mode=auto --cov=ember_mug --cov-branch --cov-report=xml --cov-report=term-missing tests"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|