test: Move from static gobject bindings to GI
authorMartin Pitt <martin.pitt@ubuntu.com>
Tue, 11 Mar 2014 16:39:21 +0000 (17:39 +0100)
committerDenis Kenzior <denkenz@gmail.com>
Wed, 12 Mar 2014 00:33:16 +0000 (19:33 -0500)
Use GLib gobject-introspection bindings so that we can also use the
scripts with Python 3.

21 files changed:
test/disable-call-forwarding
test/monitor-dundee
test/monitor-ofono
test/receive-sms
test/set-call-forwarding
test/test-advice-of-charge
test/test-call-barring
test/test-call-forwarding
test/test-call-settings
test/test-cbs
test/test-gnss
test/test-message-waiting
test/test-modem
test/test-network-registration
test/test-push-notification
test/test-smart-messaging
test/test-sms
test/test-ss-control-cb
test/test-ss-control-cf
test/test-ss-control-cs
test/test-stk-menu

index 1e6ec208d7acb6aa5d6924aa8226b14895a8a86e..36098162440de342ebc14dcc9621fa268338a7ea 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 
 import sys
-import gobject
+from gi.repository import GLib
 
 import dbus
 import dbus.mainloop.glib
@@ -49,5 +49,5 @@ if __name__ == "__main__":
 
        canexit = True
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()
index 025a3456257507074788a10efa39a67516823c66..e68488aa73a5684e5610b282355fe4df8f5f5edc 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 
 import dbus
 import dbus.mainloop.glib
@@ -105,5 +105,5 @@ if __name__ == '__main__':
                                                interface_keyword="interface")
 
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()
index f69ae79aaaf9a279e1e688b1884b84aba31797da..bd3161715809a7984825396535afe4a6c8ba7ce7 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 
 import dbus
 import dbus.mainloop.glib
@@ -150,5 +150,5 @@ if __name__ == '__main__':
                                        path_keyword="path",
                                        interface_keyword="interface")
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()
index b40ce3c128c7e7231f34ee9adc13be82515e5a53..c23eb1460aa7de5f0e63723c0b8c20893c362dbd 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 
 import dbus
 import dbus.mainloop.glib
@@ -29,5 +29,5 @@ if __name__ == '__main__':
                                                path_keyword="path",
                                                interface_keyword="interface")
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()
index 8f0722ed731e1d1ecb20c56fc6d287f693f67be8..9fd358be1452f34fe8706cef8413d1613973cea7 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 
 import sys
-import gobject
+from gi.repository import GLib
 
 import dbus
 import dbus.mainloop.glib
@@ -60,5 +60,5 @@ if __name__ == "__main__":
 
        canexit = True
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()
index 6fa3a7c49bc3c0822b7b1d02f27bd0e3c78ccfd6..0f1f57ff7436c8cd1a023b1d1e8461d3709c84fd 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 import sys
 import dbus
 import dbus.mainloop.glib
@@ -83,5 +83,5 @@ if __name__ == "__main__":
 
        canexit = True
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()
index bc11de0f4c6b7b7fa730bcd81d871fee476a7c99..be4ab575505e8c87be87135305ea211ae865a978 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 import sys
 import dbus
 import dbus.mainloop.glib
@@ -80,5 +80,5 @@ if __name__ == "__main__":
 
        canexit = True
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()
index a7ec1e4b036e7ba081cc27634a97fdc554787802..01a7294174e233a18cfcc39c46d3a034fc13b6f0 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 
 import dbus
 import dbus.mainloop.glib
@@ -115,5 +115,5 @@ if __name__ == "__main__":
 
        print(properties["VoiceUnconditional"])
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()
index 187ce06e6773b265054eccde4d900c0e7d6a0b58..5d7ee49e6d7d1d6dd8fc8022cf1ef9d7db3f6744 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 
 import dbus
 import dbus.mainloop.glib
@@ -79,5 +79,5 @@ if __name__ == "__main__":
 
        canexit = True
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()
index 8d8438f84440fc63ccd75cc0e2ed6c911644d6be..13cdd80a51642633889a201b299a54209c47024c 100755 (executable)
@@ -3,7 +3,7 @@
 import dbus
 import dbus.mainloop.glib
 import sys
