From bd0c2445f53e8c049fe7cc4c1b4e2e0a11418bc1 Mon Sep 17 00:00:00 2001 From: Marek Siarkowicz Date: Mon, 15 Jun 2015 01:56:01 +0200 Subject: Ignore bluetooth error. --- bluetooth_paired_devices.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bluetooth_paired_devices.py b/bluetooth_paired_devices.py index 5ab060f..ce86d53 100644 --- a/bluetooth_paired_devices.py +++ b/bluetooth_paired_devices.py @@ -68,7 +68,10 @@ def connect(): "8B6814D3-6CE7-4498-9700-9312C1711F63"] service_matches = [] for uuid in uuids: - service_matches = bluetooth.find_service(uuid=uuid, address=mac) + try: + service_matches = bluetooth.find_service(uuid=uuid, address=mac) + except bluetooth.btcommon.BluetoothError: + pass if service_matches: break @@ -79,14 +82,11 @@ def connect(): first_match = service_matches[0] host = first_match[0] port = first_match[1] + sock = lightblue.socket() else: first_match = service_matches[0] port = first_match["port"] host = first_match["host"] - - if sys.platform == "darwin": - sock = lightblue.socket() - else: sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM) sock.connect((host, port)) -- cgit v1.2.1