← Back to team overview

openlp-core team mailing list archive

Re: [Merge] lp:~alisonken1/openlp/pjlink2-p into lp:openlp

 

Review: Needs Fixing

Just the one request, everything else looks spiffy.

Diff comments:

> 
> === modified file 'openlp/core/common/__init__.py'
> --- openlp/core/common/__init__.py	2017-12-29 09:15:48 +0000
> +++ openlp/core/common/__init__.py	2018-02-11 11:56:38 +0000
> @@ -51,6 +52,27 @@
>  NEW_LINE_REGEX = re.compile(r' ?(\r\n?|\n) ?')
>  WHITESPACE_REGEX = re.compile(r'[ \t]+')
>  
> +# Get the local IPv4 active address(es) that are NOT localhost (lo or '127.0.0.1')

Can we put this in a function please? It's not really a good idea to put this at the module level. Also, I'd prefer to call the function than have it just run on startup (when the module is loaded), because IP addresses and things will change (like when a person plugs a network cable in), and it would be a better experience for the user if we could refresh the IP address list occasionally.

> +log.debug('Getting local IPv4 interface(es) information')
> +MY_IP4 = {}
> +for iface in QNetworkInterface.allInterfaces():
> +    if not iface.isValid() or not (iface.flags() & (QNetworkInterface.IsUp | QNetworkInterface.IsRunning)):
> +        continue
> +    for address in iface.addressEntries():
> +        ip = address.ip()
> +        if (ip.protocol() == QAbstractSocket.IPv4Protocol) and (ip != QHostAddress.LocalHost):
> +            MY_IP4[iface.name()] = {'ip': ip.toString(),
> +                                    'broadcast': address.broadcast().toString(),
> +                                    'netmask': address.netmask().toString(),
> +                                    'prefix': address.prefixLength(),
> +                                    'localnet': QHostAddress(address.netmask().toIPv4Address() &
> +                                                             ip.toIPv4Address()).toString()
> +                                    }
> +            log.debug('Adding {iface} to active list'.format(iface=iface.name()))
> +
> +if not MY_IP4:
> +    log.warning('No active IPv4 interfaces found')
> +
>  
>  def trace_error_handler(logger):
>      """


-- 
https://code.launchpad.net/~alisonken1/openlp/pjlink2-p/+merge/337511
Your team OpenLP Core is subscribed to branch lp:openlp.


References