port to python3
authorHelmut Grohne <helmut@subdivi.de>
Sun, 16 Jun 2013 13:33:01 +0000 (15:33 +0200)
committerHelmut Grohne <helmut@subdivi.de>
Sun, 16 Jun 2013 13:33:01 +0000 (15:33 +0200)
dbus_client.py
dbus_service.py

index a1f1041..1ad846f 100755 (executable)
@@ -6,12 +6,12 @@ import sys
 
 import dbus
 from dbus.mainloop.glib import DBusGMainLoop
 
 import dbus
 from dbus.mainloop.glib import DBusGMainLoop
-import gobject
+from gi.repository import GObject
 
 from onoff.common import ST_ACTIVE
 
 def wait_for_signal(proxy, signal):
 
 from onoff.common import ST_ACTIVE
 
 def wait_for_signal(proxy, signal):
-    loop = gobject.MainLoop()
+    loop = GObject.MainLoop()
     state = []
     def callback(st):
         state.append(st)
     state = []
     def callback(st):
         state.append(st)
index 7fbdf29..48a42b3 100755 (executable)
@@ -5,7 +5,7 @@ import os
 import dbus
 import dbus.service
 from dbus.mainloop.glib import DBusGMainLoop
 import dbus
 import dbus.service
 from dbus.mainloop.glib import DBusGMainLoop
-import gobject
+from gi.repository import GObject
 
 from onoff.common import ST_ACTIVE, ST_TRANSITION
 
 
 from onoff.common import ST_ACTIVE, ST_TRANSITION
 
@@ -28,13 +28,13 @@ class OnoffControl(dbus.service.Object):
     def activatetime(self, duration):
         print("called with duration %d" % duration)
         self.usecount += 1
     def activatetime(self, duration):
         print("called with duration %d" % duration)
         self.usecount += 1
-        gobject.timeout_add(duration * 1000, self.unuse)
+        GObject.timeout_add(duration * 1000, self.unuse)
         if self.usecount > 1:
             return self.curstate
         self.state(ST_TRANSITION)
         def finish():
             self.state(ST_ACTIVE)
         if self.usecount > 1:
             return self.curstate
         self.state(ST_TRANSITION)
         def finish():
             self.state(ST_ACTIVE)
-        gobject.timeout_add(200, finish)
+        GObject.timeout_add(200, finish)
         return self.curstate
 
     @dbus.service.method(domain, in_signature="hq", out_signature="q")
         return self.curstate
 
     @dbus.service.method(domain, in_signature="hq", out_signature="q")
@@ -45,9 +45,9 @@ class OnoffControl(dbus.service.Object):
         def callback(fd, _):
             print("fd %d completed" % fd)
             os.close(fd)
         def callback(fd, _):
             print("fd %d completed" % fd)
             os.close(fd)
-            gobject.timeout_add(duration * 1000, self.unuse)
+            GObject.timeout_add(duration * 1000, self.unuse)
             return False
             return False
-        gobject.io_add_watch(fd, gobject.IO_HUP|gobject.IO_ERR, callback)
+        GObject.io_add_watch(fd, GObject.IO_HUP|GObject.IO_ERR, callback)
         self.state(ST_ACTIVE)
         return self.curstate
 
         self.state(ST_ACTIVE)
         return self.curstate
 
@@ -64,7 +64,7 @@ def main():
     DBusGMainLoop(set_as_default=True)
     bus = dbus.SessionBus()
     OnoffControl(bus, 5)
     DBusGMainLoop(set_as_default=True)
     bus = dbus.SessionBus()
     OnoffControl(bus, 5)
-    gobject.MainLoop().run()
+    GObject.MainLoop().run()
 
 if __name__ == "__main__":
     main()
 
 if __name__ == "__main__":
     main()