flimflam-test: Fix small pylint errors in more scripts
Mostly fix extra imports, rename some variables that redefined python
keywords, and remove semi-colons.
BUG=chromium-os:38166
TEST=Pylint whines less.
Change-Id: I4504f78ac1dd58c6e41199367fd3279ada8f9f11
Reviewed-on: https://gerrit.chromium.org/gerrit/42307
Tested-by: Christopher Wiley <wiley@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Queue: Christopher Wiley <wiley@chromium.org>
diff --git a/test/get-service b/test/get-service
index bb4eb60..f9c335f 100755
--- a/test/get-service
+++ b/test/get-service
@@ -2,7 +2,6 @@
import dbus
import flimflam
-import pprint
import sys
if len(sys.argv) < 2:
@@ -16,15 +15,15 @@
params = { "GUID" : sys.argv[1] }
argv = sys.argv[2:]
while argv:
- property = argv[0]
+ property_key = argv[0]
value = argv[1]
- if property in ["Priority"]:
- params[property] = int(value)
- elif property in ["AutoConnect", "WiFi.HiddenSSID", "EAP.UseSystemCAS",
+ if property_key in ["Priority"]:
+ params[property_key] = int(value)
+ elif property_key in ["AutoConnect", "WiFi.HiddenSSID", "EAP.UseSystemCAS",
"SaveCredentials"]:
- params[property] = dbus.Boolean(value.lower() in ("true", "1"))
+ params[property_key] = dbus.Boolean(value.lower() in ("true", "1"))
else:
- params[property] = value
+ params[property_key] = value
argv = argv[2:]
diff --git a/test/list-entries b/test/list-entries
index 8f70b9c..e16eb47 100755
--- a/test/list-entries
+++ b/test/list-entries
@@ -1,6 +1,6 @@
#!/usr/bin/python
-import dbus, flimflam, string
+import dbus, flimflam
flim = flimflam.FlimFlam(dbus.SystemBus())
@@ -16,5 +16,5 @@
if not "Entries" in properties:
continue
for ident in properties["Entries"]:
- entry = profile.GetEntry(ident);
+ entry = profile.GetEntry(ident)
print " [%s] = %s" % (ident, flimflam.convert_dbus_value(entry, 4))
diff --git a/test/list-ipconfigs b/test/list-ipconfigs
index 421a191..99eb0b0 100755
--- a/test/list-ipconfigs
+++ b/test/list-ipconfigs
@@ -14,8 +14,8 @@
if device is None:
device = flim.FindElementByPropertySubstring('Device', 'Interface', name)
if device is None:
- print "No such device or interface %s" % name
- sys.exit(1)
+ print "No such device or interface %s" % name
+ sys.exit(1)
properties = device.GetProperties(utf8_strings = True)
for path in properties["IPConfigs"]:
diff --git a/test/list-profiles b/test/list-profiles
index e1ec1e4..9a159fd 100755
--- a/test/list-profiles
+++ b/test/list-profiles
@@ -1,6 +1,6 @@
#!/usr/bin/python
-import dbus, flimflam, string
+import dbus, flimflam
flim = flimflam.FlimFlam(dbus.SystemBus())
@@ -14,7 +14,7 @@
properties = profile.GetProperties(utf8_strings = True)
for key in properties.keys():
- print " %s = %s" % \
- (key, flimflam.convert_dbus_value(properties[key], 4))
+ print " %s = %s" % \
+ (key, flimflam.convert_dbus_value(properties[key], 4))
print
diff --git a/test/list-services b/test/list-services
index 8ef96d6..97c4dc6 100755
--- a/test/list-services
+++ b/test/list-services
@@ -1,6 +1,6 @@
#!/usr/bin/python
-import dbus, flimflam, string
+import dbus, flimflam
flim = flimflam.FlimFlam(dbus.SystemBus())
diff --git a/test/pop-profile b/test/pop-profile
index 2263a4a..43ec0b8 100755
--- a/test/pop-profile
+++ b/test/pop-profile
@@ -1,6 +1,6 @@
#!/usr/bin/python
-import dbus, flimflam, string, sys
+import dbus, flimflam, sys
if (len(sys.argv) > 2):
print "usage: %s [identifier]" % sys.argv[0]
diff --git a/test/push-profile b/test/push-profile
index 24f1728..0752077 100755
--- a/test/push-profile
+++ b/test/push-profile
@@ -1,6 +1,6 @@
#!/usr/bin/python
-import dbus, flimflam, string, sys
+import dbus, flimflam, sys
if (len(sys.argv) < 2):
print "Profile identifier required"
diff --git a/test/rm-profile b/test/rm-profile
index af175c6..0560ed9 100755
--- a/test/rm-profile
+++ b/test/rm-profile
@@ -1,6 +1,6 @@
#!/usr/bin/python
-import dbus, flimflam, string, sys
+import dbus, flimflam, sys
if (len(sys.argv) < 2):
print "Profile ident required"
diff --git a/test/service-order b/test/service-order
index ca161e2..ccf5586 100755
--- a/test/service-order
+++ b/test/service-order
@@ -7,5 +7,5 @@
if (len(sys.argv) < 2):
print "Service order is %s" % flim.GetServiceOrder()
else:
- orders = flim.SetServiceOrder(sys.argv[1]);
+ orders = flim.SetServiceOrder(sys.argv[1])
print "Service order %s => %s" % orders
diff --git a/test/set-address b/test/set-address
index 9e98b2a..3a7e64f 100755
--- a/test/set-address
+++ b/test/set-address
@@ -1,6 +1,6 @@
#!/usr/bin/python
-import dbus, flimflam,sys
+import dbus, flimflam, sys
if (len(sys.argv) < 2):
print "Usage: %s <address>" % (sys.argv[0])
diff --git a/test/set-apn b/test/set-apn
index 6829b8e..3ed823d 100755
--- a/test/set-apn
+++ b/test/set-apn
@@ -7,7 +7,7 @@
# Set the APN to be used when making connections on a cellular
# service.
-import pprint, sys
+import sys
import dbus, flimflam
from optparse import OptionParser
@@ -53,7 +53,7 @@
props['apn'] = apn
if options.network_id:
- props['network_id'] = network_id
+ props['network_id'] = options.network_id
if options.username:
props['username'] = options.username
if options.password:
diff --git a/test/set-arp-gateway b/test/set-arp-gateway
index e0d8001..69a9cb2 100644
--- a/test/set-arp-gateway
+++ b/test/set-arp-gateway
@@ -1,6 +1,6 @@
#!/usr/bin/python
-import dbus, flimflam,sys
+import dbus, flimflam, sys
if (len(sys.argv) < 2):
print "Usage: %s [true|false]" % (sys.argv[0])
diff --git a/test/set-bgscan b/test/set-bgscan
index f1296ab..4ed3269 100644
--- a/test/set-bgscan
+++ b/test/set-bgscan
@@ -41,6 +41,6 @@
print ' "var=val", where possible "var" are: %s' % attributes.keys()
sys.exit(1)
elif val == 'default':
- device.ClearProperty(attr);
+ device.ClearProperty(attr)
else:
- device.SetProperty(attr, attributes[attr](val));
+ device.SetProperty(attr, attributes[attr](val))
diff --git a/test/set-country b/test/set-country
index ca14438..03a752a 100755
--- a/test/set-country
+++ b/test/set-country
@@ -1,6 +1,6 @@
#!/usr/bin/python
-import dbus, flimflam,sys
+import dbus, flimflam, sys
if (len(sys.argv) < 2):
print "Usage: %s <country>" % (sys.argv[0])
diff --git a/test/set-device-property b/test/set-device-property
index fa1dc53..204ea6e 100644
--- a/test/set-device-property
+++ b/test/set-device-property
@@ -1,20 +1,21 @@
#!/usr/bin/python
-import dbus, flimflam, string, sys
+import dbus, flimflam, sys
if (len(sys.argv) < 4):
print "Usage: %s <device-name> <property> <value>" % (sys.argv[0])
sys.exit(1)
-(_, name, property, value) = sys.argv
+(_, name, property_key, value) = sys.argv
flim = flimflam.FlimFlam()
device = flim.FindElementByNameSubstring('Device', name)
-if property in ["BgscanShortInterval", "ScanInterval" ]:
- device.SetProperty(property, dbus.Int16(value))
-elif property in [ "BgscanSignalThreshold", ]:
- device.SetProperty(property, int(value))
-elif property in ["Cellular.AllowRoaming", "Powered"]:
- device.SetProperty(property, dbus.Boolean(value.lower() in ("true", "1")))
+if property_key in ["BgscanShortInterval", "ScanInterval" ]:
+ device.SetProperty(property_key, dbus.Int16(value))
+elif property_key in [ "BgscanSignalThreshold", ]:
+ device.SetProperty(property_key, int(value))
+elif property_key in ["Cellular.AllowRoaming", "Powered"]:
+ device.SetProperty(property_key,
+ dbus.Boolean(value.lower() in ("true", "1")))
else:
- device.SetProperty(property, value)
+ device.SetProperty(property_key, value)
diff --git a/test/set-portal-list b/test/set-portal-list
index 4ab0876..e225174 100755
--- a/test/set-portal-list
+++ b/test/set-portal-list
@@ -1,6 +1,6 @@
#!/usr/bin/python
-import dbus, flimflam,sys
+import dbus, flimflam, sys
if (len(sys.argv) < 2):
print "Usage: %s check-portal-list" % (sys.argv[0])
diff --git a/test/set-portal-url b/test/set-portal-url
index a221bf8..2d5d397 100755
--- a/test/set-portal-url
+++ b/test/set-portal-url
@@ -1,6 +1,6 @@
#!/usr/bin/python
-import dbus, flimflam,sys
+import dbus, flimflam, sys
if (len(sys.argv) < 2):
print "Usage: %s portal-url" % (sys.argv[0])
diff --git a/test/set-profile-property b/test/set-profile-property
index a557ac6..cdf529a 100644
--- a/test/set-profile-property
+++ b/test/set-profile-property
@@ -1,13 +1,13 @@
#!/usr/bin/python
-import dbus, flimflam, string, sys
+import flimflam, sys
if (len(sys.argv) < 4):
print "Usage: %s <profile-name> <property> <value>" % (sys.argv[0])
sys.exit(1)
-(_, name, property, value) = sys.argv
+(_, name, property_key, value) = sys.argv
flim = flimflam.FlimFlam()
profile = flim.FindElementByNameSubstring('Profile', name)
-profile.SetProperty(property, value)
+profile.SetProperty(property_key, value)
diff --git a/test/set-service-property b/test/set-service-property
index a7c0bcc..6979150 100644
--- a/test/set-service-property
+++ b/test/set-service-property
@@ -1,19 +1,20 @@
#!/usr/bin/python
-import dbus, flimflam, string, sys
+import dbus, flimflam, sys
if (len(sys.argv) < 4):
print "Usage: %s <service-name> <property> <value>" % (sys.argv[0])
sys.exit(1)
-(_, name, property, value) = sys.argv
+(_, name, property_key, value) = sys.argv
flim = flimflam.FlimFlam()
service = flim.FindElementByNameSubstring('Service', name)
-if property in ["Priority"]:
- service.SetProperty(property, int(value))
-elif property in ["AutoConnect", "WiFi.HiddenSSID", "EAP.UseSystemCAS",
+if property_key in ["Priority"]:
+ service.SetProperty(property_key, int(value))
+elif property_key in ["AutoConnect", "WiFi.HiddenSSID", "EAP.UseSystemCAS",
"SaveCredentials"]:
- service.SetProperty(property, dbus.Boolean(value.lower() in ("true", "1")))
+ service.SetProperty(property_key,
+ dbus.Boolean(value.lower() in ("true", "1")))
else:
- service.SetProperty(property, value)
+ service.SetProperty(property_key, value)
diff --git a/test/show-introspection b/test/show-introspection
index 2d072ef..4713d0d 100755
--- a/test/show-introspection
+++ b/test/show-introspection
@@ -4,22 +4,23 @@
bus = dbus.SystemBus()
-object = dbus.Interface(bus.get_object("org.chromium.flimflam", '/'),
- "org.freedesktop.DBus.Introspectable")
-print object.Introspect()
+flimflam_object = dbus.Interface(bus.get_object("org.chromium.flimflam", '/'),
+ "org.freedesktop.DBus.Introspectable")
+print flimflam_object.Introspect()
manager = dbus.Interface(bus.get_object("org.chromium.flimflam", "/"),
"org.chromium.flimflam.Manager")
properties = manager.GetProperties(utf8_strings = True)
for path in properties["Devices"]:
- object = dbus.Interface(bus.get_object("org.chromium.flimflam", path),
- "org.freedesktop.DBus.Introspectable")
- print object.Introspect()
-
device = dbus.Interface(bus.get_object("org.chromium.flimflam", path),
- "org.chromium.flimflam.Device")
- devprops = device.GetProperties(utf8_strings = True)
+ "org.freedesktop.DBus.Introspectable")
+ print device.Introspect()
+
+ device_object = dbus.Interface(
+ bus.get_object("org.chromium.flimflam", path),
+ "org.chromium.flimflam.Device")
+ devprops = device_object.GetProperties(utf8_strings = True)
for ipconfig_path in devprops["IPConfigs"]:
ipconfig = dbus.Interface(
bus.get_object("org.chromium.flimflam", ipconfig_path),
diff --git a/test/test-manager b/test/test-manager
index df37a5b..e7b32b7 100755
--- a/test/test-manager
+++ b/test/test-manager
@@ -2,14 +2,7 @@
import dbus
-bus = dbus.SystemBus()
-
-manager = dbus.Interface(bus.get_object("org.chromium.flimflam", "/"),
- "org.chromium.flimflam.Manager")
-
-properties = manager.GetProperties(utf8_strings = True)
-
-def print_properties(key, value):
+def print_sub_properties(key, value):
if key == "Profiles":
interface = "org.chromium.flimflam.Profile"
elif key == "Devices":
@@ -44,41 +37,39 @@
print " %s = %s" % (key, val)
- if "Networks" in properties.keys():
- list = ""
- for path in properties["Networks"]:
- val = str(path)
- list = list + val[val.rfind("/") + 1:] + " "
- print " Networks = [ %s]" % (list)
if "Services" in properties.keys():
- list = ""
- for path in properties["Services"]:
- val = str(path)
- list = list + val[val.rfind("/") + 1:] + " "
- print " Services = [ %s]" % (list)
+ remove_prefix = lambda x: x[x.rfind("/") + 1]
+ services = [" ".join(
+ map(remove_prefix, map(str, properties["Services"])))]
+ print " Services = [ %s]" % (services)
-for key in properties.keys():
- if key in ["Profiles", "Devices", "Services"]:
- print_properties(key, properties[key])
- elif key in ["AvailableTechnologies", "EnabledTechnologies",
- "ConnectedTechnologies"]:
- print "%s" % (key)
- list = ""
- for val in properties[key]:
- list = list + val + " "
- print " [ %s]" % (list)
- elif key in ["OfflineMode"]:
- print "%s" % (key)
- if properties[key] == dbus.Boolean(1):
- print " true"
+def print_properties(properties):
+ for key in properties.keys():
+ if key in ["Profiles", "Devices", "Services"]:
+ print_sub_properties(key, properties[key])
+ elif key in ["AvailableTechnologies", "EnabledTechnologies",
+ "ConnectedTechnologies"]:
+ print "%s" % (key)
+ print " [ %s]" % (" ".join(properties[key]))
+ elif key in ["OfflineMode"]:
+ print "%s" % (key)
+ if properties[key] == dbus.Boolean(1):
+ print " true"
+ else:
+ print " false"
+ elif key in ["DefaultTechnology"]:
+ print "%s" % (key)
+ if properties[key] == "":
+ print " <none>"
+ else:
+ print " %s" % (properties[key])
else:
- print " false"
- elif key in ["DefaultTechnology"]:
- print "%s" % (key)
- if properties[key] == "":
- print " <none>"
- else:
+ print "%s" % (key)
print " %s" % (properties[key])
- else:
- print "%s" % (key)
- print " %s" % (properties[key])
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object("org.chromium.flimflam", "/"),
+ "org.chromium.flimflam.Manager")
+
+print_properties(manager.GetProperties(utf8_strings = True))
diff --git a/test/test-profile b/test/test-profile
index 70c2d0d..fa7589b 100755
--- a/test/test-profile
+++ b/test/test-profile
@@ -20,17 +20,18 @@
def print_profiles():
active = flim.GetActiveProfile()
- for profile in flim.GetObjectList("Profile"):
- if profile.object_path == active.object_path:
+ for a_profile in flim.GetObjectList("Profile"):
+ if a_profile.object_path == active.object_path:
isactive = "*"
else:
isactive = " "
# TODO(sleffler) handler ~user paths
- identifier = profile.object_path[profile.object_path.rfind("/") + 1:]
+ identifier = a_profile.object_path[
+ a_profile.object_path.rfind("/") + 1:]
- properties = profile.GetProperties(utf8_strings = True)
- name = properties.get("Name", "<unnamed>");
+ profile_properties = a_profile.GetProperties(utf8_strings = True)
+ name = profile_properties.get("Name", "<unnamed>")
print "%s %-12s %s" % (isactive, identifier, name)
@@ -44,7 +45,7 @@
profile = flim.FindElementByNameSubstring('Profile', sys.argv[2])
if (len(sys.argv) > 3):
- profile.SetProperty("Name", sys.argv[3]);
+ profile.SetProperty("Name", sys.argv[3])
else:
properties = profile.GetProperties(utf8_strings = True)
print "%s" % properties.get("Name", "<unnamed>")