Skip to content

Commit

Permalink
handle exception when bluetooth adapter is off
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Robinson committed Nov 13, 2021
1 parent bd38ac2 commit 3e07d1b
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def __init__(self, manager, mac, callback):
self.device = None

def run(self):
self.device = InfiniTimeDevice(manager=self.manager, mac_address=self.mac, thread=True)
self.device = InfiniTimeDevice(
manager=self.manager, mac_address=self.mac, thread=True
)
self.device.services_done = self.data_received
self.device.connect()

Expand Down Expand Up @@ -162,19 +164,22 @@ def do_scanning(self):
print(e)
self.main_stack.set_visible_child_name("nodevice")
self.destroy_manager()

if len(self.manager.get_device_set()) > 0:
self.main_stack.set_visible_child_name("watches")
self.header_stack.set_visible_child_name("watches")
else:
try:
if len(self.manager.get_device_set()) > 0:
self.main_stack.set_visible_child_name("watches")
self.header_stack.set_visible_child_name("watches")
else:
self.main_stack.set_visible_child_name("nodevice")
for mac in self.manager.get_device_set():
print("Found {}".format(mac))
row = self.make_watch_row(self.manager.aliases[mac], mac)
row.mac = mac
row.alias = self.manager.aliases[mac]
self.watches_listbox.add(row)
except AttributeError as e:
print(e)
self.main_stack.set_visible_child_name("nodevice")

for mac in self.manager.get_device_set():
print("Found {}".format(mac))
row = self.make_watch_row(self.manager.aliases[mac], mac)
row.mac = mac
row.alias = self.manager.aliases[mac]
self.watches_listbox.add(row)
self.destroy_manager()
self.populate_tagbox()

def depopulate_listbox(self):
Expand Down Expand Up @@ -349,7 +354,6 @@ def deploy_type_toggled(self, widget):
self.conf.set_property("deploy_type", "quick")
self.rescan_button.emit("clicked")


def update_progress_bar(self):
self.dfu_progress_bar.set_fraction(
self.ble_dfu.total_receipt_size / self.ble_dfu.image_size
Expand Down

0 comments on commit 3e07d1b

Please sign in to comment.