attempt to fix for python3
authorHelmut Grohne <helmut@subdivi.de>
Sun, 16 Jun 2013 22:39:07 +0000 (00:39 +0200)
committerHelmut Grohne <helmut@subdivi.de>
Sun, 16 Jun 2013 22:39:07 +0000 (00:39 +0200)
 * Wrong way to invoke logging.
 * spawn_async returns pid as 0. Bug in library?

dbus_service.py
onoff/process.py

index bbc652c..a35936c 100755 (executable)
@@ -41,7 +41,7 @@ class OnoffControl(dbus.service.Object):
     @dbus.service.method(domain, in_signature="hq", out_signature="q")
     def activatefd(self, fd, duration):
         fd = fd.take()
-        logger.info("activatefd fd %d, duration %d", (fd, duration))
+        logger.info("activatefd fd %d, duration %d", fd, duration)
         def callback(fd, _):
             logger.info("fd %d completed", fd)
             os.close(fd)
index 5dd39c0..d380d29 100644 (file)
@@ -27,6 +27,7 @@ class OnoffProcess(OnoffDevice):
         self.state = ST_ACTIVE|ST_TRANSITION
         ret = GObject.spawn_async(self.command, flags=GObject.SPAWN_SEARCH_PATH | GObject.SPAWN_DO_NOT_REAP_CHILD)
         self.pid = ret[0]
+        assert self.pid
         logger.debug("started as pid %d", self.pid)
         self.watch = GObject.child_watch_add(self.pid, self.process_died)
         self.starting = GObject.timeout_add(1000 * self.start_wait,
@@ -53,6 +54,7 @@ class OnoffProcess(OnoffDevice):
 
     def stop_process(self):
         assert self.state & ST_ACTIVE
+        assert self.pid is not None
         if self.state & ST_TRANSITION:
             logger.debug("cancelling start notification")
             assert self.starting is not None