@@ -1415,36 +1415,8 @@ Environment example::
1415
1415
1416
1416
1417
1417
1418
- Replacing :func: `os.popen `, :func: `os.popen2 `, :func: `os.popen3 `
1419
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1420
-
1421
- ::
1422
-
1423
- (child_stdin, child_stdout) = os.popen2(cmd, mode, bufsize)
1424
- ==>
1425
- p = Popen(cmd, shell=True, bufsize=bufsize,
1426
- stdin=PIPE, stdout=PIPE, close_fds=True)
1427
- (child_stdin, child_stdout) = (p.stdin, p.stdout)
1428
-
1429
- ::
1430
-
1431
- (child_stdin,
1432
- child_stdout,
1433
- child_stderr) = os.popen3(cmd, mode, bufsize)
1434
- ==>
1435
- p = Popen(cmd, shell=True, bufsize=bufsize,
1436
- stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
1437
- (child_stdin,
1438
- child_stdout,
1439
- child_stderr) = (p.stdin, p.stdout, p.stderr)
1440
-
1441
- ::
1442
-
1443
- (child_stdin, child_stdout_and_stderr) = os.popen4(cmd, mode, bufsize)
1444
- ==>
1445
- p = Popen(cmd, shell=True, bufsize=bufsize,
1446
- stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
1447
- (child_stdin, child_stdout_and_stderr) = (p.stdin, p.stdout)
1418
+ Replacing :func: `os.popen `
1419
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
1448
1420
1449
1421
Return code handling translates as follows::
1450
1422
@@ -1461,44 +1433,6 @@ Return code handling translates as follows::
1461
1433
print("There were some errors")
1462
1434
1463
1435
1464
- Replacing functions from the :mod: `popen2 ` module
1465
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1466
-
1467
- .. note ::
1468
-
1469
- If the cmd argument to popen2 functions is a string, the command is executed
1470
- through /bin/sh. If it is a list, the command is directly executed.
1471
-
1472
- ::
1473
-
1474
- (child_stdout, child_stdin) = popen2.popen2("somestring", bufsize, mode)
1475
- ==>
1476
- p = Popen("somestring", shell=True, bufsize=bufsize,
1477
- stdin=PIPE, stdout=PIPE, close_fds=True)
1478
- (child_stdout, child_stdin) = (p.stdout, p.stdin)
1479
-
1480
- ::
1481
-
1482
- (child_stdout, child_stdin) = popen2.popen2(["mycmd", "myarg"], bufsize, mode)
1483
- ==>
1484
- p = Popen(["mycmd", "myarg"], bufsize=bufsize,
1485
- stdin=PIPE, stdout=PIPE, close_fds=True)
1486
- (child_stdout, child_stdin) = (p.stdout, p.stdin)
1487
-
1488
- :class: `popen2.Popen3 ` and :class: `popen2.Popen4 ` basically work as
1489
- :class: `subprocess.Popen `, except that:
1490
-
1491
- * :class: `Popen ` raises an exception if the execution fails.
1492
-
1493
- * The *capturestderr * argument is replaced with the *stderr * argument.
1494
-
1495
- * ``stdin=PIPE `` and ``stdout=PIPE `` must be specified.
1496
-
1497
- * popen2 closes all file descriptors by default, but you have to specify
1498
- ``close_fds=True `` with :class: `Popen ` to guarantee this behavior on
1499
- all platforms or past Python versions.
1500
-
1501
-
1502
1436
Legacy Shell Invocation Functions
1503
1437
---------------------------------
1504
1438
0 commit comments