mirror of
https://github.com/google/bumble.git
synced 2026-04-16 00:25:31 +00:00
use ruff for linting and import sorting
This commit is contained in:
@@ -646,7 +646,6 @@ async def run_assist(
|
||||
|
||||
async def run_pair(transport: str, address: str) -> None:
|
||||
async with create_device(transport) as device:
|
||||
|
||||
# Connect to the server
|
||||
print(f'=== Connecting to {address}...')
|
||||
async with device.connect_as_gatt(address) as peer:
|
||||
|
||||
@@ -1096,9 +1096,7 @@ class DeviceListener(Device.Listener, Connection.Listener):
|
||||
if self.app.connected_peer.connection.is_encrypted
|
||||
else 'not encrypted'
|
||||
)
|
||||
self.app.append_to_output(
|
||||
'connection encryption change: ' f'{encryption_state}'
|
||||
)
|
||||
self.app.append_to_output(f'connection encryption change: {encryption_state}')
|
||||
|
||||
def on_connection_data_length_change(self):
|
||||
self.app.append_to_output(
|
||||
|
||||
@@ -275,7 +275,7 @@ async def async_main(
|
||||
(
|
||||
f'min={min(latencies):.2f}, '
|
||||
f'max={max(latencies):.2f}, '
|
||||
f'average={sum(latencies)/len(latencies):.2f},'
|
||||
f'average={sum(latencies) / len(latencies):.2f},'
|
||||
),
|
||||
[f'{latency:.4}' for latency in latencies],
|
||||
'\n',
|
||||
|
||||
@@ -215,7 +215,6 @@ async def show_device_info(peer, done: Optional[asyncio.Future]) -> None:
|
||||
# -----------------------------------------------------------------------------
|
||||
async def async_main(device_config, encrypt, transport, address_or_name):
|
||||
async with await open_transport(transport) as (hci_source, hci_sink):
|
||||
|
||||
# Create a device
|
||||
if device_config:
|
||||
device = Device.from_config_file_with_hci(
|
||||
|
||||
@@ -61,7 +61,6 @@ async def dump_gatt_db(peer, done):
|
||||
# -----------------------------------------------------------------------------
|
||||
async def async_main(device_config, encrypt, transport, address_or_name):
|
||||
async with await open_transport(transport) as (hci_source, hci_sink):
|
||||
|
||||
# Create a device
|
||||
if device_config:
|
||||
device = Device.from_config_file_with_hci(
|
||||
|
||||
@@ -268,7 +268,6 @@ class UiServer:
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
class Speaker:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
device_config_path: str | None,
|
||||
|
||||
13
apps/pair.py
13
apps/pair.py
@@ -527,7 +527,9 @@ async def pair(
|
||||
if advertise_appearance:
|
||||
advertise_appearance = advertise_appearance.upper()
|
||||
try:
|
||||
advertise_appearance_int = int(advertise_appearance)
|
||||
appearance = data_types.Appearance.from_int(
|
||||
int(advertise_appearance)
|
||||
)
|
||||
except ValueError:
|
||||
category, subcategory = advertise_appearance.split('/')
|
||||
try:
|
||||
@@ -545,12 +547,11 @@ async def pair(
|
||||
except ValueError:
|
||||
print(color(f'Invalid subcategory {subcategory}', 'red'))
|
||||
return
|
||||
advertise_appearance_int = int(
|
||||
Appearance(category_enum, subcategory_enum)
|
||||
appearance = data_types.Appearance(
|
||||
category_enum, subcategory_enum
|
||||
)
|
||||
advertising_data_types.append(
|
||||
data_types.Appearance(category_enum, subcategory_enum)
|
||||
)
|
||||
|
||||
advertising_data_types.append(appearance)
|
||||
device.advertising_data = bytes(AdvertisingData(advertising_data_types))
|
||||
await device.start_advertising(
|
||||
auto_restart=True,
|
||||
|
||||
@@ -19,7 +19,7 @@ ROOTCANAL_PORT_CUTTLEFISH = 7300
|
||||
@click.option(
|
||||
'--transport',
|
||||
help='HCI transport',
|
||||
default=f'tcp-client:127.0.0.1:<rootcanal-port>',
|
||||
default='tcp-client:127.0.0.1:<rootcanal-port>',
|
||||
)
|
||||
@click.option(
|
||||
'--config',
|
||||
|
||||
@@ -47,14 +47,13 @@ from bumble.avdtp import (
|
||||
AVDTP_DELAY_REPORTING_SERVICE_CATEGORY,
|
||||
MediaCodecCapabilities,
|
||||
MediaPacketPump,
|
||||
find_avdtp_service_with_connection,
|
||||
)
|
||||
from bumble.avdtp import Protocol as AvdtpProtocol
|
||||
from bumble.avdtp import find_avdtp_service_with_connection
|
||||
from bumble.avrcp import Protocol as AvrcpProtocol
|
||||
from bumble.colors import color
|
||||
from bumble.core import AdvertisingData
|
||||
from bumble.core import AdvertisingData, DeviceClass, PhysicalTransport
|
||||
from bumble.core import ConnectionError as BumbleConnectionError
|
||||
from bumble.core import DeviceClass, PhysicalTransport
|
||||
from bumble.device import Connection, Device, DeviceConfiguration
|
||||
from bumble.hci import HCI_CONNECTION_ALREADY_EXISTS_ERROR, Address, HCI_Constant
|
||||
from bumble.pairing import PairingConfig
|
||||
@@ -381,11 +380,11 @@ class Player:
|
||||
print(f">>> {color(address.to_string(False), 'yellow')}:")
|
||||
print(f" Device Class (raw): {class_of_device:06X}")
|
||||
major_class_name = DeviceClass.major_device_class_name(major_device_class)
|
||||
print(" Device Major Class: " f"{major_class_name}")
|
||||
print(f" Device Major Class: {major_class_name}")
|
||||
minor_class_name = DeviceClass.minor_device_class_name(
|
||||
major_device_class, minor_device_class
|
||||
)
|
||||
print(" Device Minor Class: " f"{minor_class_name}")
|
||||
print(f" Device Minor Class: {minor_class_name}")
|
||||
print(
|
||||
" Device Services: "
|
||||
f"{', '.join(DeviceClass.service_class_labels(service_classes))}"
|
||||
|
||||
@@ -217,9 +217,7 @@ async def scan(
|
||||
@click.option(
|
||||
'--irk',
|
||||
metavar='<IRK_HEX>:<ADDRESS>',
|
||||
help=(
|
||||
'Use this IRK for resolving private addresses ' '(may be used more than once)'
|
||||
),
|
||||
help=('Use this IRK for resolving private addresses (may be used more than once)'),
|
||||
multiple=True,
|
||||
)
|
||||
@click.option(
|
||||
|
||||
Reference in New Issue
Block a user