Commits

Anonymous committed 9c1b39d

now cleanly pipe the output do os.devnull.

  • Participants
  • Parent commits e4ae22a

Comments (0)

Files changed (1)

 import subprocess
 
 # basics, currently only for prefix
-import sys
+import sys, os
 # For circles
 from math import sin, cos, pi
 # and parsing a command string into words for Popen
         # resize
         self.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
 
+        # add a devnull file to send process output.
+        self.devnull = open(os.devnull, "wb")
+
         # Add a circle-list for all items
         self.circle = []
 
         # print self.showAction.shapeGesture().toString()
         self.showAction.connect(self.showAction, SIGNAL("triggered(Qt::MouseButtons, Qt::KeyboardModifiers)"), self.showByShortcut)
 
-        # track subprocesses. Communicate with them from time to time
-        # and kill the dead ones.
-        self.processes = set()
-
         # Setup the circle - TODO: Call it via KUniqueApplication.newInstance
         #self.setup()
 
         # and the circle stays visible.
         if label.action is not None:
             try:
-                self.processes.add(
-                    subprocess.Popen(split_action(label.action), 
-                                     bufsize=-1, # -1 == OS gives the bufsize
-                                     stdout=subprocess.PIPE, 
-                                     stderr=subprocess.STDOUT))
-                # if it works, check all other processes
+                subprocess.Popen(split_action(label.action), 
+                                 stdout=self.devnull, 
+                                 stderr=self.devnull)
                 self.checkProcesses()
                 return True
             except:
                 return None
 
-    def checkProcesses(self):
-        """Check all subprocesses, if they are still active and throw
-        away their output in that case."""
-        for p in self.processes.copy():
-            # check if the process is still alive (==no return value)
-            if p.poll() is not None:
-                self.processes.remove(p)
-
     def isInside(self, point, thing):
         """Check, if the point is inside the thing."""
         if point.x() > thing.x() and point.x() < thing.x() + thing.width() and point.y() > thing.y() and point.y() < thing.y() + thing.height():