summaryrefslogtreecommitdiff
path: root/test/test-adapter
diff options
context:
space:
mode:
authorSteve Langasek <steve.langasek@canonical.com>2012-05-24 22:44:25 -0700
committerJohan Hedberg <johan.hedberg@intel.com>2012-06-15 12:32:50 +0300
commitee56337e416c084f4f043acdf129cdc9659b63fc (patch)
tree03c718904fefc8a731805d103c7d1ea18f60d2b4 /test/test-adapter
parentebb2896b3a0504dee9da9aff7664e2a6d7bbfc2f (diff)
downloadbluez-ee56337e416c084f4f043acdf129cdc9659b63fc.tar.gz
Update tests to be compatible with gi and python3
This patch makes the python tests source-compatible with python 3, while leaving the interpreter at python 2 for now. The tradeoff is that this source is no longer compatible with python versions < 2.6, and requires gobject-introspection for the glib-based tests.
Diffstat (limited to 'test/test-adapter')
-rwxr-xr-xtest/test-adapter52
1 files changed, 27 insertions, 25 deletions
diff --git a/test/test-adapter b/test/test-adapter
index 762ef980d..4e2f029c1 100755
--- a/test/test-adapter
+++ b/test/test-adapter
@@ -1,5 +1,7 @@
#!/usr/bin/python
+from __future__ import absolute_import, print_function, unicode_literals
+
import sys
import dbus
import time
@@ -26,28 +28,28 @@ adapter = dbus.Interface(bus.get_object("org.bluez", adapter_path),
"org.bluez.Adapter")
if (len(args) < 1):
- print "Usage: %s <command>" % (sys.argv[0])
- print ""
- print " address"
- print " list"
- print " name [name]"
- print " powered [on/off]"
- print " pairable [on/off]"
- print " pairabletimeout [timeout]"
- print " discoverable [on/off]"
- print " discoverabletimeout [timeout]"
- print " discovering"
+ print("Usage: %s <command>" % (sys.argv[0]))
+ print("")
+ print(" address")
+ print(" list")
+ print(" name [name]")
+ print(" powered [on/off]")
+ print(" pairable [on/off]")
+ print(" pairabletimeout [timeout]")
+ print(" discoverable [on/off]")
+ print(" discoverabletimeout [timeout]")
+ print(" discovering")
sys.exit(1)
if (args[0] == "address"):
properties = adapter.GetProperties()
- print properties["Address"]
+ print(properties["Address"])
sys.exit(0)
if (args[0] == "name"):
if (len(args) < 2):
properties = adapter.GetProperties()
- print properties["Name"]
+ print(properties["Name"])
else:
adapter.SetProperty("Name", args[1])
sys.exit(0)
@@ -59,19 +61,19 @@ if (args[0] == "list"):
adapter = dbus.Interface(bus.get_object("org.bluez", adapter_path),
"org.bluez.Adapter")
prop = adapter.GetProperties()
- print " [ %s ]" % (adapter_path)
- for (key, value) in prop.iteritems():
+ print(" [ %s ]" % (adapter_path))
+ for (key, value) in prop.items():
if (key == "Class"):
- print " %s = 0x%06x" % (key, value)
+ print(" %s = 0x%06x" % (key, value))
else:
- print " %s = %s" % (key, value)
- print
+ print(" %s = %s" % (key, value))
+ print()
sys.exit(0)
if (args[0] == "powered"):
if (len(args) < 2):
properties = adapter.GetProperties()
- print properties["Powered"]
+ print(properties["Powered"])
else:
if (args[1] == "on"):
value = dbus.Boolean(1)
@@ -85,7 +87,7 @@ if (args[0] == "powered"):
if (args[0] == "pairable"):
if (len(args) < 2):
properties = adapter.GetProperties()
- print properties["Pairable"]
+ print(properties["Pairable"])
else:
if (args[1] == "on"):
value = dbus.Boolean(1)
@@ -99,7 +101,7 @@ if (args[0] == "pairable"):
if (args[0] == "pairabletimeout"):
if (len(args) < 2):
properties = adapter.GetProperties()
- print properties["PairableTimeout"]
+ print(properties["PairableTimeout"])
else:
timeout = dbus.UInt32(args[1])
adapter.SetProperty("PairableTimeout", timeout)
@@ -108,7 +110,7 @@ if (args[0] == "pairabletimeout"):
if (args[0] == "discoverable"):
if (len(args) < 2):
properties = adapter.GetProperties()
- print properties["Discoverable"]
+ print(properties["Discoverable"])
else:
if (args[1] == "on"):
value = dbus.Boolean(1)
@@ -122,7 +124,7 @@ if (args[0] == "discoverable"):
if (args[0] == "discoverabletimeout"):
if (len(args) < 2):
properties = adapter.GetProperties()
- print properties["DiscoverableTimeout"]
+ print(properties["DiscoverableTimeout"])
else:
timeout = dbus.UInt32(args[1])
adapter.SetProperty("DiscoverableTimeout", timeout)
@@ -130,8 +132,8 @@ if (args[0] == "discoverabletimeout"):
if (args[0] == "discovering"):
properties = adapter.GetProperties()
- print properties["Discovering"]
+ print(properties["Discovering"])
sys.exit(0)
-print "Unknown command"
+print("Unknown command")
sys.exit(1)