From a1a48d54cb2b3822896edc57a9ea5557e56af1ff Mon Sep 17 00:00:00 2001 From: ori Date: Wed, 21 Aug 2019 12:49:17 -0700 Subject: [PATCH] bug fix if there is no adapter --- backend/app/handlers/IPHandler.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/backend/app/handlers/IPHandler.py b/backend/app/handlers/IPHandler.py index 8d41f111b..c62aacfde 100644 --- a/backend/app/handlers/IPHandler.py +++ b/backend/app/handlers/IPHandler.py @@ -6,15 +6,17 @@ class ChangeIP: def __init__(self, connection_type, ip, netmask, gateway, hostname): adapter = self.find_adapter() - self.shutdown_adapter(adapter) + if adapter is not None: + self.shutdown_adapter(adapter) - if connection_type == "DHCP": - self.change_to_dhcp(adapter=adapter) - elif connection_type == "Static": - self.change_to_static(adapter=adapter, ip=ip, netmask=netmask, gateway=gateway) + if connection_type == "DHCP": + self.change_to_dhcp(adapter=adapter) + elif connection_type == "Static": + self.change_to_static(adapter=adapter, ip=ip, netmask=netmask, gateway=gateway) + + self.start_adapter(adapter) self.change_hostname(hostname=hostname) - self.start_adapter(adapter) @staticmethod def change_to_dhcp(adapter):