本文整理汇总了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