kiilerix avatar kiilerix committed 076401c

run-tests.py: avoid using popen2.Popen4 - use subprocess instead

Use subprocess to emulate Popen4 if available - similar to how it is done in
util.py.

Using popen2 under python 2.6 gives
DeprecationWarning: The popen2 module is deprecated. Use the subprocess module.

Comments (0)

Files changed (1)

tests/run-tests.py

 import errno
 import optparse
 import os
-import popen2
+try:
+    import subprocess
+    subprocess.Popen  # trigger ImportError early
+    closefds = os.name == 'posix'
+    def Popen4(cmd, bufsize=-1):
+        p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
+                             close_fds=closefds,
+                             stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+                             stderr=subprocess.STDOUT)
+        p.fromchild = p.stdout
+        p.tochild = p.stdin
+        p.childerr = p.stderr
+        return p
+except ImportError:
+    subprocess = None
+    from popen2 import Popen4
 import shutil
 import signal
 import sys
         if ret == None:
             ret = 0
     else:
-        proc = popen2.Popen4(cmd)
+        proc = Popen4(cmd)
         try:
             output = ''
             proc.tochild.close()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.