summaryrefslogtreecommitdiff
path: root/test/test-health
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-health
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-health')
-rwxr-xr-xtest/test-health62
1 files changed, 32 insertions, 30 deletions
diff --git a/test/test-health b/test/test-health
index 16a5a2bfe..f7d42418a 100755
--- a/test/test-health
+++ b/test/test-health
@@ -1,4 +1,6 @@
#!/usr/bin/python
+
+from __future__ import absolute_import, print_function, unicode_literals
# -*- coding: utf-8 -*-
import dbus
@@ -19,15 +21,15 @@ def sig_received(*args, **kwargs):
return;
sig_name = kwargs["member"]
path = kwargs["path"]
- print sig_name
- print path
+ print(sig_name)
+ print(path)
if sig_name == "PropertyChanged":
k, v = args
- print k
- print v
+ print(k)
+ print(v)
else:
ob = args[0]
- print ob
+ print(ob)
def enter_mainloop():
@@ -38,21 +40,21 @@ def enter_mainloop():
interface_keyword="interface")
try:
- print "Entering main lopp, push Ctrl+C for finish"
+ print("Entering main lopp, push Ctrl+C for finish")
mainloop = gobject.MainLoop()
mainloop.run()
except KeyboardInterrupt:
pass
finally:
- print "Exiting, bye"
+ print("Exiting, bye")
hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/org/bluez"),
"org.bluez.HealthManager")
role = None
while role == None:
- print "Select 1. source or 2. sink: ",
+ print("Select 1. source or 2. sink: ",)
try:
sel = int(sys.stdin.readline())
if sel == 1:
@@ -62,20 +64,20 @@ while role == None:
else:
raise ValueError
except (TypeError, ValueError):
- print "Wrong selection, try again: ",
+ print("Wrong selection, try again: ",)
except KeyboardInterrupt:
sys.exit()
dtype = None
while dtype == None:
- print "Select a data type: ",
+ print("Select a data type: ",)
try:
sel = int(sys.stdin.readline())
if (sel < 0) or (sel > 65535):
raise ValueError
dtype = sel;
except (TypeError, ValueError):
- print "Wrong selection, try again: ",
+ print("Wrong selection, try again: ",)
except KeyboardInterrupt:
sys.exit()
@@ -83,8 +85,8 @@ pref = None
if role == "Source":
while pref == None:
try:
- print "Select a preferred data channel type 1.",
- print "reliable 2. streaming: ",
+ print("Select a preferred data channel type 1.",)
+ print("reliable 2. streaming: ",)
sel = int(sys.stdin.readline())
if sel == 1:
pref = "Reliable"
@@ -94,7 +96,7 @@ if role == "Source":
raise ValueError
except (TypeError, ValueError):
- print "Wrong selection, try again"
+ print("Wrong selection, try again")
except KeyboardInterrupt:
sys.exit()
@@ -109,19 +111,19 @@ else:
"Description": "Test sink",
"Role": role})
-print "New application created:", app_path
+print("New application created:", app_path)
con = None
while con == None:
try:
- print "Connect to a remote device (y/n)? ",
+ print("Connect to a remote device (y/n)? ",)
sel = sys.stdin.readline()
if sel in ("y\n", "yes\n", "Y\n", "YES\n"):
con = True
elif sel in ("n\n", "no\n", "N\n", "NO\n"):
con = False
else:
- print "Wrong selection, try again."
+ print("Wrong selection, try again.")
except KeyboardInterrupt:
sys.exit()
@@ -136,10 +138,10 @@ adapters = manager.ListAdapters()
i = 1
for ad in adapters:
- print "%d. %s" % (i, ad)
+ print("%d. %s" % (i, ad))
i = i + 1
-print "Select an adapter: ",
+print("Select an adapter: ",)
select = None
while select == None:
try:
@@ -148,7 +150,7 @@ while select == None:
raise TypeError
select = adapters[pos]
except (TypeError, IndexError, ValueError):
- print "Wrong selection, try again: ",
+ print("Wrong selection, try again: ",)
except KeyboardInterrupt:
sys.exit()
@@ -158,15 +160,15 @@ adapter = dbus.Interface(bus.get_object("org.bluez", select),
devices = adapter.ListDevices()
if len(devices) == 0:
- print "No devices available"
+ print("No devices available")
sys.exit()
i = 1
for dev in devices:
- print "%d. %s" % (i, dev)
+ print("%d. %s" % (i, dev))
i = i + 1
-print "Select a device: ",
+print("Select a device: ",)
select = None
while select == None:
try:
@@ -175,7 +177,7 @@ while select == None:
raise TypeError
select = devices[pos]
except (TypeError, IndexError, ValueError):
- print "Wrong selection, try again: ",
+ print("Wrong selection, try again: ",)
except KeyboardInterrupt:
sys.exit()
@@ -185,32 +187,32 @@ device = dbus.Interface(bus.get_object("org.bluez", select),
echo = None
while echo == None:
try:
- print "Perform an echo (y/n)? ",
+ print("Perform an echo (y/n)? ",)
sel = sys.stdin.readline()
if sel in ("y\n", "yes\n", "Y\n", "YES\n"):
echo = True
elif sel in ("n\n", "no\n", "N\n", "NO\n"):
echo = False
else:
- print "Wrong selection, try again."
+ print("Wrong selection, try again.")
except KeyboardInterrupt:
sys.exit()
if echo:
if device.Echo():
- print "Echo was ok"
+ print("Echo was ok")
else:
- print "Echo war wrong, exiting"
+ print("Echo war wrong, exiting")
sys.exit()
-print "Connecting to device %s" % (select)
+print("Connecting to device %s" % (select))
if role == "Source":
chan = device.CreateChannel(app_path, "Reliable")
else:
chan = device.CreateChannel(app_path, "Any")
-print chan
+print(chan)
enter_mainloop()