From 9b40301a23076730c43bbf82835cbbdd1a227de0 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Thu, 11 Oct 2018 18:04:10 -0400 Subject: [PATCH] fix another generate_test_data bug --- aioupnp/upnp.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/aioupnp/upnp.py b/aioupnp/upnp.py index c237b2a..19eac13 100644 --- a/aioupnp/upnp.py +++ b/aioupnp/upnp.py @@ -199,9 +199,12 @@ class UPnP: except (UPnPError, NotImplementedError): print("failed to add and remove a mapping") - device = list(self.gateway.devices.values())[0] - assert device.manufacturer and device.modelName - device_path = os.path.join(os.getcwd(), self.gateway.manufacturer_string) + if self.gateway._device: + device = list(self.gateway.devices.values())[0] + assert device.manufacturer and device.modelName + device_path = os.path.join(os.getcwd(), self.gateway.manufacturer_string) + else: + device_path = os.path.join(os.getcwd(), "UNKNOWN GATEWAY") with open(device_path, "w") as f: f.write(json.dumps({ "gateway": self.gateway.debug_gateway(),