[gnome-schedule/freebsd] at.py: Use subprocess popen, replacing os.popen*



commit 8f224a335f7dc1dd0d7873fb709406c0b65cd86e
Author: Gaute Hope <eg gaute vetsj com>
Date:   Wed Oct 12 13:38:17 2011 +0200

    at.py: Use subprocess popen, replacing os.popen*

 src/at.py |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/at.py b/src/at.py
index 547dc64..2228f17 100644
--- a/src/at.py
+++ b/src/at.py
@@ -21,6 +21,7 @@
 #python modules
 import re
 import os
+from subprocess import Popen, PIPE
 import sys
 import tempfile
 import commands
@@ -175,7 +176,7 @@ fi
 
                     execute = config.getAtbin() + " -c " + job_id
                     # read lines and detect starter
-                    script = os.popen(execute).read()
+                    script = Popen(execute, shell = True, stdout = PIPE).stdout.read()
                     script,  dangerous = self.__prepare_script__ (script, manual_poscorrect, output, display)
 
                     #removing ending newlines, but keep one
@@ -423,14 +424,13 @@ fi
                 #changes the ownership
                 os.chown(path, self.uid, self.gid)
                 execute = config.getSubin() + " " + self.user + " -c \"" + config.getAtbin() +  " -f " + path + " " + runat + " && exit\""
-                child_stdin, child_stdout, child_stderr = os.popen3(execute)
             else:
                 execute = config.getAtbin() + " -f " + path + " " + runat
-                child_stdin, child_stdout, child_stderr = os.popen3(execute)
         else:
             execute = config.getAtbin() + " -f " + path + " " + runat
-            child_stdin, child_stdout, child_stderr = os.popen3(execute)
 
+        p = Popen (execute, shell = True, stdin = PIPE, stdout = PIPE, stderr = PIPE, close_fds = True)
+        (child_stdin, child_stdout, child_stderr) = (p.stdin, p.stdout, p.stderr)
 
         err = child_stderr.readlines ()
         job_id = 0
@@ -478,13 +478,13 @@ fi
                 #changes the ownership
                 os.chown(path, self.uid, self.gid)
                 execute = config.getSubin() + " " + self.user + " -c \"" + config.getAtbin() +  " -f " + path + " " + runat + " && exit\""
-                child_stdin, child_stdout, child_stderr = os.popen3(execute)
             else:
                 execute = config.getAtbin() + " -f " + path + " " + runat
-                child_stdin, child_stdout, child_stderr = os.popen3(execute)
         else:
             execute = config.getAtbin() + " -f " + path + " " + runat
-            child_stdin, child_stdout, child_stderr = os.popen3(execute)
+
+        p = Popen (execute, shell = True, stdin = PIPE, stdout = PIPE, stderr = PIPE, close_fds = True)
+        (child_stdin, child_stdout, child_stderr) = (p.stdin, p.stdout, p.stderr)
 
         err = child_stderr.readlines ()
         job_id = 0
@@ -515,7 +515,7 @@ fi
         data = []
         #do 'atq'
         execute = config.getAtqbin ()
-        self.lines = os.popen(execute).readlines()
+        self.lines = Popen(execute, shell = True, stdout = PIPE).stdout.readlines()
 
         # Skip header: Date..
         if self.sysname == 'FreeBSD':



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]