Review: Needs Fixing

One question and a request to refactor.

Diff comments:

> === modified file 'openlp/.version'
> --- openlp/.version   2016-12-12 22:16:23 +0000
> +++ openlp/.version   2018-02-10 09:09:49 +0000
> @@ -1 +1 @@
> -2.5.0
> +2.5-bzr2809

why?

> \ No newline at end of file
> 
> === modified file 'openlp/core/projectors/constants.py'
> --- openlp/core/projectors/constants.py       2018-01-03 00:35:14 +0000
> +++ openlp/core/projectors/constants.py       2018-02-10 09:09:49 +0000
> @@ -557,3 +559,24 @@
>          label = "{source}{item}".format(source=source, item=item)
>          PJLINK_DEFAULT_CODES[label] = "{source} 
> {item}".format(source=PJLINK_DEFAULT_SOURCES[source],
>                                                                 
> item=PJLINK_DEFAULT_ITEMS[item])
> +
> +# Get the local IPv4 active address(es) that are NOT localhost (lo or 
> '127.0.0.1')

This is 90% a code duplication so needs to be refactored.
in core/api/tab.py this is similar code looking for the interfaces.
can this be refactored tp core/common please

> +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')


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

_______________________________________________
Mailing list: https://launchpad.net/~openlp-core
Post to     : openlp-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openlp-core
More help   : https://help.launchpad.net/ListHelp

Reply via email to