486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 | |
def __init__(self, args, bufsize=0, executable=None, |
stdin=None, stdout=None, stderr=None, |
preexec_fn=None, close_fds=False, shell=False, |
cwd=None, env=None, universal_newlines=False, |
startupinfo=None, creationflags=0): |
"""Create new Popen instance.""" |
_cleanup() |
|
if not isinstance(bufsize, (int, long)): |
raise TypeError("bufsize must be an integer") |
|
if mswindows: |
if preexec_fn is not None: |
raise ValueError("preexec_fn is not supported on Windows " |
"platforms") |
if close_fds: |
raise ValueError("close_fds is not supported on Windows " |
"platforms") |
else: |
|
if startupinfo is not None: |
raise ValueError("startupinfo is only supported on Windows " |
"platforms") |
if creationflags != 0: |
raise ValueError("creationflags is only supported on Windows " |
"platforms") |
|
self.stdin = None |
self.stdout = None |
self.stderr = None |
self.pid = None |
self.returncode = None |
self.universal_newlines = universal_newlines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(p2cread, p2cwrite, |
c2pread, c2pwrite, |
errread, errwrite) = self._get_handles(stdin, stdout, stderr) |
|
self._execute_child(args, executable, preexec_fn, close_fds, |
cwd, env, universal_newlines, |
startupinfo, creationflags, shell, |
p2cread, p2cwrite, |
c2pread, c2pwrite, |
errread, errwrite) |
|
if p2cwrite: |
self.stdin = os.fdopen(p2cwrite, 'wb', bufsize) |
if c2pread: |
if universal_newlines: |
self.stdout = os.fdopen(c2pread, 'rU', bufsize) |
else: |
self.stdout = os.fdopen(c2pread, 'rb', bufsize) |
if errread: |
if universal_newlines: |
self.stderr = os.fdopen(errread, 'rU', bufsize) |
else: |
self.stderr = os.fdopen(errread, 'rb', bufsize) |
|
_active.append(self) | |