[gnome-keysign: 19/65] handle bluetooth as an optional dependency



commit 4a0ad58c17aa2af63702462b34b432ab93abb859
Author: RyuzakiKK <aasonykk gmail com>
Date:   Thu Aug 17 19:54:42 2017 +0200

    handle bluetooth as an optional dependency

 keysign/discover.py |  5 ++++-
 keysign/offer.py    | 10 +++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/keysign/discover.py b/keysign/discover.py
index 1aad94c..fd86df4 100644
--- a/keysign/discover.py
+++ b/keysign/discover.py
@@ -3,9 +3,12 @@ import logging
 from twisted.internet import threads
 from twisted.internet.defer import inlineCallbacks, returnValue
 
-from .bluetoothreceive import BluetoothReceive
 from .avahidiscovery import AvahiKeysignDiscoveryWithMac
 from .util import parse_barcode
+try:
+    from .bluetoothreceive import BluetoothReceive
+except ImportError:
+    BluetoothReceive = None
 
 log = logging.getLogger(__name__)
 
diff --git a/keysign/offer.py b/keysign/offer.py
index cba712a..7090004 100644
--- a/keysign/offer.py
+++ b/keysign/offer.py
@@ -1,8 +1,11 @@
 import logging
 from twisted.internet.defer import returnValue
 
-from .bluetoothoffer import BluetoothOffer
 from .avahioffer import AvahiHTTPOffer
+try:
+    from .bluetoothoffer import BluetoothOffer
+except ImportError:
+    BluetoothOffer = None
 
 log = logging.getLogger(__name__)
 
@@ -18,8 +21,9 @@ class Offer:
         self.a_offer = AvahiHTTPOffer(self.key)
         a_info = self.a_offer.start()
         code, a_data = a_info
-        self.bt_offer = BluetoothOffer(self.key)
-        _, self.b_data = self.bt_offer.allocate_code()
+        if BluetoothOffer:
+            self.bt_offer = BluetoothOffer(self.key)
+            _, self.b_data = self.bt_offer.allocate_code()
         discovery_data = a_data + ";" + self.b_data
         # As design when we use both avahi and wormhole we only display
         # the wormhole code


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]