##// END OF EJS Templates
util: always use subprocess
Martin Geisler -
r8280:0b02d98d default
parent child Browse files
Show More
@@ -44,37 +44,29 b' def sha1(s):'
44 44 _sha1 = sha.sha
45 45 return _sha1(s)
46 46
47 try:
48 import subprocess
49 subprocess.Popen # trigger ImportError early
50 closefds = os.name == 'posix'
51 def popen2(cmd, mode='t', bufsize=-1):
52 p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
53 close_fds=closefds,
54 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
55 return p.stdin, p.stdout
56 def popen3(cmd, mode='t', bufsize=-1):
57 p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
58 close_fds=closefds,
59 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
60 stderr=subprocess.PIPE)
61 return p.stdin, p.stdout, p.stderr
62 def Popen3(cmd, capturestderr=False, bufsize=-1):
63 stderr = capturestderr and subprocess.PIPE or None
64 p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
65 close_fds=closefds,
66 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
67 stderr=stderr)
68 p.fromchild = p.stdout
69 p.tochild = p.stdin
70 p.childerr = p.stderr
71 return p
72 except ImportError:
73 subprocess = None
74 from popen2 import Popen3
75 popen2 = os.popen2
76 popen3 = os.popen3
77
47 import subprocess
48 closefds = os.name == 'posix'
49 def popen2(cmd, mode='t', bufsize=-1):
50 p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
51 close_fds=closefds,
52 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
53 return p.stdin, p.stdout
54 def popen3(cmd, mode='t', bufsize=-1):
55 p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
56 close_fds=closefds,
57 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
58 stderr=subprocess.PIPE)
59 return p.stdin, p.stdout, p.stderr
60 def Popen3(cmd, capturestderr=False, bufsize=-1):
61 stderr = capturestderr and subprocess.PIPE or None
62 p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
63 close_fds=closefds,
64 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
65 stderr=stderr)
66 p.fromchild = p.stdout
67 p.tochild = p.stdin
68 p.childerr = p.stderr
69 return p
78 70
79 71 def version():
80 72 """Return version information if available."""
@@ -11,28 +11,24 b' import difflib'
11 11 import errno
12 12 import optparse
13 13 import os
14 try:
15 import subprocess
16 subprocess.Popen # trigger ImportError early
17 closefds = os.name == 'posix'
18 def Popen4(cmd, bufsize=-1):
19 p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
20 close_fds=closefds,
21 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
22 stderr=subprocess.STDOUT)
23 p.fromchild = p.stdout
24 p.tochild = p.stdin
25 p.childerr = p.stderr
26 return p
27 except ImportError:
28 subprocess = None
29 from popen2 import Popen4
14 import subprocess
30 15 import shutil
31 16 import signal
32 17 import sys
33 18 import tempfile
34 19 import time
35 20
21 closefds = os.name == 'posix'
22 def Popen4(cmd, bufsize=-1):
23 p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
24 close_fds=closefds,
25 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
26 stderr=subprocess.STDOUT)
27 p.fromchild = p.stdout
28 p.tochild = p.stdin
29 p.childerr = p.stderr
30 return p
31
36 32 # reserved exit code to skip test (used by hghave)
37 33 SKIPPED_STATUS = 80
38 34 SKIPPED_PREFIX = 'skipped: '
General Comments 0
You need to be logged in to leave comments. Login now