##// END OF EJS Templates
replace usage of os.popen() with util.popen()...
Dirkjan Ochtman -
r6548:962eb403 default
parent child Browse files
Show More
@@ -55,7 +55,7 b''
55 from mercurial.i18n import _
55 from mercurial.i18n import _
56 from mercurial.node import short
56 from mercurial.node import short
57 from mercurial import cmdutil, templater, util
57 from mercurial import cmdutil, templater, util
58 import os, re, time
58 import re, time
59
59
60 MySQLdb = None
60 MySQLdb = None
61
61
@@ -127,7 +127,7 b' class bugzilla_2_16(object):'
127 cmd = self.ui.config('bugzilla', 'notify',
127 cmd = self.ui.config('bugzilla', 'notify',
128 'cd /var/www/html/bugzilla && '
128 'cd /var/www/html/bugzilla && '
129 './processmail %s nobody@nowhere.com') % id
129 './processmail %s nobody@nowhere.com') % id
130 fp = os.popen('(%s) 2>&1' % cmd)
130 fp = util.popen('(%s) 2>&1' % cmd)
131 out = fp.read()
131 out = fp.read()
132 ret = fp.close()
132 ret = fp.close()
133 if ret:
133 if ret:
@@ -47,7 +47,7 b' them in the global .hgrc'
47 '''
47 '''
48
48
49 import sys, os, signal
49 import sys, os, signal
50 from mercurial import dispatch
50 from mercurial import dispatch, util
51
51
52 def uisetup(ui):
52 def uisetup(ui):
53 def pagecmd(ui, options, cmd, cmdfunc):
53 def pagecmd(ui, options, cmd, cmdfunc):
@@ -56,7 +56,7 b' def uisetup(ui):'
56 attend = ui.configlist('pager', 'attend')
56 attend = ui.configlist('pager', 'attend')
57 if (cmd in attend or
57 if (cmd in attend or
58 (cmd not in ui.configlist('pager', 'ignore') and not attend)):
58 (cmd not in ui.configlist('pager', 'ignore') and not attend)):
59 sys.stderr = sys.stdout = os.popen(p, "wb")
59 sys.stderr = sys.stdout = util.popen(p, "wb")
60 if ui.configbool('pager', 'quiet'):
60 if ui.configbool('pager', 'quiet'):
61 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
61 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
62 return oldrun(ui, options, cmd, cmdfunc)
62 return oldrun(ui, options, cmd, cmdfunc)
@@ -404,7 +404,7 b' def patchbomb(ui, repo, *revs, **opts):'
404 ui.status('Displaying ', m['Subject'], ' ...\n')
404 ui.status('Displaying ', m['Subject'], ' ...\n')
405 ui.flush()
405 ui.flush()
406 if 'PAGER' in os.environ:
406 if 'PAGER' in os.environ:
407 fp = os.popen(os.environ['PAGER'], 'w')
407 fp = util.popen(os.environ['PAGER'], 'w')
408 else:
408 else:
409 fp = ui
409 fp = ui
410 generator = email.Generator.Generator(fp, mangle_from_=False)
410 generator = email.Generator.Generator(fp, mangle_from_=False)
@@ -6,7 +6,8 b''
6 # of the GNU General Public License, incorporated herein by reference.
6 # of the GNU General Public License, incorporated herein by reference.
7
7
8 from i18n import _
8 from i18n import _
9 import os, smtplib, util, socket
9 import os, smtplib, socket
10 import util
10
11
11 def _smtp(ui):
12 def _smtp(ui):
12 '''build an smtp connection and return a function to send mail'''
13 '''build an smtp connection and return a function to send mail'''
@@ -53,7 +54,7 b' def _sendmail(ui, sender, recipients, ms'
53 cmdline = '%s -f %s %s' % (program, util.email(sender),
54 cmdline = '%s -f %s %s' % (program, util.email(sender),
54 ' '.join(map(util.email, recipients)))
55 ' '.join(map(util.email, recipients)))
55 ui.note(_('sending mail: %s\n') % cmdline)
56 ui.note(_('sending mail: %s\n') % cmdline)
56 fp = os.popen(cmdline, 'w')
57 fp = util.popen(cmdline, 'w')
57 fp.write(msg)
58 fp.write(msg)
58 ret = fp.close()
59 ret = fp.close()
59 if ret:
60 if ret:
@@ -1086,12 +1086,12 b" if os.name == 'nt':"
1086 # through the current COMSPEC. cmd.exe suppress enclosing quotes.
1086 # through the current COMSPEC. cmd.exe suppress enclosing quotes.
1087 return '"' + cmd + '"'
1087 return '"' + cmd + '"'
1088
1088
1089 def popen(command):
1089 def popen(command, mode='r'):
1090 # Work around "popen spawned process may not write to stdout
1090 # Work around "popen spawned process may not write to stdout
1091 # under windows"
1091 # under windows"
1092 # http://bugs.python.org/issue1366
1092 # http://bugs.python.org/issue1366
1093 command += " 2> %s" % nulldev
1093 command += " 2> %s" % nulldev
1094 return os.popen(quotecommand(command))
1094 return os.popen(quotecommand(command), mode)
1095
1095
1096 def explain_exit(code):
1096 def explain_exit(code):
1097 return _("exited with status %d") % code, code
1097 return _("exited with status %d") % code, code
@@ -1252,8 +1252,8 b' else:'
1252 def quotecommand(cmd):
1252 def quotecommand(cmd):
1253 return cmd
1253 return cmd
1254
1254
1255 def popen(command):
1255 def popen(command, mode='r'):
1256 return os.popen(command)
1256 return os.popen(command, mode)
1257
1257
1258 def testpid(pid):
1258 def testpid(pid):
1259 '''return False if pid dead, True if running or not sure'''
1259 '''return False if pid dead, True if running or not sure'''
@@ -12,6 +12,7 b' Mercurial version'
12 import os
12 import os
13 import re
13 import re
14 import time
14 import time
15 import util
15
16
16 unknown_version = 'unknown'
17 unknown_version = 'unknown'
17 remembered_version = False
18 remembered_version = False
@@ -48,7 +49,7 b' def remember_version(version=None):'
48 """Store version information."""
49 """Store version information."""
49 global remembered_version
50 global remembered_version
50 if not version and os.path.isdir(".hg"):
51 if not version and os.path.isdir(".hg"):
51 f = os.popen("hg identify") # use real hg installation
52 f = util.popen("hg identify") # use real hg installation
52 ident = f.read()[:-1]
53 ident = f.read()[:-1]
53 if not f.close() and ident:
54 if not f.close() and ident:
54 ids = ident.split(' ', 1)
55 ids = ident.split(' ', 1)
General Comments 0
You need to be logged in to leave comments. Login now