-import gobject
+from gi.repository import GLib
 import os
 
 def print_menu():
@@ -127,8 +127,8 @@ def get_serving_cell_name(netReg):
                        \nBase Station CBS not available.")
        print("-----------------------------------------------------------")
 
-def stdin_handler(fd, condition, cbs, netReg):
-       in_key = os.read(fd.fileno(), 160).rstrip()
+def stdin_handler(channel, condition, cbs, netReg):
+       in_key = os.read(channel.unix_get_fd(), 160).rstrip().decode('UTF-8')
 
        if in_key == '0':
                set_cbs_state(cbs, True)
@@ -181,8 +181,9 @@ if __name__ == "__main__":
 
        print_menu()
 
-       gobject.io_add_watch(sys.stdin, gobject.IO_IN, stdin_handler, cbs, \
-                               netReg)
+       GLib.io_add_watch(GLib.IOChannel(filedes=sys.stdin.fileno()),
+                  GLib.PRIORITY_DEFAULT, GLib.IO_IN, stdin_handler, cbs, \
+                  netReg)
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()
index 62b56f912cb8e2f2d13790b7e1f0027089ae0430..aa0b160cd5c8450841e90bff1d62ea5454feeb47 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 import sys
 import os
 
@@ -37,8 +37,8 @@ def print_menu():
        print("[x] Exit")
        print("-----------------------------------------------------------")
 
-def stdin_handler(fd, condition, gnss, path):
-       in_key = os.read(fd.fileno(), 8).rstrip()
+def stdin_handler(channel, condition, gnss, path):
+       in_key = os.read(channel.unix_get_fd(), 160).rstrip().decode('UTF-8')
        if in_key == '0':
                xml = raw_input('type the element and press enter: ')
                try:
@@ -87,7 +87,8 @@ if __name__ == "__main__":
 
        print_menu()
 
-       gobject.io_add_watch(sys.stdin, gobject.IO_IN, stdin_handler,
-                               gnss, path)
-       mainloop = gobject.MainLoop()
+       GLib.io_add_watch(GLib.IOChannel(filedes=sys.stdin.fileno()),
+                  GLib.PRIORITY_DEFAULT, GLib.IO_IN, stdin_handler,
+                  gnss, path)
+       mainloop = GLib.MainLoop()
        mainloop.run()
index b737ee4ac19e2db7e77ae9fabacd743969a10e9c..b93fbf396a94b924bbece71488055067ca7a4535 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 import sys
 import dbus
 import dbus.mainloop.glib
@@ -36,5 +36,5 @@ if __name__ == "__main__":
        print("Voicemail mailbox number: %s" %\
                (properties['VoicemailMailboxNumber']))
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()
index 76810946a631f767791af1b88d7a8081dd857aa6..29dbf14af27faced38339fc77345075c2371d4f5 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 
 import dbus
 import dbus.mainloop.glib
@@ -61,5 +61,5 @@ if __name__ == "__main__":
                for interface in properties["Interfaces"]:
                        print("    [ %s ]" % (interface))
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()
index 9410ae6e442f963f274297afed00bd44e7b49a3b..c5ad5864462206a3ae000d6542ae710be932d2e4 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 import sys
 import dbus
 import dbus.mainloop.glib
@@ -67,5 +67,5 @@ if __name__ == "__main__":
 
        canexit = True
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()
index d05ec35c928bf42714d965730cf47e986df85b87..ecc6afbf745c2cee2fd4f46cb9fc0c78c26fecdd 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 
 import sys
 import dbus
@@ -43,7 +43,7 @@ if __name__ == '__main__':
        pn.RegisterAgent(path)
        print("Agent registered")
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
 
        try:
                mainloop.run()
index 6d5d44b1ca2e2be740145d61ad0eec94860b5ae7..188ac1eea535a50aef6ad007c1bc4e9feaa11d5e 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 
 import sys
 import dbus
@@ -61,7 +61,7 @@ if __name__ == '__main__':
        pn.RegisterAgent(path)
        print("Agent registered")
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
 
        try:
                mainloop.run()
