Port ofono test scripts to also work with Python3
PATCH 1/1 Port ofono test scripts to also work with Python3
Hello ofono developers,
I already sent this last week, but apparently it never got moderated. I (temporarily) subscribed now [1].
We are in the process of eliminating Python 2 from our images, and thus I ported the ofono test scripts to Python 3.
The first three patches keep the current behaviour and just make the scripts bilingual, i. e. they will work with both Python >= 2.6 and Python 3. They are rather big, but mostly mechanical (2to3 with some overzealous bits removed, and cleaning up some print statements).
Patch 4 moves the scripts from the ancient and long-unmaintained static gobject bindings to gobject-introspection. That's available for both python 2 and 3.
Patch 5 does the remaining bits (unicode and raw_input, and updating hashbangs) and is currently *not* bilingual. If you want these scripts to only work with Python 3 (which should be fine these days), it can be applied (we already did that in the ofono-rilmodem branch[2]). Otherwise, if you generally agree to doing this conversion I'm happy to change it to a form where it works with both Python versions. But that's more involved and it's work that I would only do after getting your "yes, we'll take it" confirmation. :-)
Tony and I tested most of these scripts with phonesim with python 2 and 3 and they work well.
Thanks,
Martin
[1] Without a bug tracker, github pull requests, Launchpad merge requests, or a non-subscriber ML it is painfully difficult to contribute any patch. Do you consider setting up any of those?
[2] https://github.com/rilmodem/ofono
Signature · 2 lines
Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
From 7e6e87d290bed80a4b8d66a59f0ff883ffc33b43 Mon Sep 17 00:00:00 2001
From: Martin Pitt <[email protected]>
Date: Tue, 25 Feb 2014 12:38:34 +0100
Subject: [PATCH 1/5] test: Make print calls compatible with Python 3
Turn print calls into print() function calls and avoid using comma-separated arguments, so that they work and look the same with both Python 2 and 3.
--- test/activate-context | 4 +- test/answer-calls | 4 +- test/backtrace | 8 +-- test/cancel-ussd | 2 +- test/cdma-connman-disable | 2 +- test/cdma-connman-enable | 2 +- test/cdma-dial-number | 2 +- test/cdma-list-call | 4 +- test/cdma-set-credentials | 6 +-- test/change-pin | 4 +- test/create-internet-context | 10 ++-- test/create-mms-context | 10 ++-- test/create-multiparty | 2 +- test/deactivate-context | 4 +- test/dial-number | 6 +-- test/disable-call-forwarding | 12 ++--- test/disable-gprs | 2 +- test/disable-modem | 2 +- test/display-icon | 4 +- test/dundee-connect | 2 +- test/dundee-disconnect | 2 +- test/enable-cbs | 2 +- test/enable-gprs | 2 +- test/enable-modem | 2 +- test/enter-pin | 4 +- test/get-icon | 4 +- test/get-operators | 6 +-- test/get-tech-preference | 2 +- test/hangup-active | 2 +- test/hangup-call | 2 +- test/initiate-ussd | 12 ++--- test/list-calls | 8 +-- test/list-contexts | 8 +-- test/list-messages | 8 +-- test/list-modems | 10 ++-- test/list-operators | 8 +-- test/lock-pin | 4 +- test/lockdown-modem | 4 +- test/monitor-dundee | 16 +++--- test/monitor-ofono | 16 +++--- test/offline-modem | 2 +- test/online-modem | 2 +- test/private-chat | 2 +- test/process-context-settings | 14 ++--- test/receive-sms | 4 +- test/reject-calls | 4 +- test/release-and-answer | 2 +- test/release-and-swap | 2 +- test/remove-contexts | 2 +- test/reset-pin | 4 +- test/scan-for-operators | 8 +-- test/send-sms | 8 +-- test/send-ussd | 14 ++--- test/send-vcal | 6 +-- test/send-vcard | 6 +-- test/set-call-forwarding | 18 +++---- test/set-cbs-topics | 4 +- test/set-context-property | 8 +-- test/set-fast-dormancy | 4 +- test/set-gsm-band | 4 +- test/set-mms-details | 8 +-- test/set-msisdn | 4 +- test/set-roaming-allowed | 2 +- test/set-tech-preference | 4 +- test/set-tty | 4 +- test/set-umts-band | 4 +- test/set-use-sms-reports | 4 +- test/test-advice-of-charge | 32 ++++++------ test/test-call-barring | 26 ++++----- test/test-call-forwarding | 44 ++++++++-------- test/test-call-settings | 48 ++++++++--------- test/test-cbs | 96 +++++++++++++++++----------------- test/test-gnss | 32 ++++++------ test/test-message-waiting | 18 +++---- test/test-modem | 28 +++++----- test/test-network-registration | 24 ++++----- test/test-phonebook | 2 +- test/test-push-notification | 8 +-- test/test-smart-messaging | 16 +++--- test/test-sms | 96 +++++++++++++++++----------------- test/test-ss | 16 +++--- test/test-ss-control-cb | 68 ++++++++++++------------ test/test-ss-control-cf | 32 ++++++------ test/test-ss-control-cs | 84 ++++++++++++++--------------- test/test-stk-menu | 116 ++++++++++++++++++++--------------------- test/unlock-pin | 4 +- 86 files changed, 576 insertions(+), 576 deletions(-)
test/activate-context +2 -2
@@ -20,7 +20,7 @@ for path, properties in modems: contexts = connman.GetContexts() if (len(contexts) == 0): - print "No context available" + print("No context available") sys.exit(1) connman.SetProperty("Powered", dbus.Boolean(1))
@@ -36,5 +36,5 @@ for path, properties in modems: try: context.SetProperty("Active", dbus.Boolean(1), timeout = 100) except dbus.DBusException, e: - print "Error activating %s: %s" % (path, str(e)) + print("Error activating %s: %s" % (path, str(e))) exit(2)
test/answer-calls +2 -2
@@ -10,7 +10,7 @@ manager = dbus.Interface(bus.get_object('org.ofono', '/'), modems = manager.GetModems() for path, properties in modems: - print "[ %s ]" % (path) + print("[ %s ]" % (path)) if "org.ofono.VoiceCallManager" not in properties["Interfaces"]: continue
@@ -22,7 +22,7 @@ for path, properties in modems: for path, properties in calls: state = properties["State"] - print "[ %s ] %s" % (path, state) + print("[ %s ] %s" % (path, state)) if state != "incoming": continue
test/backtrace +4 -4
@@ -6,7 +6,7 @@ import sys import subprocess if (len(sys.argv) < 3): - print "Usage: %s [binary] [log]" % (sys.argv[0]) + print("Usage: %s [binary] [log]" % (sys.argv[0])) sys.exit(1) binary = sys.argv[1]
@@ -50,8 +50,8 @@ child_stdout.close() frame_count = len(frames); count = 0 -print "-------- backtrace --------" +print("-------- backtrace --------") while count < frame_count: - print "[%d]: %s() [%s]" % (count/2, frames[count], frames[count + 1]) + print("[%d]: %s() [%s]" % (count/2, frames[count], frames[count + 1])) count = count + 2 -print "---------------------------" +print("---------------------------")
test/cancel-ussd +1 -1
@@ -21,7 +21,7 @@ ussd = dbus.Interface(bus.get_object('org.ofono', path), properties = ussd.GetProperties() state = properties["State"] -print "State: %s" % (state) +print("State: %s" % (state)) if state != "idle": ussd.Cancel()
test/cdma-connman-disable +1 -1
@@ -13,7 +13,7 @@ else: modems = manager.GetModems() path = modems[0][0] -print "Disconnecting CDMA Packet Data Service on modem %s..." % path +print("Disconnecting CDMA Packet Data Service on modem %s..." % path) cm = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.cdma.ConnectionManager')
test/cdma-connman-enable +1 -1
@@ -13,7 +13,7 @@ else: modems = manager.GetModems() path = modems[0][0] -print "Connecting CDMA Packet Data Service on modem %s..." % path +print("Connecting CDMA Packet Data Service on modem %s..." % path) cm = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.cdma.ConnectionManager')
test/cdma-dial-number +1 -1
@@ -16,7 +16,7 @@ else: path, properties = modems[0] number = sys.argv[1] -print "Using modem %s" % path +print("Using modem %s" % path) manager = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.cdma.VoiceCallManager')
test/cdma-list-call +2 -2
@@ -10,7 +10,7 @@ manager = dbus.Interface(bus.get_object('org.ofono', '/'), modems = manager.GetModems() for path, properties in modems: - print "[ %s ]" % (path) + print("[ %s ]" % (path)) if "org.ofono.cdma.VoiceCallManager" not in properties["Interfaces"]: continue
@@ -22,4 +22,4 @@ for path, properties in modems: for key in properties.keys(): val = str(properties[key]) - print " %s = %s" % (key, val) + print(" %s = %s" % (key, val))
test/cdma-set-credentials +3 -3
@@ -17,12 +17,12 @@ for path, properties in modems: cm = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.cdma.ConnectionManager') - print "Connecting CDMA Packet Data Service on modem %s..." % path + print("Connecting CDMA Packet Data Service on modem %s..." % path) if len(sys.argv) > 1: cm.SetProperty("Username", (sys.argv[1])) - print "Setting Username to %s" % (sys.argv[1]) + print("Setting Username to %s" % (sys.argv[1])) if len(sys.argv) > 2: cm.SetProperty("Password", (sys.argv[2])) - print "Setting Password to %s" % (sys.argv[2]) + print("Setting Password to %s" % (sys.argv[2]))
test/change-pin +2 -2
@@ -19,10 +19,10 @@ elif len(sys.argv) == 3: old_pin = sys.argv[2] new_pin = sys.argv[3] else: - print "%s [PATH] pin_type old_pin new_pin" % (sys.argv[0]) + print("%s [PATH] pin_type old_pin new_pin" % (sys.argv[0])) sys.exit(0) -print "Change %s for modem %s..." % (pin_type, path) +print("Change %s for modem %s..." % (pin_type, path)) simmanager = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.SimManager')
test/create-internet-context +5 -5
@@ -27,21 +27,21 @@ for path, properties in modems: if path == "": path = connman.AddContext("internet") - print "Created new context %s" % (path) + print("Created new context %s" % (path)) else: - print "Found context %s" % (path) + print("Found context %s" % (path)) context = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.ConnectionContext') if len(sys.argv) > 1: context.SetProperty("AccessPointName", sys.argv[1]) - print "Setting APN to %s" % (sys.argv[1]) + print("Setting APN to %s" % (sys.argv[1])) if len(sys.argv) > 2: context.SetProperty("Username", sys.argv[2]) - print "Setting username to %s" % (sys.argv[2]) + print("Setting username to %s" % (sys.argv[2])) if len(sys.argv) > 3: context.SetProperty("Password", sys.argv[3]) - print "Setting password to %s" % (sys.argv[3]) + print("Setting password to %s" % (sys.argv[3]))
test/create-mms-context +5 -5
@@ -27,21 +27,21 @@ for path, properties in modems: if path == "": path = connman.AddContext("mms") - print "Created new context %s" % (path) + print("Created new context %s" % (path)) else: - print "Found context %s" % (path) + print("Found context %s" % (path)) context = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.ConnectionContext') if len(sys.argv) > 1: context.SetProperty("AccessPointName", sys.argv[1]) - print "Setting APN to %s" % (sys.argv[1]) + print("Setting APN to %s" % (sys.argv[1])) if len(sys.argv) > 2: context.SetProperty("Username", sys.argv[2]) - print "Setting username to %s" % (sys.argv[2]) + print("Setting username to %s" % (sys.argv[2])) if len(sys.argv) > 3: context.SetProperty("Password", sys.argv[3]) - print "Setting password to %s" % (sys.argv[3]) + print("Setting password to %s" % (sys.argv[3]))
test/create-multiparty +1 -1
@@ -21,4 +21,4 @@ manager = dbus.Interface(bus.get_object('org.ofono', path), mpty = manager.CreateMultiparty() for path in mpty: - print path + print(path)
test/deactivate-context +2 -2
@@ -20,7 +20,7 @@ for path, properties in modems: contexts = connman.GetContexts() if (len(contexts) == 0): - print "No context available" + print("No context available") sys.exit(1) if len(sys.argv) > 1:
@@ -34,5 +34,5 @@ for path, properties in modems: try: context.SetProperty("Active", dbus.Boolean(0)) except dbus.DBusException, e: - print "Error activating %s: %s" % (path, str(e)) + print("Error activating %s: %s" % (path, str(e))) exit(2)
test/dial-number +3 -3
@@ -4,7 +4,7 @@ import sys import dbus if (len(sys.argv) < 2): - print "Usage: %s [modem] <number> [hide_callerid]" % (sys.argv[0]) + print("Usage: %s [modem] <number> [hide_callerid]" % (sys.argv[0])) sys.exit(1) bus = dbus.SystemBus()
@@ -32,11 +32,11 @@ else: number = sys.argv[2] hide_callerid = sys.argv[3] -print "Using modem %s" % modem +print("Using modem %s" % modem) vcm = dbus.Interface(bus.get_object('org.ofono', modem), 'org.ofono.VoiceCallManager') path = vcm.Dial(number, hide_callerid) -print path +print(path)
test/disable-call-forwarding +6 -6
@@ -8,17 +8,17 @@ import dbus.mainloop.glib def property_changed(property, value): if len(value.__str__()) > 0: - print "CF property %s changed to %s" % (property, value) + print("CF property %s changed to %s" % (property, value)) else: - print "CF property %s changed to disabled" % (property) + print("CF property %s changed to disabled" % (property)) if canexit: mainloop.quit(); if __name__ == "__main__": if len(sys.argv) < 2: - print "Usage: %s <type>" % (sys.argv[0]) - print "Type can be: all, conditional" + print("Usage: %s <type>" % (sys.argv[0])) + print("Type can be: all, conditional") sys.exit(1) canexit = False
@@ -42,10 +42,10 @@ if __name__ == "__main__": try: cf.DisableAll(type, timeout = 100) except dbus.DBusException, e: - print "Unable to DisableAll", e + print("Unable to DisableAll %s" % e) sys.exit(1); - print "DisableAll successful" + print("DisableAll successful") canexit = True
test/disable-gprs +1 -1
@@ -13,7 +13,7 @@ else: modems = manager.GetModems() path = modems[0][0] -print "Disconnecting GPRS on modem %s..." % path +print("Disconnecting GPRS on modem %s..." % path) cm = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.ConnectionManager')
test/disable-modem +1 -1
@@ -13,7 +13,7 @@ else: modems = manager.GetModems() path = modems[0][0] -print "Disconnecting modem %s..." % path +print("Disconnecting modem %s..." % path) modem = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.Modem')
test/display-icon +2 -2
@@ -4,7 +4,7 @@ import sys import dbus if (len(sys.argv) < 2): - print "Usage: %s [modem] icon_id" % (sys.argv[0]) + print("Usage: %s [modem] icon_id" % (sys.argv[0])) sys.exit(1) bus = dbus.SystemBus()
@@ -21,7 +21,7 @@ elif (len(sys.argv) == 3): modem = sys.argv[1] icon = sys.argv[2] -print "Using modem %s" % modem +print("Using modem %s" % modem) sim = dbus.Interface(bus.get_object('org.ofono', modem), 'org.ofono.SimManager')
test/dundee-connect +1 -1
@@ -13,7 +13,7 @@ else: devices = manager.GetDevices() path = devices[0][0] -print "Connect device %s..." % path +print("Connect device %s..." % path) device = dbus.Interface(bus.get_object('org.ofono.dundee', path), 'org.ofono.dundee.Device')
test/dundee-disconnect +1 -1
@@ -13,7 +13,7 @@ else: devices = manager.GetDevices() path = devices[0][0] -print "Disconnect device %s..." % path +print("Disconnect device %s..." % path) device = dbus.Interface(bus.get_object('org.ofono.dundee', path), 'org.ofono.dundee.Device')
test/enable-cbs +1 -1
@@ -13,7 +13,7 @@ else: modems = manager.GetModems() path = modems[0][0] -print "Enabling cell broadcast on modem %s..." % path +print("Enabling cell broadcast on modem %s..." % path) cbs = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.CellBroadcast')
test/enable-gprs +1 -1
@@ -13,7 +13,7 @@ else: modems = manager.GetModems() path = modems[0][0] -print "Connecting modem %s..." % path +print("Connecting modem %s..." % path) cm = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.ConnectionManager')
test/enable-modem +1 -1
@@ -13,7 +13,7 @@ else: modems = manager.GetModems() path = modems[0][0] -print "Connecting modem %s..." % path +print("Connecting modem %s..." % path) modem = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.Modem')
test/enter-pin +2 -2
@@ -17,10 +17,10 @@ elif len(sys.argv) == 3: pin_type = sys.argv[1] pin = sys.argv[2] else: - print "%s [PATH] pin_type pin" % (sys.argv[0]) + print("%s [PATH] pin_type pin" % (sys.argv[0])) sys.exit(0) -print "Enter Pin for modem %s..." % path +print("Enter Pin for modem %s..." % path) simmanager = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.SimManager')
test/get-icon +2 -2
@@ -8,7 +8,7 @@ bus = dbus.SystemBus() if len(sys.argv) == 2: id = sys.argv[1] else: - print "%s <icon id>" % (sys.argv[0]) + print("%s <icon id>" % (sys.argv[0])) sys.exit(0) manager = dbus.Interface(bus.get_object("org.ofono", "/"),
@@ -28,4 +28,4 @@ icon = sim.GetIcon(dbus.Byte(int(sys.argv[1]))) xpm = "" for byte in icon: xpm += str(byte) -print xpm +print(xpm)
test/get-operators +3 -3
@@ -22,7 +22,7 @@ for entry in operators: path = entry[0] properties = entry[1] - print "[ %s ]" % (path) + print("[ %s ]" % (path)) for key in properties.keys(): if key in ["Technologies"]:
@@ -31,7 +31,7 @@ for entry in operators: val += i + " " else: val = str(properties[key]) - print " %s = %s" % (key, val) + print(" %s = %s" % (key, val)) - print + print()
test/get-tech-preference +1 -1
@@ -17,4 +17,4 @@ radiosettings = dbus.Interface(bus.get_object('org.ofono', path), properties = radiosettings.GetProperties() -print "Technology preference: %s" % (properties["TechnologyPreference"]) +print("Technology preference: %s" % (properties["TechnologyPreference"]))
test/hangup-active +1 -1
@@ -18,7 +18,7 @@ calls = manager.GetCalls() for path, properties in calls: state = properties["State"] - print "[ %s ] %s" % (path, state) + print("[ %s ] %s" % (path, state)) if state != "active": continue
test/hangup-call +1 -1
@@ -6,7 +6,7 @@ import dbus bus = dbus.SystemBus() if (len(sys.argv) < 2): - print "Usage: %s [ Call Path ]" % (sys.argv[0]) + print("Usage: %s [ Call Path ]" % (sys.argv[0])) sys.exit(1) call = dbus.Interface(bus.get_object('org.ofono', sys.argv[1]),
test/initiate-ussd +6 -6
@@ -4,7 +4,7 @@ import sys import dbus if (len(sys.argv) < 2): - print "Usage: %s [modem] <ussd-string>" % (sys.argv[0]) + print("Usage: %s [modem] <ussd-string>" % (sys.argv[0])) sys.exit(1) bus = dbus.SystemBus()
@@ -27,7 +27,7 @@ ussd = dbus.Interface(bus.get_object('org.ofono', path), properties = ussd.GetProperties() state = properties["State"] -print "State: %s" % (state) +print("State: %s" % (state)) if state != "idle": sys.exit(1);
@@ -37,12 +37,12 @@ result = ussd.Initiate(ussdstring, timeout=100) properties = ussd.GetProperties() state = properties["State"] -print result[0] + ": " + result[1] +print(result[0] + ": " + result[1]) if state == "idle": sys.exit(0) -print "State: %s" % (state) +print("State: %s" % (state)) while state == "user-response": response = raw_input("Enter response: ")
@@ -52,7 +52,7 @@ while state == "user-response": properties = ussd.GetProperties() state = properties["State"] - print result + print(result) if state != "idle": - print "State: %s" % (state) + print("State: %s" % (state))
test/list-calls +4 -4
@@ -10,7 +10,7 @@ manager = dbus.Interface(bus.get_object('org.ofono', '/'), modems = manager.GetModems() for path, properties in modems: - print "[ %s ]" % (path) + print("[ %s ]" % (path)) if "org.ofono.VoiceCallManager" not in properties["Interfaces"]: continue
@@ -21,11 +21,11 @@ for path, properties in modems: calls = mgr.GetCalls() for path, properties in calls: - print " [ %s ]" % (path) + print(" [ %s ]" % (path)) for key in properties.keys(): if key == 'Icon': - print " %s = %d" % (key, properties[key]) + print(" %s = %d" % (key, properties[key])) else: val = str(properties[key]) - print " %s = %s" % (key, val) + print(" %s = %s" % (key, val))
test/list-contexts +4 -4
@@ -10,7 +10,7 @@ manager = dbus.Interface(bus.get_object('org.ofono', '/'), modems = manager.GetModems() for path, properties in modems: - print "[ %s ]" % (path) + print("[ %s ]" % (path)) if "org.ofono.ConnectionManager" not in properties["Interfaces"]: continue
@@ -21,7 +21,7 @@ for path, properties in modems: contexts = connman.GetContexts() for path, properties in contexts: - print " [ %s ]" % (path) + print(" [ %s ]" % (path)) for key in properties.keys(): if key in ["Settings"] or key in ["IPv6.Settings"]:
@@ -39,6 +39,6 @@ for path, properties in modems: val += " }" else: val = str(properties[key]) - print " %s = %s" % (key, val) + print(" %s = %s" % (key, val)) - print + print()
test/list-messages +4 -4
@@ -10,7 +10,7 @@ manager = dbus.Interface(bus.get_object('org.ofono', '/'), modems = manager.GetModems() for path, properties in modems: - print "[ %s ]" % (path) + print("[ %s ]" % (path)) if "org.ofono.MessageManager" not in properties["Interfaces"]: continue
@@ -21,10 +21,10 @@ for path, properties in modems: contexts = connman.GetMessages() for path, properties in contexts: - print " [ %s ]" % (path) + print(" [ %s ]" % (path)) for key in properties.keys(): val = str(properties[key]) - print " %s = %s" % (key, val) + print(" %s = %s" % (key, val)) - print + print()
test/list-modems +5 -5
@@ -10,7 +10,7 @@ manager = dbus.Interface(bus.get_object('org.ofono', '/'), modems = manager.GetModems() for path, properties in modems: - print "[ %s ]" % (path) + print("[ %s ]" % (path)) for key in properties.keys(): if key in ["Interfaces", "Features"]:
@@ -19,13 +19,13 @@ for path, properties in modems: val += i + " " else: val = properties[key] - print " %s = %s" % (key, val) + print(" %s = %s" % (key, val)) for interface in properties["Interfaces"]: object = dbus.Interface(bus.get_object('org.ofono', path), interface) - print " [ %s ]" % (interface) + print(" [ %s ]" % (interface)) try: properties = object.GetProperties()
@@ -77,6 +77,6 @@ for path, properties in modems: val += " }" else: val = properties[key] - print " %s = %s" % (key, val) + print(" %s = %s" % (key, val)) - print + print()
test/list-operators +4 -4
@@ -11,7 +11,7 @@ manager = dbus.Interface(bus.get_object('org.ofono', '/'), modems = manager.GetModems() for path, properties in modems: - print "[ %s ]" % (path) + print("[ %s ]" % (path)) if "org.ofono.NetworkRegistration" not in properties["Interfaces"]: continue
@@ -25,7 +25,7 @@ for path, properties in modems: operators = netreg.GetOperators() for path, properties in operators: - print " [ %s ]" % (path) + print(" [ %s ]" % (path)) for key in properties.keys(): if key in ["Technologies"]:
@@ -34,6 +34,6 @@ for path, properties in modems: val += i + " " else: val = str(properties[key]) - print " %s = %s" % (key, val) + print(" %s = %s" % (key, val)) - print + print()
test/lock-pin +2 -2
@@ -17,10 +17,10 @@ elif len(sys.argv) == 3: pin_type = sys.argv[1] pin = sys.argv[2] else: - print "%s [PATH] pin_type pin" % (sys.argv[0]) + print("%s [PATH] pin_type pin" % (sys.argv[0])) sys.exit(0) -print "Lock %s %s for modem %s..." % (pin_type, pin, path) +print("Lock %s %s for modem %s..." % (pin_type, pin, path)) simmanager = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.SimManager')
test/lockdown-modem +2 -2
@@ -13,13 +13,13 @@ else: modems = manager.GetModems() path = modems[0][0] -print "Locking and disconnecting modem %s..." % path +print("Locking and disconnecting modem %s..." % path) modem = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.Modem') modem.SetProperty("Lockdown", dbus.Boolean(1)) -print "press ENTER to unlock the modem %s" % path +print("press ENTER to unlock the modem %s" % path) sys.stdin.readline() modem.SetProperty("Lockdown", dbus.Boolean(0))
test/monitor-dundee +8 -8
@@ -52,32 +52,32 @@ def pretty(d): def property_changed(name, value, path, interface): iface = interface[interface.rfind(".") + 1:] - print "{%s} [%s] %s = %s" % (iface, path, name, pretty(value)) + print("{%s} [%s] %s = %s" % (iface, path, name, pretty(value))) def added(name, value, member, path, interface): iface = interface[interface.rfind(".") + 1:] - print "{%s} [%s] %s %s" % (iface, member, name, pretty(value)) + print("{%s} [%s] %s %s" % (iface, member, name, pretty(value))) def removed(name, member, path, interface): iface = interface[interface.rfind(".") + 1:] - print "{%s} [%s] %s" % (iface, member, name) + print("{%s} [%s] %s" % (iface, member, name)) def event(member, path, interface): iface = interface[interface.rfind(".") + 1:] - print "{%s} [%s] %s" % (iface, path, member) + print("{%s} [%s] %s" % (iface, path, member)) def message(msg, args, member, path, interface): iface = interface[interface.rfind(".") + 1:] - print "{%s} [%s] %s %s (%s)" % (iface, path, member, - str(msg), pretty(args)) + print("{%s} [%s] %s %s (%s)" % (iface, path, member, + str(msg), pretty(args))) def ussd(msg, member, path, interface): iface = interface[interface.rfind(".") + 1:] - print "{%s} [%s] %s %s" % (iface, path, member, str(msg)) + print("{%s} [%s] %s %s" % (iface, path, member, str(msg))) def value(value, member, path, interface): iface = interface[interface.rfind(".") + 1:] - print "{%s} [%s] %s %s" % (iface, path, member, str(value)) + print("{%s} [%s] %s %s" % (iface, path, member, str(value))) if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
test/monitor-ofono +8 -8
@@ -55,32 +55,32 @@ def pretty(d): def property_changed(name, value, path, interface): iface = interface[interface.rfind(".") + 1:] - print "{%s} [%s] %s = %s" % (iface, path, name, pretty(value)) + print("{%s} [%s] %s = %s" % (iface, path, name, pretty(value))) def added(name, value, member, path, interface): iface = interface[interface.rfind(".") + 1:] - print "{%s} [%s] %s %s" % (iface, member, name, pretty(value)) + print("{%s} [%s] %s %s" % (iface, member, name, pretty(value))) def removed(name, member, path, interface): iface = interface[interface.rfind(".") + 1:] - print "{%s} [%s] %s" % (iface, name, member) + print("{%s} [%s] %s" % (iface, name, member)) def event(member, path, interface): iface = interface[interface.rfind(".") + 1:] - print "{%s} [%s] %s" % (iface, path, member) + print("{%s} [%s] %s" % (iface, path, member)) def message(msg, args, member, path, interface): iface = interface[interface.rfind(".") + 1:] - print "{%s} [%s] %s %s (%s)" % (iface, path, member, - msg, pretty(args)) + print("{%s} [%s] %s %s (%s)" % (iface, path, member, + msg, pretty(args))) def ussd(msg, member, path, interface): iface = interface[interface.rfind(".") + 1:] - print "{%s} [%s] %s %s" % (iface, path, member, msg) + print("{%s} [%s] %s %s" % (iface, path, member, msg)) def value(value, member, path, interface): iface = interface[interface.rfind(".") + 1:] - print "{%s} [%s] %s %s" % (iface, path, member, str(value)) + print("{%s} [%s] %s %s" % (iface, path, member, str(value))) if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
test/offline-modem +1 -1
@@ -12,6 +12,6 @@ else: modems = manager.GetModems() path = modems[0][0] -print "Setting modem %s offline..." % path +print("Setting modem %s offline..." % path) modem = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.Modem') modem.SetProperty("Online", dbus.Boolean(0), timeout = 120)
test/online-modem +1 -1
@@ -12,6 +12,6 @@ else: modems = manager.GetModems() path = modems[0][0] -print "Setting modem %s online..." % path +print("Setting modem %s online..." % path) modem = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.Modem') modem.SetProperty("Online", dbus.Boolean(1), timeout = 120)
test/private-chat +1 -1
@@ -23,4 +23,4 @@ manager = dbus.Interface(bus.get_object('org.ofono', path), mpty = manager.PrivateChat(callid, timeout=100) for path in mpty: - print path + print(path)
test/process-context-settings +7 -7
@@ -23,7 +23,7 @@ for path, properties in modems: if properties["Active"] == dbus.Boolean(0): continue - print "Configuring %s" % (path) + print("Configuring %s" % (path)) settings = properties["Settings"]
@@ -35,20 +35,20 @@ for path, properties in modems: gateway = "0.0.0.0"; if settings["Method"] == "dhcp": - print " Run DHCP on interface %s" % (interface) + print(" Run DHCP on interface %s" % (interface)) else: - print " Interface is %s" % (interface) - print " IP address is %s" % (address) - print " Gateway is %s" % (gateway) + print(" Interface is %s" % (interface)) + print(" IP address is %s" % (address)) + print(" Gateway is %s" % (gateway)) cmd = "ifconfig " + interface + " " + address cmd += " netmask 255.255.255.255" os.system(cmd); for i in settings["DomainNameServers"]: - print " Nameserver is %s" % (i) + print(" Nameserver is %s" % (i)) cmd = "route add -host " + i cmd +=" dev " + interface os.system(cmd); - print + print()
test/receive-sms +2 -2
@@ -6,11 +6,11 @@ import dbus import dbus.mainloop.glib def incoming_message(message, details, path, interface): - print "%s" % (message) + print("%s" % (message)) for key in details: val = details[key] - print " %s = %s" % (key, val) + print(" %s = %s" % (key, val)) if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
test/reject-calls +2 -2
@@ -10,7 +10,7 @@ manager = dbus.Interface(bus.get_object('org.ofono', '/'), modems = manager.GetModems() for path, properties in modems: - print "[ %s ]" % (path) + print("[ %s ]" % (path)) if "org.ofono.VoiceCallManager" not in properties["Interfaces"]: continue
@@ -22,7 +22,7 @@ for path, properties in modems: for path, properties in calls: state = properties["State"] - print "[ %s ] %s" % (path, state) + print("[ %s ] %s" % (path, state)) if state != "incoming": continue
test/release-and-answer +1 -1
@@ -10,7 +10,7 @@ manager = dbus.Interface(bus.get_object('org.ofono', '/'), modems = manager.GetModems() for path, properties in modems: - print "[ %s ]" % (path) + print("[ %s ]" % (path)) if "org.ofono.VoiceCallManager" not in properties["Interfaces"]: continue
test/release-and-swap +1 -1
@@ -10,7 +10,7 @@ manager = dbus.Interface(bus.get_object('org.ofono', '/'), modems = manager.GetModems() for path, properties in modems: - print "[ %s ]" % (path) + print("[ %s ]" % (path)) if "org.ofono.VoiceCallManager" not in properties["Interfaces"]: continue
test/remove-contexts +1 -1
@@ -20,4 +20,4 @@ for path, properties in modems: for path, properties in contexts: connman.RemoveContext(path) - print"Removed: [ %s ]" % (path) + print("Removed: [ %s ]" % (path))
test/reset-pin +2 -2
@@ -14,9 +14,9 @@ elif len(sys.argv) == 4: path = modems[0][0] puk_type, puk, pin = sys.argv[1:] else: - print "%s [PATH] puk_type puk pin" % (sys.argv[0]) + print("%s [PATH] puk_type puk pin" % (sys.argv[0])) -print "Reset pin for modem %s..." % path +print("Reset pin for modem %s..." % path) simmanager = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.SimManager')
test/scan-for-operators +4 -4
@@ -13,7 +13,7 @@ else: modems = manager.GetModems() path = modems[0][0] -print "Scanning operators on modem %s..." % path +print("Scanning operators on modem %s..." % path) netreg = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.NetworkRegistration')
@@ -23,7 +23,7 @@ for entry in operators: path = entry[0] properties = entry[1] - print "[ %s ]" % (path) + print("[ %s ]" % (path)) for key in properties.keys(): if key in ["Technologies"]:
@@ -32,7 +32,7 @@ for entry in operators: val += i + " " else: val = str(properties[key]) - print " %s = %s" % (key, val) + print(" %s = %s" % (key, val)) - print + print()
test/send-sms +4 -4
@@ -4,8 +4,8 @@ import sys import dbus if len(sys.argv) < 4: - print "Usage: %s [modem] <to> <message> <delivery report>" %\ - (sys.argv[0]) + print("Usage: %s [modem] <to> <message> <delivery report>" %\ + (sys.argv[0])) sys.exit(1) bus = dbus.SystemBus()
@@ -18,7 +18,7 @@ else: modems = manager.GetModems() path = modems[0][0] -print "Send message using modem %s ..." % path +print("Send message using modem %s ..." % path) mm = dbus.Interface(bus.get_object('org.ofono', path),
@@ -31,4 +31,4 @@ else: mm.SetProperty("UseDeliveryReports", dbus.Boolean(int(sys.argv[3]))) path = mm.SendMessage(sys.argv[1], sys.argv[2]) -print path +print(path)
test/send-ussd +7 -7
@@ -4,7 +4,7 @@ import sys import dbus if (len(sys.argv) < 2): - print "Usage: %s [modem] <ussd-string>" % (sys.argv[0]) + print("Usage: %s [modem] <ussd-string>" % (sys.argv[0])) sys.exit(1) bus = dbus.SystemBus()
@@ -27,13 +27,13 @@ ussd = dbus.Interface(bus.get_object('org.ofono', path), properties = ussd.GetProperties() state = properties["State"] -print "State: %s" % (state) +print("State: %s" % (state)) if state == "idle": result = ussd.Initiate(ussdstring, timeout=100) - print result[0] + ": " + result[1] + print(result[0] + ": " + result[1]) elif state == "user-response": - print ussd.Respond(ussdstring, timeout=100) + print(ussd.Respond(ussdstring, timeout=100)) else: sys.exit(1);
@@ -43,15 +43,15 @@ state = properties["State"] if state == "idle": sys.exit(0) -print "State: %s" % (state) +print("State: %s" % (state)) while state == "user-response": response = raw_input("Enter response: ") - print ussd.Respond(response, timeout=100) + print(ussd.Respond(response, timeout=100)) properties = ussd.GetProperties() state = properties["State"] if state != "idle": - print "State: %s" % (state) + print("State: %s" % (state))
test/send-vcal +3 -3
@@ -4,7 +4,7 @@ import sys import dbus if len(sys.argv) < 3: - print "Usage: %s [modem] <to> <vcal file>" % (sys.argv[0]) + print("Usage: %s [modem] <to> <vcal file>" % (sys.argv[0])) sys.exit(1) bus = dbus.SystemBus()
@@ -17,7 +17,7 @@ else: modems = manager.GetModems() path = modems[0][0] -print "Send vcal using modem %s ..." % path +print("Send vcal using modem %s ..." % path) sm = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.SmartMessaging')
@@ -29,4 +29,4 @@ else: vcal = file(sys.argv[2]).read() path = sm.SendAppointment(sys.argv[1], vcal) -print path +print(path)
test/send-vcard +3 -3
@@ -4,7 +4,7 @@ import sys import dbus if len(sys.argv) < 3: - print "Usage: %s [modem] <to> <vcard file>" % (sys.argv[0]) + print("Usage: %s [modem] <to> <vcard file>" % (sys.argv[0])) sys.exit(1) bus = dbus.SystemBus()
@@ -17,7 +17,7 @@ else: modems = manager.GetModems() path = modems[0][0] -print "Send vcard using modem %s ..." % path +print("Send vcard using modem %s ..." % path) sm = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.SmartMessaging')
@@ -29,4 +29,4 @@ else: vcard = file(sys.argv[2]).read() path = sm.SendBusinessCard(sys.argv[1], vcard) -print path +print(path)
test/set-call-forwarding +9 -9
@@ -8,19 +8,19 @@ import dbus.mainloop.glib def property_changed(property, value): if len(value.__str__()) > 0: - print "CF property %s changed to %s" % (property, value) + print("CF property %s changed to %s" % (property, value)) else: - print "CF property %s changed to disabled" % (property) + print("CF property %s changed to disabled" % (property)) if canexit: mainloop.quit(); if __name__ == "__main__": if len(sys.argv) < 3: - print "Usage: %s <property> <value>" % (sys.argv[0]) - print "Properties can be: VoiceUnconditional, VoiceBusy," - print " VoiceNoReply, VoiceNoReplyTimeout, VoiceNotReachable" - print "Value: number to or the timeout" + print("Usage: %s <property> <value>" % (sys.argv[0])) + print("Properties can be: VoiceUnconditional, VoiceBusy,") + print(" VoiceNoReply, VoiceNoReplyTimeout, VoiceNotReachable") + print("Value: number to or the timeout") sys.exit(1) property = sys.argv[1]
@@ -47,16 +47,16 @@ if __name__ == "__main__": cf.SetProperty(property, dbus.UInt16(value), timeout = 100) except dbus.DBusException, e: - print "Unable SetProperty", e + print("Unable SetProperty %s" % e) sys.exit(1); else: try: cf.SetProperty(property, value, timeout = 100) except dbus.DBusException, e: - print "Unable SetProperty", e + print("Unable SetProperty %s" % e) sys.exit(1); - print "Set Property successful" + print("Set Property successful") canexit = True
test/set-cbs-topics +2 -2
@@ -15,9 +15,9 @@ elif len(sys.argv) == 2: path = modems[0][0] topics = sys.argv[1] else: - print "%s [PATH] topics" % (sys.argv[0]) + print("%s [PATH] topics" % (sys.argv[0])) -print "Setting cell broadcast topics for modem %s..." % path +print("Setting cell broadcast topics for modem %s..." % path) cbs = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.CellBroadcast')
test/set-context-property +4 -4
@@ -4,7 +4,7 @@ import sys import dbus if len(sys.argv) < 4: - print "Usage: set-context-property <context> <name> <value>" + print("Usage: set-context-property <context> <name> <value>") sys.exit(1) bus = dbus.SystemBus()
@@ -24,7 +24,7 @@ for path, properties in modems: contexts = connman.GetContexts() if (len(contexts) == 0): - print "No context available" + print("No context available") sys.exit(1) path = contexts[int(sys.argv[1])][0]
@@ -34,6 +34,6 @@ for path, properties in modems: try: context.SetProperty(sys.argv[2], sys.argv[3]) except dbus.DBusException, e: - print "Error setting context %s property %s: %s" %\ - (path, sys.argv[2], str(e)) + print("Error setting context %s property %s: %s" %\ + (path, sys.argv[2], str(e))) exit(2)
test/set-fast-dormancy +2 -2
@@ -15,10 +15,10 @@ elif len(sys.argv) == 2: path = modems[0][0] enable = int(sys.argv[1]) else: - print "%s [PATH] {0|1}" % (sys.argv[0]) + print("%s [PATH] {0|1}" % (sys.argv[0])) exit(1) -print "Setting fast dormancy for modem %s..." % path +print("Setting fast dormancy for modem %s..." % path) radiosettings = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.RadioSettings')
test/set-gsm-band +2 -2
@@ -15,10 +15,10 @@ elif len(sys.argv) == 2: path = modems[0][0] band = sys.argv[1] else: - print "%s [PATH] band" % (sys.argv[0]) + print("%s [PATH] band" % (sys.argv[0])) exit(1) -print "Setting gsm band for modem %s..." % path +print("Setting gsm band for modem %s..." % path) radiosettings = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.RadioSettings')
test/set-mms-details +4 -4
@@ -26,18 +26,18 @@ for path, properties in modems: break if path == "": - print "No MMS context" + print("No MMS context") exit(1) context = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.ConnectionContext') if len(sys.argv) < 3: - print "Usage: %s <proxy> <center>" % (sys.argv[0]) + print("Usage: %s <proxy> <center>" % (sys.argv[0])) exit(1) context.SetProperty("MessageProxy", sys.argv[1]) - print "Setting MMS Proxy to %s" % (sys.argv[1]) + print("Setting MMS Proxy to %s" % (sys.argv[1])) context.SetProperty("MessageCenter", sys.argv[2]) - print "Setting MMSC to %s" % (sys.argv[2]) + print("Setting MMSC to %s" % (sys.argv[2]))
test/set-msisdn +2 -2
@@ -15,10 +15,10 @@ elif len(sys.argv) == 2: path = modems[0][0] number = sys.argv[1] else: - print "%s [PATH] <number>" % (sys.argv[0]) + print("%s [PATH] <number>" % (sys.argv[0])) exit(1) -print "Setting MSISDN for modem %s..." % path +print("Setting MSISDN for modem %s..." % path) sim = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.SimManager') sim.SetProperty("SubscriberNumbers", [number]);
test/set-roaming-allowed +1 -1
@@ -24,4 +24,4 @@ for path, properties in modems: connman.SetProperty("RoamingAllowed", allowed) - print "Setting %s to RoamingAllowed=%d" % (path, allowed) + print("Setting %s to RoamingAllowed=%d" % (path, allowed))
test/set-tech-preference +2 -2
@@ -15,9 +15,9 @@ elif len(sys.argv) == 2: path = modems[0][0] tech = sys.argv[1] else: - print "%s [PATH] technology" % (sys.argv[0]) + print("%s [PATH] technology" % (sys.argv[0])) -print "Setting technology preference for modem %s..." % path +print("Setting technology preference for modem %s..." % path) radiosettings = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.RadioSettings')
test/set-tty +2 -2
@@ -15,10 +15,10 @@ elif len(sys.argv) == 2: path = modems[0][0] enable = int(sys.argv[1]) else: - print "%s [PATH] {0|1}" % (sys.argv[0]) + print("%s [PATH] {0|1}" % (sys.argv[0])) exit(1) -print "Setting TTY for modem %s..." % path +print("Setting TTY for modem %s..." % path) texttelephony = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.TextTelephony')
test/set-umts-band +2 -2
@@ -15,10 +15,10 @@ elif len(sys.argv) == 2: path = modems[0][0] band = sys.argv[1] else: - print "%s [PATH] band" % (sys.argv[0]) + print("%s [PATH] band" % (sys.argv[0])) exit(1) -print "Setting umts band for modem %s..." % path +print("Setting umts band for modem %s..." % path) radiosettings = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.RadioSettings')
test/set-use-sms-reports +2 -2
@@ -19,10 +19,10 @@ elif len(sys.argv) == 2: if sys.argv[1] == "off": enabled = 0 else: - print "%s [PATH] on/off" % (sys.argv[0]) + print("%s [PATH] on/off" % (sys.argv[0])) sys.exit(1) -print "Setting delivery report use for modem %s..." % path +print("Setting delivery report use for modem %s..." % path) sms = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.MessageManager')
test/test-advice-of-charge +16 -16
@@ -7,16 +7,16 @@ import dbus.mainloop.glib def cm_property_changed(name, value): - print "CallMeter property: '%s' changed to '%s'" % (name, str(value)) + print("CallMeter property: '%s' changed to '%s'" % (name, str(value))) if canexit: mainloop.quit() def cm_maximum_reached(): - print "Only 30 seconds call time remains, recharge." + print("Only 30 seconds call time remains, recharge.") def print_useage(s): - print "Usage: %s <property> <newvalue> <password>" % (s) - print "Usage: %s reset <password>" % (s) + print("Usage: %s <property> <newvalue> <password>" % (s)) + print("Usage: %s reset <password>" % (s)) sys.exit(1); if __name__ == "__main__":
@@ -51,24 +51,24 @@ if __name__ == "__main__": properties = cm.GetProperties() - print "Currency: %s" % (properties['Currency']) - print "PricePerUnit %s" % (properties['PricePerUnit']) - print "Call meter for the current call: %s" % (properties['CallMeter']) - print "Call meter for current and previous calls: %s" %\ - properties['AccumulatedCallMeter'] - print "Call meter maximum, once reached calls are not possible: %s" %\ - properties['AccumulatedCallMeterMaximum'] + print("Currency: %s" % (properties['Currency'])) + print("PricePerUnit %s" % (properties['PricePerUnit'])) + print("Call meter for the current call: %s" % (properties['CallMeter'])) + print("Call meter for current and previous calls: %s" %\ + properties['AccumulatedCallMeter']) + print("Call meter maximum, once reached calls are not possible: %s" %\ + properties['AccumulatedCallMeterMaximum']) total = properties['PricePerUnit'] * properties['AccumulatedCallMeter'] - print "Accumulated Meter in Currency: %s %s" %\ - (total, properties['Currency']) + print("Accumulated Meter in Currency: %s %s" %\ + (total, properties['Currency'])) if (sys.argv[1] == 'reset'): - print "Resetting Accumulated Call Meter" + print("Resetting Accumulated Call Meter") try: cm.Reset(pin) except dbus.DBusException, e: - print "Unable to reset ACM: ", e + print("Unable to reset ACM: %s" % e) sys.exit(1) else: try:
@@ -78,7 +78,7 @@ if __name__ == "__main__": newvalue = float(newvalue) cm.SetProperty(property, newvalue, pin) except dbus.DBusException, e: - print "Unable to set property: ", e + print("Unable to set property: %s" % e) sys.exit(1) canexit = True
test/test-call-barring +13 -13
@@ -7,14 +7,14 @@ import dbus.mainloop.glib def property_changed(name, value): - print "CallBarring property: '%s' changed to '%s'" % (name, str(value)) + print("CallBarring property: '%s' changed to '%s'" % (name, str(value))) if canexit: mainloop.quit() def print_useage(s): - print "Usage: %s <property> <newvalue> <password>" % (s) - print "Usage: %s disableall <password>" % (s) - print "Usage: %s passwd <old_password> <new_password>" % (s) + print("Usage: %s <property> <newvalue> <password>" % (s)) + print("Usage: %s disableall <password>" % (s)) + print("Usage: %s passwd <old_password> <new_password>" % (s)) sys.exit(1); if __name__ == "__main__":
@@ -51,31 +51,31 @@ if __name__ == "__main__": properties = cb.GetProperties() - print "Barring settings for Incoming Voice calls: %s" %\ - (properties['VoiceIncoming']) - print "Barring settings for Outgoing Calls: %s" %\ - (properties['VoiceOutgoing']) + print("Barring settings for Incoming Voice calls: %s" %\ + (properties['VoiceIncoming'])) + print("Barring settings for Outgoing Calls: %s" %\ + (properties['VoiceOutgoing'])) if (sys.argv[1] == 'disableall'): - print "Disabling all barrings" + print("Disabling all barrings") try: cb.DisableAll(pin) except dbus.DBusException, e: - print "Unable to Disable All barrings: ", e + print("Unable to Disable All barrings: ", e) sys.exit(1) elif (sys.argv[1] == 'passwd'): try: cb.ChangePassword(old_password, new_password) except dbus.DBusException, e: - print "Unable to change password: ", e + print("Unable to change password: ", e) sys.exit(1) - print "Password changed" + print("Password changed") sys.exit(0) else: try: cb.SetProperty(property, newvalue, pin) except dbus.DBusException, e: - print "Unable to set property: ", e + print("Unable to set property: ", e) sys.exit(1) canexit = True
test/test-call-forwarding +22 -22
121 lines not on this page · raw message
test/test-call-settings +24 -24
80 lines not on this page · raw message
test/test-cbs +48 -48
175 lines not on this page · raw message
test/test-gnss +16 -16
@@ -15,27 +15,27 @@ class PositioningAgent(dbus.service.Object): @dbus.service.method(AGENT_INTERFACE, in_signature="", out_signature="") def Release(self): - print "Release" + print("Release") mainloop.quit() @dbus.service.method(AGENT_INTERFACE, in_signature="s", out_signature="") def Request(self, xml): - print "positioning data: %s" % (xml) + print("positioning data: %s" % (xml)) @dbus.service.method(AGENT_INTERFACE, in_signature="", out_signature="") def ResetAssistanceData(self): - print "Reset Assistance Data request received" + print("Reset Assistance Data request received") def print_menu(): - print "Select test case" - print "-----------------------------------------------------------" - print "[0] SendPositioningElement" - print "[1] RegisterPositioningRequestAgent" - print "[2] UnregisterPositioningRequestAgent" - print "[x] Exit" - print "-----------------------------------------------------------" + print("Select test case") + print("-----------------------------------------------------------") + print("[0] SendPositioningElement") + print("[1] RegisterPositioningRequestAgent") + print("[2] UnregisterPositioningRequestAgent") + print("[x] Exit") + print("-----------------------------------------------------------") def stdin_handler(fd, condition, gnss, path): in_key = os.read(fd.fileno(), 8).rstrip()
@@ -43,23 +43,23 @@ def stdin_handler(fd, condition, gnss, path): xml = raw_input('type the element and press enter: ') try: gnss.SendPositioningElement(dbus.String(xml)) - print "ok" + print("ok") except dbus.DBusException, e: - print "Unable to send positioning element" + print("Unable to send positioning element") elif in_key == '1': try: gnss.RegisterPositioningRequestAgent("/test/posagent") - print "ok" + print("ok") except dbus.DBusException, e: - print "Unable to register positioning agent" + print("Unable to register positioning agent") elif in_key == '2': try: gnss.UnregisterPositioningRequestAgent(path) - print "ok" + print("ok") except dbus.DBusException, e: - print "Unable to unregister positioning agent" + print("Unable to unregister positioning agent") elif in_key == 'x': sys.exit(1)
test/test-message-waiting +9 -9
@@ -7,11 +7,11 @@ import dbus.mainloop.glib def mw_property_changed(name, value): if name == 'VoicemailMessageCount': - print "MessageWaiting property: '%s' changed to '%d'" %\ - (name,value) + print("MessageWaiting property: '%s' changed to '%d'" %\ + (name,value)) else: - print "MessageWaiting property: '%s' changed to '%s'" %\ - (name,value) + print("MessageWaiting property: '%s' changed to '%s'" %\ + (name,value)) if __name__ == "__main__": dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
@@ -30,11 +30,11 @@ if __name__ == "__main__": properties = mw.GetProperties() - print "Voicemail waiting: %s" % (properties['VoicemailWaiting']) - print "Voicemail message count: %d" %\ - (properties['VoicemailMessageCount']) - print "Voicemail mailbox number: %s" %\ - (properties['VoicemailMailboxNumber']) + print("Voicemail waiting: %s" % (properties['VoicemailWaiting'])) + print("Voicemail message count: %d" %\ + (properties['VoicemailMessageCount'])) + print("Voicemail mailbox number: %s" %\ + (properties['VoicemailMailboxNumber'])) mainloop = gobject.MainLoop() mainloop.run()
test/test-modem +14 -14
@@ -6,7 +6,7 @@ import dbus import dbus.mainloop.glib def property_changed(name, value): - print "Modem property %s changed to %s" % (name, value) + print("Modem property %s changed to %s" % (name, value)) if __name__ == "__main__": dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
@@ -25,41 +25,41 @@ if __name__ == "__main__": properties = modem.GetProperties() if properties.has_key('Name'): - print "Name: %s" % (properties['Name']) + print("Name: %s" % (properties['Name'])) if properties.has_key('Manufacturer'): - print "Manufacturer: %s" % (properties['Manufacturer']) + print("Manufacturer: %s" % (properties['Manufacturer'])) if properties.has_key('Model'): - print "Model: %s" % (properties['Model']) + print("Model: %s" % (properties['Model'])) if properties.has_key('Revision'): - print "Revision: %s" % (properties['Revision']) + print("Revision: %s" % (properties['Revision'])) if properties.has_key('Serial'): - print "Serial: %s" % (properties['Serial']) + print("Serial: %s" % (properties['Serial'])) if properties.has_key('Powered'): - print "Powered: %s" % (properties['Powered']) + print("Powered: %s" % (properties['Powered'])) if properties.has_key('Online'): - print "Online: %s" % (properties['Online']) + print("Online: %s" % (properties['Online'])) if properties.has_key('Lockdown'): - print "Lockdown: %s" % (properties['Lockdown']) + print("Lockdown: %s" % (properties['Lockdown'])) if properties.has_key('Emergency'): - print "Emergency: %s" % (properties['Emergency']) + print("Emergency: %s" % (properties['Emergency'])) if properties.has_key('Features'): - print "Features:" + print("Features:") for feature in properties["Features"]: - print " [ %s ]" % (feature) + print(" [ %s ]" % (feature)) if properties.has_key('Interfaces'): - print "Interfaces:" + print("Interfaces:") for interface in properties["Interfaces"]: - print " [ %s ]" % (interface) + print(" [ %s ]" % (interface)) mainloop = gobject.MainLoop() mainloop.run()
test/test-network-registration +12 -12
@@ -6,18 +6,18 @@ import dbus import dbus.mainloop.glib def network_property_changed(name, value): - print "Network Registration property '%s' changed to '%s'" %\ - (name, value) + print("Network Registration property '%s' changed to '%s'" %\ + (name, value)) if name == 'Name' and canexit: mainloop.quit() if __name__ == "__main__": if len(sys.argv) < 2: - print "Usage: %s [modem] <path> - Register to PLMN on <path>" %\ - (sys.argv[0]) - print "Usage: %s [modem] default - Register to default PLMN" %\ - (sys.argv[0]) + print("Usage: %s [modem] <path> - Register to PLMN on <path>" %\ + (sys.argv[0])) + print("Usage: %s [modem] default - Register to default PLMN" %\ + (sys.argv[0])) sys.exit(1) canexit = False
@@ -44,15 +44,15 @@ if __name__ == "__main__": props = netreg.GetProperties() - print "Status is: '%s', Operator Name is: '%s'" %\ - (props['Status'], props['Name']) + print("Status is: '%s', Operator Name is: '%s'" %\ + (props['Status'], props['Name'])) if props.has_key('LocationAreaCode') and props.has_key('CellId'): - print "Location: '%d', Cell: '%d'" %\ - (props['LocationAreaCode'], props['CellId']) + print("Location: '%d', Cell: '%d'" %\ + (props['LocationAreaCode'], props['CellId'])) if props.has_key('Technology'): - print "Technology: '%s'" % (props['Technology']) + print("Technology: '%s'" % (props['Technology'])) try: if plmn == 'default':
@@ -62,7 +62,7 @@ if __name__ == "__main__": op = dbus.Interface(obj, 'org.ofono.NetworkOperator') op.Register() except dbus.DBusException, e: - print "Unable to register: ", e + print("Unable to register: %s" % e) sys.exit(1) canexit = True
test/test-phonebook +1 -1
@@ -20,4 +20,4 @@ if __name__ == "__main__": phonebook = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.Phonebook') - print phonebook.Import(timeout=100) + print(phonebook.Import(timeout=100))
test/test-push-notification +4 -4
@@ -11,16 +11,16 @@ class PushNotificationAgent(dbus.service.Object): @dbus.service.method("org.ofono.PushNotificationAgent", in_signature="", out_signature="") def Release(self): - print "Release" + print("Release") mainloop.quit() @dbus.service.method("org.ofono.PushNotificationAgent", in_signature="aya{sv}", out_signature="") def ReceiveNotification(self, data, props): for key in props.keys(): - print "Key: %s, Value: %s" % (key, props[key]) + print("Key: %s, Value: %s" % (key, props[key])) - print "Received notification of size: %d" % len(data) + print("Received notification of size: %d" % len(data)) if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
@@ -41,7 +41,7 @@ if __name__ == '__main__': path = "/test/agent" agent = PushNotificationAgent(bus, path) pn.RegisterAgent(path) - print "Agent registered" + print("Agent registered") mainloop = gobject.MainLoop()
test/test-smart-messaging +8 -8
@@ -11,34 +11,34 @@ class SmartMessagingAgent(dbus.service.Object): @dbus.service.method("org.ofono.SmartMessagingAgent", in_signature="", out_signature="") def Release(self): - print "Release" + print("Release") mainloop.quit() @dbus.service.method("org.ofono.SmartMessagingAgent", in_signature="aya{sv}", out_signature="") def ReceiveBusinessCard(self, data, props): for key in props.keys(): - print "Key: %s, Value: %s" % (key, props[key]) + print("Key: %s, Value: %s" % (key, props[key])) string = "" for byte in data: string += str(byte) - print "Received Business Card:" - print string + print("Received Business Card:") + print(string) @dbus.service.method("org.ofono.SmartMessagingAgent", in_signature="aya{sv}", out_signature="") def ReceiveAppointment(self, data, props): for key in props.keys(): - print "Key: %s, Value: %s" % (key, props[key]) + print("Key: %s, Value: %s" % (key, props[key])) string = "" for byte in data: string += str(byte) - print "Received Appointment:" - print string + print("Received Appointment:") + print(string) if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
@@ -59,7 +59,7 @@ if __name__ == '__main__': path = "/test/agent" agent = SmartMessagingAgent(bus, path) pn.RegisterAgent(path) - print "Agent registered" + print("Agent registered") mainloop = gobject.MainLoop()
test/test-sms +48 -48
163 lines not on this page · raw message
test/test-ss +8 -8
@@ -23,20 +23,20 @@ ss = dbus.Interface(bus.get_object('org.ofono', modem), try: ss_type, properties = ss.Initiate(ss_code, timeout=100) except dbus.DBusException, e: - print "Unable to perform operation: ", e + print("Unable to perform operation: %s" % e) sys.exit(1); if (ss_type == "CallBarring"): - print "%s : Operation [ %s ] Service Type [ %s ]" % (ss_type, properties[0], properties[1]) + print("%s : Operation [ %s ] Service Type [ %s ]" % (ss_type, properties[0], properties[1])) for key in properties[2]: - print "%s : %s" % (key, properties[2][key]) + print("%s : %s" % (key, properties[2][key])) elif (ss_type == "CallForwarding"): - print "%s : Operation [ %s ] Service Type [ %s ]" % (ss_type, properties[0], properties[1]) + print("%s : Operation [ %s ] Service Type [ %s ]" % (ss_type, properties[0], properties[1])) for key in properties[2]: - print "%s : %s" % (key, properties[2][key]) + print("%s : %s" % (key, properties[2][key])) elif (ss_type == "CallWaiting"): - print "%s : Operation [ %s ]" % (ss_type, properties[0]) + print("%s : Operation [ %s ]" % (ss_type, properties[0])) for key in properties[1]: - print "%s : %s" % (key, properties[1][key]) + print("%s : %s" % (key, properties[1][key])) else: - print "%s : Operation [ %s ] Status [ %s ]" % (ss_type, properties[0], properties[1]) + print("%s : Operation [ %s ] Status [ %s ]" % (ss_type, properties[0], properties[1]))
test/test-ss-control-cb +34 -34
108 lines not on this page · raw message
test/test-ss-control-cf +16 -16
@@ -6,7 +6,7 @@ import dbus import dbus.mainloop.glib def property_changed(property, value): - print "CallForwarding property %s changed to %s" % (property, value) + print("CallForwarding property %s changed to %s" % (property, value)) def print_properties(cf): properties = cf.GetProperties()
@@ -17,7 +17,7 @@ def print_properties(cf): else: value = "disabled" - print "%s call forwarding rule: %s" % (p, value) + print("%s call forwarding rule: %s" % (p, value)) if __name__ == "__main__": dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
@@ -42,33 +42,33 @@ if __name__ == "__main__": print_properties(cf) # Busy To +155542, for Voice - print "Setting Busy Voice rule to +155542" - print ss.Initiate("*67*+155542*11#") + print("Setting Busy Voice rule to +155542") + print(ss.Initiate("*67*+155542*11#")) print_properties(cf) # Not Reachable to +155543, Voice - print "Setting Voice Not Reachable rule to +155543" - print ss.Initiate("**62*+155543*11#") + print("Setting Voice Not Reachable rule to +155543") + print(ss.Initiate("**62*+155543*11#")) # Not Reachable to +155544, Voice service - print "Setting Voice No Reply rule to +155544, timeout=30" - print ss.Initiate("**61*+155544*11*30#") + print("Setting Voice No Reply rule to +155544, timeout=30") + print(ss.Initiate("**61*+155544*11*30#")) # Unconditional to +155547, Voice - print "Setting Unconditional for Voice to +155545" - print ss.Initiate("*21*+155545*10#") + print("Setting Unconditional for Voice to +155545") + print(ss.Initiate("*21*+155545*10#")) print_properties(cf) - print "Query all voice forwardings" - print ss.Initiate("*#002**11#") + print("Query all voice forwardings") + print(ss.Initiate("*#002**11#")) - print "Query no reply voice forwardings" - print ss.Initiate("*#61**11#") + print("Query no reply voice forwardings") + print(ss.Initiate("*#61**11#")) # Deactivate everything - print "Deactivating everything" - print ss.Initiate("##002#") + print("Deactivating everything") + print(ss.Initiate("##002#")) print_properties(cf) mainloop = gobject.MainLoop()
test/test-ss-control-cs +42 -42
135 lines not on this page · raw message
test/test-stk-menu +58 -58
265 lines not on this page · raw message
test/unlock-pin +2 -2
@@ -17,10 +17,10 @@ elif len(sys.argv) == 3: pin_type = sys.argv[1] pin = sys.argv[2] else: - print "%s [PATH] pin_type pin" % (sys.argv[0]) + print("%s [PATH] pin_type pin" % (sys.argv[0])) sys.exit(0) -print "Unlock %s %s for modem %s..." % (pin_type, pin, path) +print("Unlock %s %s for modem %s..." % (pin_type, pin, path)) simmanager = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.SimManager')
Signature · 1 line
1.9.0
From 5e245236a5d73285fd1a160db138375119fd13ee Mon Sep 17 00:00:00 2001
From: Martin Pitt <[email protected]>
Date: Tue, 25 Feb 2014 12:42:52 +0100
Subject: [PATCH 2/5] test: Make exception catching compatible with Python 3
Use "except Type as var" syntax to work with both Python >= 2.6 and Python 3.
--- test/activate-context | 2 +- test/deactivate-context | 2 +- test/disable-call-forwarding | 2 +- test/set-call-forwarding | 4 ++-- test/set-context-property | 2 +- test/test-advice-of-charge | 4 ++-- test/test-call-barring | 6 +++--- test/test-call-forwarding | 26 +++++++++++++------------- test/test-call-settings | 2 +- test/test-cbs | 2 +- test/test-gnss | 6 +++--- test/test-network-registration | 2 +- test/test-sms | 6 +++--- test/test-ss | 2 +- test/test-ss-control-cb | 8 ++++---- test/test-ss-control-cs | 12 ++++++------ test/test-stk-menu | 2 +- 17 files changed, 45 insertions(+), 45 deletions(-)
test/activate-context +1 -1
@@ -35,6 +35,6 @@ for path, properties in modems: try: context.SetProperty("Active", dbus.Boolean(1), timeout = 100) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Error activating %s: %s" % (path, str(e))) exit(2)
test/deactivate-context +1 -1
@@ -33,6 +33,6 @@ for path, properties in modems: try: context.SetProperty("Active", dbus.Boolean(0)) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Error activating %s: %s" % (path, str(e))) exit(2)
test/disable-call-forwarding +1 -1
@@ -41,7 +41,7 @@ if __name__ == "__main__": try: cf.DisableAll(type, timeout = 100) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to DisableAll %s" % e) sys.exit(1);
test/set-call-forwarding +2 -2
@@ -46,13 +46,13 @@ if __name__ == "__main__": try: cf.SetProperty(property, dbus.UInt16(value), timeout = 100) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable SetProperty %s" % e) sys.exit(1); else: try: cf.SetProperty(property, value, timeout = 100) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable SetProperty %s" % e) sys.exit(1);
test/set-context-property +1 -1
@@ -33,7 +33,7 @@ for path, properties in modems: try: context.SetProperty(sys.argv[2], sys.argv[3]) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Error setting context %s property %s: %s" %\ (path, sys.argv[2], str(e))) exit(2)
test/test-advice-of-charge +2 -2
@@ -67,7 +67,7 @@ if __name__ == "__main__": print("Resetting Accumulated Call Meter") try: cm.Reset(pin) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to reset ACM: %s" % e) sys.exit(1) else:
@@ -77,7 +77,7 @@ if __name__ == "__main__": elif property == 'PricePerUnit': newvalue = float(newvalue) cm.SetProperty(property, newvalue, pin) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to set property: %s" % e) sys.exit(1)
test/test-call-barring +3 -3
@@ -60,13 +60,13 @@ if __name__ == "__main__": print("Disabling all barrings") try: cb.DisableAll(pin) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to Disable All barrings: ", e) sys.exit(1) elif (sys.argv[1] == 'passwd'): try: cb.ChangePassword(old_password, new_password) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to change password: ", e) sys.exit(1) print("Password changed")
@@ -74,7 +74,7 @@ if __name__ == "__main__": else: try: cb.SetProperty(property, newvalue, pin) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to set property: ", e) sys.exit(1)
test/test-call-forwarding +13 -13
@@ -36,47 +36,47 @@ if __name__ == "__main__": try: cf.SetProperty("FoobarNoReplyTimeout", dbus.UInt16(19)) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to set timeout - Good") try: cf.SetProperty("VoiceNotReachableTimeout", dbus.UInt16(19)) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to set timeout - Good") try: cf.SetProperty("VoiceNoReplyTimeout", dbus.UInt16(19)) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to set timeout - Good") try: cf.SetProperty("DataNoReplyTimeout", dbus.UInt16(19)) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to set timeout - Good") try: cf.SetProperty("FaxNoReplyTimeout", dbus.UInt16(19)) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to set timeout - Good") try: cf.SetProperty("SmsNoReplyTimeout", dbus.UInt16(19)) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to set timeout - Good") try: cf.SetProperty("VoiceNoReply", "") - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to erase voice no reply rule - Bad") try: cf.SetProperty("VoiceNoReply", "+134444") - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to register voice no reply rule - Bad") try: cf.SetProperty("VoiceNoReplyTimeout", dbus.UInt16(30)) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to set voice no reply timeout - Bad") properties = cf.GetProperties()
@@ -86,7 +86,7 @@ if __name__ == "__main__": try: cf.SetProperty("VoiceUnconditional", "+155555") - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to set Voice Unconditional - Bad") properties = cf.GetProperties()
@@ -95,12 +95,12 @@ if __name__ == "__main__": try: cf.DisableAll("foobar") - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to delete invalids - Good") try: cf.DisableAll("conditional") - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to delete all conditional - Bad") properties = cf.GetProperties()
@@ -110,7 +110,7 @@ if __name__ == "__main__": try: cf.DisableAll("all") - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to delete all conditional - Bad") print(properties["VoiceUnconditional"])
test/test-call-settings +1 -1
@@ -67,7 +67,7 @@ if __name__ == "__main__": try: cs.SetProperty(property, newvalue) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to set property: %s" % e) sys.exit(1);
test/test-cbs +1 -1
@@ -103,7 +103,7 @@ def set_topics(cbs): try: print("Setting Cell Broadcast topics...") cbs.SetProperty("Topics", topics); - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to set topic: %s" % e) print("-----------------------------------------------------------")
test/test-gnss +3 -3
@@ -44,21 +44,21 @@ def stdin_handler(fd, condition, gnss, path): try: gnss.SendPositioningElement(dbus.String(xml)) print("ok") - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to send positioning element") elif in_key == '1': try: gnss.RegisterPositioningRequestAgent("/test/posagent") print("ok") - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to register positioning agent") elif in_key == '2': try: gnss.UnregisterPositioningRequestAgent(path) print("ok") - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to unregister positioning agent") elif in_key == 'x': sys.exit(1)
test/test-network-registration +1 -1
@@ -61,7 +61,7 @@ if __name__ == "__main__": obj = bus.get_object('org.ofono', plmn); op = dbus.Interface(obj, 'org.ofono.NetworkOperator') op.Register() - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to register: %s" % e) sys.exit(1)
test/test-sms +3 -3
@@ -48,7 +48,7 @@ def message_delivery_report(sms, value): try: sms.SetProperty("UseDeliveryReports", dbus.Boolean(value)) - except dbus.DBusException, e: + except dbus.DBusException as e: if value == 1: print("Unable to activate Delivery Reports - FAIL")
@@ -58,13 +58,13 @@ def message_delivery_report(sms, value): def message_service_center_address(sms, value): try: sms.SetProperty("ServiceCenterAddress",dbus.String(value)) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to set correct Service Center Address - FAIL") def message_bearer(sms, value): try: sms.SetProperty("Bearer", dbus.String(value)) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Unable to set Bearer[%s] - FAIL" % (value))
test/test-ss +1 -1
@@ -22,7 +22,7 @@ ss = dbus.Interface(bus.get_object('org.ofono', modem), try: ss_type, properties = ss.Initiate(ss_code, timeout=100) -except dbus.DBusException, e: +except dbus.DBusException as e: print("Unable to perform operation: %s" % e) sys.exit(1);
test/test-ss-control-cb +4 -4
@@ -37,25 +37,25 @@ if __name__ == "__main__": print("Trying invalid SS request for CB") try: print(ss.Initiate("*33#456666")) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Failed with %s - Good" % e) print("Trying invalid SS request for CB") try: print(ss.Initiate("*33*ABC#")) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Failed with %s - Good" % e) print("Trying invalid SS request for CB") try: print(ss.Initiate("*33**ABC#")) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Failed with %s - Good" % e) print("Trying invalid SS request for CB") try: print(ss.Initiate("*33***12#")) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Failed with %s - Good" % e) print("Query Outgoing All")
test/test-ss-control-cs +6 -6
@@ -37,19 +37,19 @@ if __name__ == "__main__": print("Trying invalid SS request for CLIR") try: print(ss.Initiate("*31#456666")) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Failed with %s - Good" % e) print("Trying invalid SS request for CLIR") try: print(ss.Initiate("*31*455*4#")) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Failed with %s - Good" % e) print("Trying invalid SS request for CLIR") try: print(ss.Initiate("*31**44435#")) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Failed with %s - Good" % e) print("Query CLIP")
@@ -77,19 +77,19 @@ if __name__ == "__main__": print("Trying invalid SS request for CW") try: print(ss.Initiate("*43#456666")) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Failed with %s - Good" % e) print("Trying invalid SS request for CW") try: print(ss.Initiate("*43*455*4#")) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Failed with %s - Good" % e) print("Trying invalid SS request for CW") try: print(ss.Initiate("*43**44435#")) - except dbus.DBusException, e: + except dbus.DBusException as e: print("Failed with %s - Good" % e) print("Query CW")
test/test-stk-menu +1 -1
@@ -238,7 +238,7 @@ class StkAgent(dbus.service.Object): if key == 't': raise EndSession("User wishes to terminate" " session") - except Exception, exc: + except Exception as exc: print(exc) @dbus.service.method("org.ofono.SimToolkitAgent",
Signature · 1 line
1.9.0
From 71dee186db5c9bd6eee421bdfa489869f2999cb4 Mon Sep 17 00:00:00 2001
From: Martin Pitt <[email protected]>
Date: Tue, 25 Feb 2014 13:03:28 +0100
Subject: [PATCH 3/5] test: Replace obsolete has_key() with "in" to also work
with Python 3
--- test/test-modem | 22 +++++++++++----------- test/test-network-registration | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-)
test/test-modem +11 -11
@@ -24,39 +24,39 @@ if __name__ == "__main__": properties = modem.GetProperties() - if properties.has_key('Name'): + if 'Name' in properties: print("Name: %s" % (properties['Name'])) - if properties.has_key('Manufacturer'): + if 'Manufacturer' in properties: print("Manufacturer: %s" % (properties['Manufacturer'])) - if properties.has_key('Model'): + if 'Model' in properties: print("Model: %s" % (properties['Model'])) - if properties.has_key('Revision'): + if 'Revision' in properties: print("Revision: %s" % (properties['Revision'])) - if properties.has_key('Serial'): + if 'Serial' in properties: print("Serial: %s" % (properties['Serial']))
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.9.0
From d27aee1bacdbcec06dbc8bc4c9fadbede06588e6 Mon Sep 17 00:00:00 2001
From: Martin Pitt <[email protected]>
Date: Tue, 25 Feb 2014 13:16:31 +0100
Subject: [PATCH 4/5] test: Move from static gobject bindings to GI
Use GLib gobject-introspection bindings so that we can also use the scripts with Python 3.
--- test/disable-call-forwarding | 4 ++-- test/monitor-dundee | 4 ++-- test/monitor-ofono | 4 ++-- test/receive-sms | 4 ++-- test/set-call-forwarding | 4 ++-- test/test-advice-of-charge | 4 ++-- test/test-call-barring | 4 ++-- test/test-call-forwarding | 4 ++-- test/test-call-settings | 4 ++-- test/test-cbs | 13 +++++++------ test/test-gnss | 13 +++++++------ test/test-message-waiting | 4 ++-- test/test-modem | 4 ++-- test/test-network-registration | 4 ++-- test/test-push-notification | 4 ++-- test/test-smart-messaging | 4 ++-- test/test-sms | 13 +++++++------ test/test-ss-control-cb | 4 ++-- test/test-ss-control-cf | 4 ++-- test/test-ss-control-cs | 4 ++-- test/test-stk-menu | 10 +++++----- 21 files changed, 60 insertions(+), 57 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.9.0
From 75f01374251fd49f160a26e85deff0808fefb4f8 Mon Sep 17 00:00:00 2001
From: Martin Pitt <[email protected]>
Date: Tue, 25 Feb 2014 13:18:38 +0100
Subject: [PATCH 5/5] test: Convert to Python 3
Change raw_input() to input() and unicode to str. This is *not* compatible with Python 2. Update the hashbangs to run with Python 3.
--- test/activate-context | 2 +- test/answer-calls | 2 +- test/backtrace | 2 +- test/cancel-ussd | 2 +- test/cdma-connman-disable | 2 +- test/cdma-connman-enable | 2 +- test/cdma-dial-number | 2 +- test/cdma-hangup | 2 +- test/cdma-list-call | 2 +- test/cdma-set-credentials | 2 +- test/change-pin | 2 +- test/create-internet-context | 2 +- test/create-mms-context | 2 +- test/create-multiparty | 2 +- test/deactivate-all | 2 +- test/deactivate-context | 2 +- test/dial-number | 2 +- test/disable-call-forwarding | 2 +- test/disable-gprs | 2 +- test/disable-modem | 2 +- test/display-icon | 2 +- test/dundee-connect | 2 +- test/dundee-disconnect | 2 +- test/enable-cbs | 2 +- test/enable-gprs | 2 +- test/enable-modem | 2 +- test/enter-pin | 2 +- test/get-icon | 2 +- test/get-operators | 2 +- test/get-tech-preference | 2 +- test/hangup-active | 2 +- test/hangup-all | 2 +- test/hangup-call | 2 +- test/hangup-multiparty | 2 +- test/hold-and-answer | 2 +- test/initiate-ussd | 4 ++-- test/list-calls | 2 +- test/list-contexts | 2 +- test/list-messages | 2 +- test/list-modems | 2 +- test/list-operators | 2 +- test/lock-pin | 2 +- test/lockdown-modem | 2 +- test/monitor-dundee | 4 ++-- test/monitor-ofono | 4 ++-- test/offline-modem | 2 +- test/online-modem | 2 +- test/private-chat | 2 +- test/process-context-settings | 2 +- test/receive-sms | 2 +- test/reject-calls | 2 +- test/release-and-answer | 2 +- test/release-and-swap | 2 +- test/remove-contexts | 2 +- test/reset-pin | 2 +- test/scan-for-operators | 2 +- test/send-sms | 2 +- test/send-ussd | 4 ++-- test/send-vcal | 2 +- test/send-vcard | 2 +- test/set-call-forwarding | 2 +- test/set-cbs-topics | 2 +- test/set-context-property | 2 +- test/set-fast-dormancy | 2 +- test/set-gsm-band | 2 +- test/set-mic-volume | 2 +- test/set-mms-details | 2 +- test/set-msisdn | 2 +- test/set-roaming-allowed | 2 +- test/set-speaker-volume | 2 +- test/set-tech-preference | 2 +- test/set-tty | 2 +- test/set-umts-band | 2 +- test/set-use-sms-reports | 2 +- test/swap-calls | 2 +- test/test-advice-of-charge | 2 +- test/test-call-barring | 2 +- test/test-call-forwarding | 2 +- test/test-call-settings | 2 +- test/test-cbs | 4 ++-- test/test-gnss | 4 ++-- test/test-message-waiting | 2 +- test/test-modem | 2 +- test/test-network-registration | 2 +- test/test-phonebook | 2 +- test/test-push-notification | 2 +- test/test-smart-messaging | 2 +- test/test-sms | 18 +++++++++--------- test/test-ss | 2 +- test/test-ss-control-cb | 2 +- test/test-ss-control-cf | 2 +- test/test-ss-control-cs | 2 +- test/test-stk-menu | 34 +++++++++++++++++----------------- test/unlock-pin | 2 +- 94 files changed, 124 insertions(+), 124 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.9.0
Part of the diff is not shown here. View the raw message.
Hi Martin,
Quoted 7 lines · Martin Pitt
Hello ofono developers,
I already sent this last week, but apparently it never got moderated. I (temporarily) subscribed now [1].
We are in the process of eliminating Python 2 from our images, and thus I ported the ofono test scripts to Python 3.
Could you submit these patches using git-send-email? It would be way easier for me to reply with my comments.
Quoted 5 lines
The first three patches keep the current behaviour and just make the scripts bilingual, i. e. they will work with both Python >= 2.6 and Python 3. They are rather big, but mostly mechanical (2to3 with some overzealous bits removed, and cleaning up some print statements).
I looked at these and I'm fine with the first 3, however there are some little gotchas that you need to fix.
For example,
Python 2.7.5 (default, Aug 26 2013, 23:31:36)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Quoted 1 line
Quoted 1 line
Quoted 1 line
print()
()
Quoted 1 line
Quoted 1 line
Quoted 1 line
This is probably not what you intended.
Patches 2 and 3 seem to be just fine. Couldn't apply because they depend on patch 1.
Quoted 4 lines
Patch 4 moves the scripts from the ancient and long-unmaintained static gobject bindings to gobject-introspection. That's available for both python 2 and 3.
This seems fine with me as well. If there are no objections I am okay applying it.
Quoted 10 lines
Patch 5 does the remaining bits (unicode and
raw_input, and updating hashbangs) and is currently *not* bilingual. If you want these scripts to only work with Python 3 (which should be fine these days), it can be applied (we already did that in the ofono-rilmodem branch[2]). Otherwise, if you generally agree to doing this conversion I'm happy to change it to a form where it works with both Python versions. But that's more involved and it's work that I would only do after getting your "yes, we'll take it" confirmation. :-)
I'm okay moving to Python 3, but you might want to send this as an RFC to garner more feedback.
Regards,
-Denis
Hey Denis,
Denis Kenzior [2014-03-11 10:33 -0500]:
Quoted 2 lines
Could you submit these patches using git-send-email? It would be way easier for me to reply with my comments.
Done now. First time I use it, I hope I didn't mess up anything.
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
print()()
Quoted 1 line
Quoted 1 line
Quoted 1 line
This is probably not what you intended.
Indeed not, thanks for spotting. Changed to print('') now, which does the same (and the right thing) with both Python 2 and 3. The new git-send-email'ed patch already has this.
Quoted 2 lines
Patches 2 and 3 seem to be just fine. Couldn't apply because they depend on patch 1.
Yes, unfortunately they are quite intrusive :/
Quoted 10 lines
Quoted 9 lines
Patch 5 does the remaining bits (unicode and
raw_input, and updating hashbangs) and is currently *not* bilingual. If you want these scripts to only work with Python 3 (which should be fine these days), it can be applied (we already did that in the ofono-rilmodem branch[2]). Otherwise, if you generally agree to doing this conversion I'm happy to change it to a form where it works with both Python versions. But that's more involved and it's work that I would only do after getting your "yes, we'll take it" confirmation. :-)
Quoted 2 lines
I'm okay moving to Python 3, but you might want to send this as an RFC to garner more feedback.
That patch is a lot smaller, so it can be applied independently of the other four. What you mean with "send as RFC" other than sending it to the ML for review?
Thanks,
Martin
Signature · 2 lines
Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
Hi Martin,
Quoted 6 lines
Quoted 2 lines
I'm okay moving to Python 3, but you might want to send this as an RFC to garner more feedback.
That patch is a lot smaller, so it can be applied independently of the other four. What you mean with "send as RFC" other than sending it to the ML for review?
Just means to preceed that patch title with 'RFC:' But no worries, we'll figure it out.
Regards,
-Denis