本文整理汇总了Python中mercurial.util.popen函数的典型用法代码示例。如果您正苦于以下问题:Python popen函数的具体用法?Python popen怎么用?Python popen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了popen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: notify
def notify(self, ids, committer):
'''tell bugzilla to send mail.'''
self.ui.status(_('telling bugzilla to send mail:\n'))
(user, userid) = self.get_bugzilla_user(committer)
for id in ids:
self.ui.status(_(' bug %s\n') % id)
cmdfmt = self.ui.config('bugzilla', 'notify', self.default_notify)
bzdir = self.ui.config('bugzilla', 'bzdir', '/var/www/html/bugzilla')
try:
# Backwards-compatible with old notify string, which
# took one string. This will throw with a new format
# string.
cmd = cmdfmt % id
except TypeError:
cmd = cmdfmt % {'bzdir': bzdir, 'id': id, 'user': user}
self.ui.note(_('running notify command %s\n') % cmd)
fp = util.popen('(%s) 2>&1' % cmd)
out = fp.read()
ret = fp.close()
if ret:
self.ui.warn(out)
raise util.Abort(_('bugzilla notify command %s') %
util.explain_exit(ret)[0])
self.ui.status(_('done\n'))
示例2: _runpager
def _runpager(p):
if not hasattr(os, "fork"):
sys.stdout = util.popen(p, "wb")
if sys.stderr.isatty():
sys.stderr = sys.stdout
return
fdin, fdout = os.pipe()
pid = os.fork()
if pid == 0:
os.close(fdin)
os.dup2(fdout, sys.stdout.fileno())
if sys.stderr.isatty():
os.dup2(fdout, sys.stderr.fileno())
os.close(fdout)
return
os.dup2(fdin, sys.stdin.fileno())
os.close(fdin)
os.close(fdout)
try:
os.execvp("/bin/sh", ["/bin/sh", "-c", p])
except OSError, e:
if e.errno == errno.ENOENT:
# no /bin/sh, try executing the pager directly
args = shlex.split(p)
os.execvp(args[0], args)
else:
raise
示例3: _pagerfork
def _pagerfork(ui, p):
if not util.safehasattr(os, 'fork'):
sys.stdout = util.popen(p, 'wb')
if ui._isatty(sys.stderr):
sys.stderr = sys.stdout
return
fdin, fdout = os.pipe()
pid = os.fork()
if pid == 0:
os.close(fdin)
os.dup2(fdout, sys.stdout.fileno())
if ui._isatty(sys.stderr):
os.dup2(fdout, sys.stderr.fileno())
os.close(fdout)
return
os.dup2(fdin, sys.stdin.fileno())
os.close(fdin)
os.close(fdout)
try:
os.execvp('/bin/sh', ['/bin/sh', '-c', p])
except OSError, e:
if e.errno == errno.ENOENT:
# no /bin/sh, try executing the pager directly
args = shlex.split(p)
os.execvp(args[0], args)
else:
raise
示例4: _run
def _run(self, cmd, *args, **kwargs):
cmdline = self._cmdline(cmd, *args, **kwargs)
self.prerun()
try:
return util.popen(cmdline)
finally:
self.postrun()
示例5: helper
def helper():
stdout = util.popen(cmd, mode='rb')
for each in loaditer(stdout):
client_name = each.get('client', None)
if client_name is not None and client_name == client:
return True
return False
示例6: get_filelogs_at_cl
def get_filelogs_at_cl(client, clnum):
cmd = 'p4 --client %s -G fstat -T ' \
'"depotFile,headAction,headType,headRev" ' \
'"//%s/..."@%d' % (
util.shellquote(client),
util.shellquote(client),
clnum
)
stdout = util.popen(cmd, mode='rb')
try:
result = []
for d in loaditer(stdout):
if d.get('depotFile'):
headaction = d['headAction']
if headaction in ACTION_ARCHIVE or headaction in ACTION_DELETE:
continue
depotfile = d['depotFile']
filelog = {}
filelog[clnum] = {
'action': d['headAction'],
'type': d['headType'],
}
result.append(P4Filelog(depotfile, filelog))
return result
except Exception:
raise P4Exception(stdout)
示例7: content
def content(self, rev):
text = None
if os.path.isfile(self.rcspath):
cmd = 'co -kk -q -p1.%d %s' % (rev, util.shellquote(self.rcspath))
with util.popen(cmd, mode='rb') as fp:
text = fp.read()
return text
示例8: _run
def _run(self, cmd, *args, **kwargs):
cmdline = self._cmdline(cmd, *args, **kwargs)
self.ui.debug(_('running: %s\n') % (cmdline,))
self.prerun()
try:
return util.popen(cmdline)
finally:
self.postrun()
示例9: gitopen
def gitopen(self, s, err=None):
if err == subprocess.PIPE:
(sin, so, se) = util.popen3('GIT_DIR=%s %s' % (self.path, s))
return so
elif err == subprocess.STDOUT:
return self.popen_with_stderr(s)
else:
return util.popen('GIT_DIR=%s %s' % (self.path, s), 'rb')
示例10: _parse_view
def _parse_view(self, path):
"Read changes affecting the path"
cmd = 'p4 -G changes -s submitted %s' % util.shellquote(path)
stdout = util.popen(cmd, mode='rb')
for d in loaditer(stdout):
c = d.get("change", None)
if c:
self.p4changes[c] = True
示例11: _parse_view
def _parse_view(self, path):
"Read changes affecting the path"
cmd = 'p4 -G changes -s submitted "%s"' % path
stdout = util.popen(cmd)
for d in loaditer(stdout):
c = d.get("change", None)
if c:
self.p4changes[c] = True
示例12: pagecmd
def pagecmd(orig, ui, options, cmd, cmdfunc):
p = ui.config("pager", "pager", os.environ.get("PAGER"))
if p and sys.stdout.isatty() and "--debugger" not in sys.argv:
attend = ui.configlist("pager", "attend")
if cmd in attend or (cmd not in ui.configlist("pager", "ignore") and not attend):
sys.stderr = sys.stdout = util.popen(p, "wb")
if ui.configbool("pager", "quiet"):
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
return orig(ui, options, cmd, cmdfunc)
示例13: parse_usermap
def parse_usermap():
cmd = 'p4 -G users'
stdout = util.popen(cmd, mode='rb')
try:
for d in loaditer(stdout):
if d.get('User'):
yield d
except Exception:
raise P4Exception(stdout)
示例14: get_latest_cl
def get_latest_cl(client):
cmd = 'p4 --client %s -G changes -m 1 -s submitted' % (
util.shellquote(client))
stdout = util.popen(cmd, mode='rb')
parsed = marshal.load(stdout)
cl = parsed.get('change')
if cl:
return int(cl)
return None
示例15: pagecmd
def pagecmd(orig, ui, options, cmd, cmdfunc):
p = ui.config("pager", "pager", os.environ.get("PAGER"))
if p and sys.stdout.isatty() and '--debugger' not in sys.argv:
attend = ui.configlist('pager', 'attend', attended)
if (cmd in attend or
(cmd not in ui.configlist('pager', 'ignore') and not attend)):
sys.stderr = sys.stdout = util.popen(p, "wb")
if ui.configbool('pager', 'quiet'):
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
return orig(ui, options, cmd, cmdfunc)