From 14e974781ecfa5bbd07347842e7ca55c9e2cea8f Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 9 Dec 2020 19:54:24 +0100 Subject: [PATCH] fixing bugs --- ereuse_devicehub/resources/action/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ereuse_devicehub/resources/action/views.py b/ereuse_devicehub/resources/action/views.py index 50637ad8..3847fd06 100644 --- a/ereuse_devicehub/resources/action/views.py +++ b/ereuse_devicehub/resources/action/views.py @@ -244,11 +244,15 @@ class ActionView(View): components = snapshot.get('components') if not device: return None + if not components: + return device.hid macs = [c.serial_number for c in components - if c.type == 'NetworkAdapter' and c.serial_number is not None] + if c.type == 'NetworkAdapter' and c.serial_number is not None] macs.sort() mac = '' hid = device.hid + if not hid: + return hid if macs: mac = "-{mac}".format(mac=macs[0]) hid += mac