Python popen2._cleanup() Examples

The following are 16 code examples of popen2._cleanup(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module popen2 , or try the search function .
Example #1
Source File: test_popen2.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
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])) 
Example #2
Source File: test_popen2.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
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() 
Example #3
Source File: test_popen2.py    From BinderFilter with MIT License 5 votes vote down vote up
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])) 
Example #4
Source File: test_popen2.py    From BinderFilter with MIT License 5 votes vote down vote up
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() 
Example #5
Source File: test_popen2.py    From oss-ftp with MIT License 5 votes vote down vote up
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])) 
Example #6
Source File: test_popen2.py    From oss-ftp with MIT License 5 votes vote down vote up
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() 
Example #7
Source File: test_popen2.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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])) 
Example #8
Source File: test_popen2.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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() 
Example #9
Source File: test_popen2.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
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" 
Example #10
Source File: test_cmd_line.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
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 
Example #11
Source File: test_popen2.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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])) 
Example #12
Source File: test_popen2.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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() 
Example #13
Source File: test_cmd_line.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #14
Source File: test_popen2.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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])) 
Example #15
Source File: test_popen2.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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() 
Example #16
Source File: test_cmd_line.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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