index 33d4ccde682349892309dafea40922d9f2994adb..49935e11c3171f41f727a75a5e7661de7c7e8e44 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
 
-import gobject
+from gi.repository import GLib
 import sys
 import os
 
@@ -124,9 +124,9 @@ def print_sms_properties(sms):
                else:
                        print("%s Message Manager rule disabled" % (p))
 
-def stdin_handler(fd, condition, sms, value, number):
+def stdin_handler(channel, condition, sms, value, number):
        global lock
-       in_key = os.read(fd.fileno(), 160).rstrip()
+       in_key = os.read(channel.unix_get_fd(), 160).rstrip().decode('UTF-8')
 
        if lock == "off":
                lock = "on"
@@ -241,7 +241,8 @@ if __name__ == "__main__":
        print_sms_properties(sms)
        print_menu()
 
-       gobject.io_add_watch(sys.stdin, gobject.IO_IN, stdin_handler,
-                               sms, value, number)
-       mainloop = gobject.MainLoop()
+       GLib.io_add_watch(GLib.IOChannel(filedes=sys.stdin.fileno()),
+                  GLib.PRIORITY_DEFAULT, GLib.IOCondition.IN, stdin_handler,
+                  sms, value, number)
+       mainloop = GLib.MainLoop()
        mainloop.run()
index d972097a1d4a6e0eae7f4454c4fad9db6511702d..86bac9b05c6fccdbc37ab6f2d8f42b753d7e4c84 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 
 import dbus
 import dbus.mainloop.glib
@@ -90,6 +90,6 @@ if __name__ == "__main__":
        print("Disable All Barrings")
        print(ss.Initiate("#330*3579#"))
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()
 
index 1ba95127351409ca72ba55ffd98900d813511df7..d30bf4f8792497f48c47dfe092458dc47f2a1c50 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 
 import dbus
 import dbus.mainloop.glib
@@ -71,5 +71,5 @@ if __name__ == "__main__":
        print(ss.Initiate("##002#"))
        print_properties(cf)
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()
index 2d5442f82c010a51751299c4c6a36719fe2a8138..e0ed1d1aea80f6f8664393b9a0f1064d8969482e 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 
 import dbus
 import dbus.mainloop.glib
@@ -111,6 +111,6 @@ if __name__ == "__main__":
 
        print_properties(cs)
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()
 
index 7952abde68966a57e4c737d6cbc1ad62d3eab6d9..e76f292211d883c354e7c99a0d306f0bbcc98054 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import gobject
+from gi.repository import GLib
 
 import sys
 import dbus
@@ -36,7 +36,7 @@ class StkAgent(dbus.service.Object):
        def call_added(self, path, properties):
                print("call added %s" % (path))
                if (self.timeout_id > 0):
-                       gobject.source_remove(self.timeout_id)
+                       GLib.source_remove(self.timeout_id)
                        self.timeout_callback()
 
        @dbus.service.method("org.ofono.SimToolkitAgent",
@@ -94,7 +94,7 @@ class StkAgent(dbus.service.Object):
                        print("Waiting for %d seconds" % (seconds))
 
                self.timeout_reply_handler = reply_func
-               self.timeout_id = gobject.timeout_add_seconds(seconds,
+               self.timeout_id = GLib.timeout_add_seconds(seconds,
                                                        self.timeout_callback)
 
        @dbus.service.method("org.ofono.SimToolkitAgent",
@@ -264,7 +264,7 @@ class StkAgent(dbus.service.Object):
                        print("Waiting for %d seconds" % (seconds))
 
                self.timeout_reply_handler = reply_func
-               self.timeout_id = gobject.timeout_add_seconds(seconds,
+               self.timeout_id = GLib.timeout_add_seconds(seconds,
                                                        self.timeout_callback)
 
        @dbus.service.method("org.ofono.SimToolkitAgent",
@@ -413,5 +413,5 @@ if __name__ == '__main__':
                print("%s [menu|agent]" % (sys.argv[0]))
                exit(0)
 
-       mainloop = gobject.MainLoop()
+       mainloop = GLib.MainLoop()
        mainloop.run()