[PATCH 1/2] examples: network-scan: resolve PEP8 issues

Aleksander Morgado aleksander at aleksander.es
Sun Feb 14 22:37:23 UTC 2021


On 13/2/21 17:19, yegorslists at googlemail.com wrote:
> From: Yegor Yefremov <yegorslists at googlemail.com>
> 
> Use autopep8 utility to resolve issues like spaces before brackets
> and wrong hanging indentation.
> 
> Also treat objects like boolean variables to check whether they are
> None or not.
> ---

Merged, thanks

>  .../network-scan-python/network-scan-python   | 24 +++++++++++--------
>  1 file changed, 14 insertions(+), 10 deletions(-)
> 
> diff --git a/examples/network-scan-python/network-scan-python b/examples/network-scan-python/network-scan-python
> index df295995..db12242a 100755
> --- a/examples/network-scan-python/network-scan-python
> +++ b/examples/network-scan-python/network-scan-python
> @@ -34,17 +34,19 @@ if __name__ == "__main__":
>          sys.exit(1)
>  
>      # Connection to ModemManager
> -    connection = Gio.bus_get_sync (Gio.BusType.SYSTEM, None)
> -    manager = ModemManager.Manager.new_sync (connection, Gio.DBusObjectManagerClientFlags.DO_NOT_AUTO_START, None)
> -    if manager.get_name_owner() is None:
> +    connection = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
> +    manager = ModemManager.Manager.new_sync(
> +        connection, Gio.DBusObjectManagerClientFlags.DO_NOT_AUTO_START, None)
> +    if not manager.get_name_owner():
>          sys.stderr.write('ModemManager not found in bus\n')
>          sys.exit(2)
>  
>      # Iterate modems and scan network with each one by one
>      for obj in manager.get_objects():
>          modem3gpp = obj.get_modem_3gpp()
> -        if modem3gpp is None:
> -            sys.stderr.write('%s: skipping unusable modem...\n' % obj.get_object_path())
> +        if not modem3gpp:
> +            sys.stderr.write('%s: skipping unusable modem...\n' %
> +                             obj.get_object_path())
>              continue
>          modem3gpp.set_default_timeout(300000)
>          print('%s: starting network scan...' % modem3gpp.get_object_path())
> @@ -52,10 +54,12 @@ if __name__ == "__main__":
>          if networks:
>              for network in networks:
>                  print('%s: %s - %s (%s, %s)' % (
> -                      network.get_operator_code(),
> -                      network.get_operator_short(),
> -                      network.get_operator_short(),
> -                      ModemManager.modem_access_technology_build_string_from_mask (network.get_access_technology()),
> -                      ModemManager.Modem3gppNetworkAvailability.get_string(network.get_availability())))
> +                    network.get_operator_code(),
> +                    network.get_operator_short(),
> +                    network.get_operator_short(),
> +                    ModemManager.modem_access_technology_build_string_from_mask(
> +                        network.get_access_technology()),
> +                    ModemManager.Modem3gppNetworkAvailability.get_string(
> +                        network.get_availability())))
>          else:
>              print('no networks found')
> 


-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list