##// END OF EJS Templates
hghave: use subprocess instead of os.popen...
Augie Fackler -
r26137:99e8a9ff default
parent child Browse files
Show More
@@ -1,6 +1,9 b''
1 import os, stat
1 import errno
2 import os
2 import re
3 import re
3 import socket
4 import socket
5 import stat
6 import subprocess
4 import sys
7 import sys
5 import tempfile
8 import tempfile
6
9
@@ -69,14 +72,16 b' def matchoutput(cmd, regexp, ignorestatu'
69 is matched by the supplied regular expression.
72 is matched by the supplied regular expression.
70 """
73 """
71 r = re.compile(regexp)
74 r = re.compile(regexp)
72 fh = os.popen(cmd)
73 s = fh.read()
74 try:
75 try:
75 ret = fh.close()
76 p = subprocess.Popen(
76 except IOError:
77 cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
77 # Happen in Windows test environment
78 except OSError as e:
78 ret = 1
79 if e.errno != errno.ENOENT:
79 return (ignorestatus or ret is None) and r.search(s)
80 raise
81 ret = -1
82 ret = p.wait()
83 s = p.stdout.read()
84 return (ignorestatus or not ret) and r.search(s)
80
85
81 @check("baz", "GNU Arch baz client")
86 @check("baz", "GNU Arch baz client")
82 def has_baz():
87 def has_baz():
General Comments 0
You need to be logged in to leave comments. Login now