Commit 93958131 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Fix use of else: after break

parent 2ea04ea3
......@@ -529,13 +529,13 @@ class Ili:
# If no IPv4 gateway was entered break, else process it
if not ipv4gateway_raw:
break
else:
try:
ipaddress.IPv4Address(ipv4gateway_raw)
self.state.add_network_interface_attribute(interface, 'ipv4gateway', ipv4gateway_raw)
break
except ipaddress.AddressValueError:
self._error('ERROR', f'The IPv4 gateway "{ipv4gateway_raw}" is not valid!')
try:
ipaddress.IPv4Address(ipv4gateway_raw)
self.state.add_network_interface_attribute(interface, 'ipv4gateway', ipv4gateway_raw)
break
except ipaddress.AddressValueError:
self._error('ERROR', f'The IPv4 gateway "{ipv4gateway_raw}" is not valid!')
# Get user to choose IPv6 address
has_ipv6 = False
......@@ -549,19 +549,19 @@ class Ili:
# If the user selected cancel, we need to abort
if code == self._dialog.DIALOG_CANCEL:
exit(0)
sys.exit(0)
# If no IPv6 address was entered break, else process it
if not ipv6address_raw:
break
else:
try:
ipaddress.IPv6Network(ipv6address_raw, strict=False)
self.state.add_network_interface_attribute(interface, 'ipv6address', ipv6address_raw)
has_ipv6 = True
break
except ipaddress.AddressValueError:
self._error('ERROR', f'The IPv6 address "{ipv6address_raw}" is not valid!')
try:
ipaddress.IPv6Network(ipv6address_raw, strict=False)
self.state.add_network_interface_attribute(interface, 'ipv6address', ipv6address_raw)
has_ipv6 = True
break
except ipaddress.AddressValueError:
self._error('ERROR', f'The IPv6 address "{ipv6address_raw}" is not valid!')
# If we have IPv6
if has_ipv6:
......@@ -581,13 +581,13 @@ class Ili:
# If no IPv6 gateway was entered break, else process it
if not ipv6gateway_raw:
break
else:
try:
ipaddress.IPv6Address(ipv6gateway_raw)
self.state.add_network_interface_attribute(interface, 'ipv6gateway', ipv6gateway_raw)
break
except ipaddress.AddressValueError:
self._error('ERROR', f'The IPv6 gateway "{ipv6gateway_raw}" is not valid!')
try:
ipaddress.IPv6Address(ipv6gateway_raw)
self.state.add_network_interface_attribute(interface, 'ipv6gateway', ipv6gateway_raw)
break
except ipaddress.AddressValueError:
self._error('ERROR', f'The IPv6 gateway "{ipv6gateway_raw}" is not valid!')
# Get user to choose DNS1 address
has_dns1 = False
......@@ -606,14 +606,14 @@ class Ili:
# If no DNS1 address was entered break, else process it
if not dns1address_raw:
break
else:
try:
ipaddress.ip_address(dns1address_raw)
self.state.add_network_interface_attribute(interface, 'dns1address', dns1address_raw)
has_dns1 = True
break
except ValueError:
self._error('ERROR', f'The DNS1 address "{dns1address_raw}" is not valid!')
try:
ipaddress.ip_address(dns1address_raw)
self.state.add_network_interface_attribute(interface, 'dns1address', dns1address_raw)
has_dns1 = True
break
except ValueError:
self._error('ERROR', f'The DNS1 address "{dns1address_raw}" is not valid!')
# Get user to choose DNS2 address
if has_dns1:
......@@ -632,13 +632,13 @@ class Ili:
# If no DNS2 address was entered break, else process it
if not dns2address_raw:
break
else:
try:
ipaddress.ip_address(dns2address_raw)
self.state.add_network_interface_attribute(interface, 'dns2address', dns2address_raw)
break
except ValueError:
self._error('ERROR', f'The DNS2 address "{dns2address_raw}" is not valid!')
try:
ipaddress.ip_address(dns2address_raw)
self.state.add_network_interface_attribute(interface, 'dns2address', dns2address_raw)
break
except ValueError:
self._error('ERROR', f'The DNS2 address "{dns2address_raw}" is not valid!')
def _get_install_microcode(self):
"""Get the users choice to install microcode."""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment