fix up PEP8

This commit is contained in:
Tim Bentley 2018-02-24 16:10:02 +00:00
parent 619d7ce839
commit bff8b193dc
2 changed files with 9 additions and 9 deletions

View File

@ -62,7 +62,7 @@ def get_local_ip4():
""" """
# Get the local IPv4 active address(es) that are NOT localhost (lo or '127.0.0.1') # Get the local IPv4 active address(es) that are NOT localhost (lo or '127.0.0.1')
log.debug('Getting local IPv4 interface(es) information') log.debug('Getting local IPv4 interface(es) information')
MY_IP4 = {} my_ip4 = {}
for iface in QNetworkInterface.allInterfaces(): for iface in QNetworkInterface.allInterfaces():
if not iface.isValid() or not (iface.flags() & (QNetworkInterface.IsUp | QNetworkInterface.IsRunning)): if not iface.isValid() or not (iface.flags() & (QNetworkInterface.IsUp | QNetworkInterface.IsRunning)):
continue continue
@ -70,8 +70,8 @@ def get_local_ip4():
ip = address.ip() ip = address.ip()
# NOTE: Next line will skip if interface is localhost - keep for now until we decide about it later # NOTE: Next line will skip if interface is localhost - keep for now until we decide about it later
# if (ip.protocol() == QAbstractSocket.IPv4Protocol) and (ip != QHostAddress.LocalHost): # if (ip.protocol() == QAbstractSocket.IPv4Protocol) and (ip != QHostAddress.LocalHost):
if (ip.protocol() == QAbstractSocket.IPv4Protocol): if ip.protocol() == QAbstractSocket.IPv4Protocol:
MY_IP4[iface.name()] = {'ip': ip.toString(), my_ip4[iface.name()] = {'ip': ip.toString(),
'broadcast': address.broadcast().toString(), 'broadcast': address.broadcast().toString(),
'netmask': address.netmask().toString(), 'netmask': address.netmask().toString(),
'prefix': address.prefixLength(), 'prefix': address.prefixLength(),
@ -79,16 +79,16 @@ def get_local_ip4():
ip.toIPv4Address()).toString() ip.toIPv4Address()).toString()
} }
log.debug('Adding {iface} to active list'.format(iface=iface.name())) log.debug('Adding {iface} to active list'.format(iface=iface.name()))
if len(MY_IP4) == 1: if len(my_ip4) == 1:
if 'lo' in MY_IP4: if 'lo' in my_ip4:
# No active interfaces - so leave localhost in there # No active interfaces - so leave localhost in there
log.warning('No active IPv4 interfaces found except localhost') log.warning('No active IPv4 interfaces found except localhost')
else: else:
# Since we have a valid IP4 interface, remove localhost # Since we have a valid IP4 interface, remove localhost
log.debug('Found at least one IPv4 interface, removing localhost') log.debug('Found at least one IPv4 interface, removing localhost')
MY_IP4.pop('lo') my_ip4.pop('lo')
return MY_IP4 return my_ip4
def trace_error_handler(logger): def trace_error_handler(logger):