examples: network-scan: resolve PEP8 issues
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.
This commit is contained in:

committed by
Aleksander Morgado

parent
f3f05f397a
commit
c7d0defdde
@@ -35,16 +35,18 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# Connection to ModemManager
|
# Connection to ModemManager
|
||||||
connection = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
|
connection = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
|
||||||
manager = ModemManager.Manager.new_sync (connection, Gio.DBusObjectManagerClientFlags.DO_NOT_AUTO_START, None)
|
manager = ModemManager.Manager.new_sync(
|
||||||
if manager.get_name_owner() is None:
|
connection, Gio.DBusObjectManagerClientFlags.DO_NOT_AUTO_START, None)
|
||||||
|
if not manager.get_name_owner():
|
||||||
sys.stderr.write('ModemManager not found in bus\n')
|
sys.stderr.write('ModemManager not found in bus\n')
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
# Iterate modems and scan network with each one by one
|
# Iterate modems and scan network with each one by one
|
||||||
for obj in manager.get_objects():
|
for obj in manager.get_objects():
|
||||||
modem3gpp = obj.get_modem_3gpp()
|
modem3gpp = obj.get_modem_3gpp()
|
||||||
if modem3gpp is None:
|
if not modem3gpp:
|
||||||
sys.stderr.write('%s: skipping unusable modem...\n' % obj.get_object_path())
|
sys.stderr.write('%s: skipping unusable modem...\n' %
|
||||||
|
obj.get_object_path())
|
||||||
continue
|
continue
|
||||||
modem3gpp.set_default_timeout(300000)
|
modem3gpp.set_default_timeout(300000)
|
||||||
print('%s: starting network scan...' % modem3gpp.get_object_path())
|
print('%s: starting network scan...' % modem3gpp.get_object_path())
|
||||||
@@ -55,7 +57,9 @@ if __name__ == "__main__":
|
|||||||
network.get_operator_code(),
|
network.get_operator_code(),
|
||||||
network.get_operator_short(),
|
network.get_operator_short(),
|
||||||
network.get_operator_short(),
|
network.get_operator_short(),
|
||||||
ModemManager.modem_access_technology_build_string_from_mask (network.get_access_technology()),
|
ModemManager.modem_access_technology_build_string_from_mask(
|
||||||
ModemManager.Modem3gppNetworkAvailability.get_string(network.get_availability())))
|
network.get_access_technology()),
|
||||||
|
ModemManager.Modem3gppNetworkAvailability.get_string(
|
||||||
|
network.get_availability())))
|
||||||
else:
|
else:
|
||||||
print('no networks found')
|
print('no networks found')
|
||||||
|
Reference in New Issue
Block a user