当前位置: 首页>>代码示例>>Python>>正文


Python popen2._cleanup方法代码示例

本文整理汇总了Python中popen2._cleanup方法的典型用法代码示例。如果您正苦于以下问题:Python popen2._cleanup方法的具体用法?Python popen2._cleanup怎么用?Python popen2._cleanup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在popen2的用法示例。


在下文中一共展示了popen2._cleanup方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: import popen2 [as 别名]
# 或者: from popen2 import _cleanup [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])) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_popen2.py

示例2: tearDown

# 需要导入模块: import popen2 [as 别名]
# 或者: from popen2 import _cleanup [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() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_popen2.py

示例3: _test

# 需要导入模块: import popen2 [as 别名]
# 或者: from popen2 import _cleanup [as 别名]
def _test():
    # same test as popen2._test(), but using the os.popen*() API
    print "Testing os module:"
    import popen2
    # When the test runs, there shouldn't be any open pipes
    popen2._cleanup()
    assert not popen2._active, "Active pipes when test starts " + repr([c.cmd for c in popen2._active])
    cmd  = "cat"
    teststr = "ab cd\n"
    if os.name == "nt" or (is_jython and os._name == 'nt'):
        cmd = "more"
    # "more" doesn't act the same way across Windows flavors,
    # sometimes adding an extra newline at the start or the
    # end.  So we strip whitespace off both ends for comparison.
    expected = teststr.strip()
    print "testing popen2..."
    w, r = os.popen2(cmd)
    w.write(teststr)
    w.close()
    got = r.read()
    if got.strip() != expected:
        raise ValueError("wrote %r read %r" % (teststr, got))
    print "testing popen3..."
    try:
        w, r, e = os.popen3([cmd])
    except:
        w, r, e = os.popen3(cmd)
    w.write(teststr)
    w.close()
    got = r.read()
    if got.strip() != expected:
        raise ValueError("wrote %r read %r" % (teststr, got))
    got = e.read()
    if got:
        raise ValueError("unexpected %r on stderr" % (got,))
    for inst in popen2._active[:]:
        inst.wait()
    popen2._cleanup()
    if popen2._active:
        raise ValueError("_active not empty")
    print "All OK" 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:43,代码来源:test_popen2.py

示例4: start_python

# 需要导入模块: import popen2 [as 别名]
# 或者: from popen2 import _cleanup [as 别名]
def start_python(self, cmd_line):
        outfp, infp = popen2.popen4('"%s" %s' % (sys.executable, cmd_line))
        infp.close()
        data = outfp.read()
        outfp.close()
        # try to cleanup the child so we don't appear to leak when running
        # with regrtest -R.  This should be a no-op on Windows.
        popen2._cleanup()
        return data 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:11,代码来源:test_cmd_line.py


注:本文中的popen2._cleanup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。