本文整理匯總了Python中popen2.popen2方法的典型用法代碼示例。如果您正苦於以下問題:Python popen2.popen2方法的具體用法?Python popen2.popen2怎麽用?Python popen2.popen2使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類popen2
的用法示例。
在下文中一共展示了popen2.popen2方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setUp
# 需要導入模塊: import popen2 [as 別名]
# 或者: from popen2 import popen2 [as 別名]
def setUp(self):
popen2._cleanup()
# When the test runs, there shouldn't be any open pipes
self.assertFalse(popen2._active, "Active pipes when test starts" +
repr([c.cmd for c in popen2._active]))
示例2: tearDown
# 需要導入模塊: import popen2 [as 別名]
# 或者: from popen2 import popen2 [as 別名]
def tearDown(self):
for inst in popen2._active:
inst.wait()
popen2._cleanup()
self.assertFalse(popen2._active, "popen2._active not empty")
# The os.popen*() API delegates to the subprocess module (on Unix)
import subprocess
for inst in subprocess._active:
inst.wait()
subprocess._cleanup()
self.assertFalse(subprocess._active, "subprocess._active not empty")
reap_children()
示例3: test_popen2
# 需要導入模塊: import popen2 [as 別名]
# 或者: from popen2 import popen2 [as 別名]
def test_popen2(self):
r, w = popen2.popen2(self.cmd)
self.validate_output(self.teststr, self.expected, r, w)
示例4: test_popen3
# 需要導入模塊: import popen2 [as 別名]
# 或者: from popen2 import popen2 [as 別名]
def test_popen3(self):
if os.name == 'posix':
r, w, e = popen2.popen3([self.cmd])
self.validate_output(self.teststr, self.expected, r, w, e)
r, w, e = popen2.popen3(self.cmd)
self.validate_output(self.teststr, self.expected, r, w, e)
示例5: test_os_popen2
# 需要導入模塊: import popen2 [as 別名]
# 或者: from popen2 import popen2 [as 別名]
def test_os_popen2(self):
# same test as test_popen2(), but using the os.popen*() API
if os.name == 'posix':
w, r = os.popen2([self.cmd])
self.validate_output(self.teststr, self.expected, r, w)
w, r = os.popen2(["echo", self.teststr])
got = r.read()
self.assertEqual(got, self.teststr + "\n")
w, r = os.popen2(self.cmd)
self.validate_output(self.teststr, self.expected, r, w)
示例6: _apply_ossl_cmd
# 需要導入模塊: import popen2 [as 別名]
# 或者: from popen2 import popen2 [as 別名]
def _apply_ossl_cmd(self, osslcmd, rawdata):
r,w=popen2.popen2(osslcmd)
w.write(rawdata)
w.close()
res = r.read()
r.close()
return res
示例7: print_chain
# 需要導入模塊: import popen2 [as 別名]
# 或者: from popen2 import popen2 [as 別名]
def print_chain(l):
llen = len(l) - 1
if llen < 0:
return ""
c = l[llen]
llen -= 1
s = "_ "
if not c.isSelfSigned():
s = "_ ... [Missing Root]\n"
else:
s += "%s [Self Signed]\n" % c.subject
i = 1
while (llen != -1):
c = l[llen]
s += "%s\_ %s" % (" "*i, c.subject)
if llen != 0:
s += "\n"
i += 2
llen -= 1
print s
# import popen2
# a=popen2.Popen3("openssl crl -text -inform DER -noout ", capturestderr=True)
# a.tochild.write(open("samples/klasa1.crl").read())
# a.tochild.close()
# a.poll()
示例8: resolve_clang_includes
# 需要導入模塊: import popen2 [as 別名]
# 或者: from popen2 import popen2 [as 別名]
def resolve_clang_includes(self):
cmd = "clang -print-file-name=include"
rfd, wfd = popen2.popen2(cmd)
return rfd.read().strip("\n")
示例9: _apply_ossl_cmd
# 需要導入模塊: import popen2 [as 別名]
# 或者: from popen2 import popen2 [as 別名]
def _apply_ossl_cmd(self, osslcmd, rawdata):
r,w=popen2.popen2(osslcmd)
w.write(rawdata)
w.close()
res = r.read()
r.close()
return res