From bfbacbfffcfb88759e08bb6fc2b03f023b7f9a00 Mon Sep 17 00:00:00 2001 From: Felipe Martins Diel <41558831+felipediel@users.noreply.github.com> Date: Mon, 8 Jun 2020 07:21:55 -0300 Subject: [PATCH] Handle storage error in broadlink_discovery (#372) --- cli/broadlink_discovery | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cli/broadlink_discovery b/cli/broadlink_discovery index 276884c..8ff02ac 100755 --- a/cli/broadlink_discovery +++ b/cli/broadlink_discovery @@ -3,6 +3,7 @@ import argparse import broadlink +from broadlink.exceptions import StorageError parser = argparse.ArgumentParser(fromfile_prefix_chars='@') parser.add_argument("--timeout", type=int, default=5, help="timeout to wait for receiving discovery responses") @@ -20,8 +21,10 @@ for device in devices: ''.join(format(x, '02x') for x in device.mac))) print("Device file data (to be used with --device @filename in broadlink_cli) : ") print("{} {} {}".format(hex(device.devtype), device.host[0], ''.join(format(x, '02x') for x in device.mac))) - if hasattr(device, 'check_temperature'): + try: print("temperature = {}".format(device.check_temperature())) + except (AttributeError, StorageError): + pass print("") else: print("Error authenticating with device : {}".format(device.host))