Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(60)

Side by Side Diff: Lib/subprocess.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/stat.py ('k') | Lib/tempfile.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # subprocess - Subprocesses with accessible I/O streams 1 # subprocess - Subprocesses with accessible I/O streams
2 # 2 #
3 # For more information about this module, see PEP 324. 3 # For more information about this module, see PEP 324.
4 # 4 #
5 # Copyright (c) 2003-2005 by Peter Astrand <astrand@lysator.liu.se> 5 # Copyright (c) 2003-2005 by Peter Astrand <astrand@lysator.liu.se>
6 # 6 #
7 # Licensed to PSF under a Contributor Agreement. 7 # Licensed to PSF under a Contributor Agreement.
8 # See http://www.python.org/2.4/license for licensing details. 8 # See http://www.python.org/2.4/license for licensing details.
9 9
10 r"""subprocess - Subprocesses with accessible I/O streams 10 r"""subprocess - Subprocesses with accessible I/O streams
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 439
440 PIPE = -1 440 PIPE = -1
441 STDOUT = -2 441 STDOUT = -2
442 DEVNULL = -3 442 DEVNULL = -3
443 443
444 444
445 def _eintr_retry_call(func, *args): 445 def _eintr_retry_call(func, *args):
446 while True: 446 while True:
447 try: 447 try:
448 return func(*args) 448 return func(*args)
449 except (OSError, IOError) as e: 449 except OSError as e:
450 if e.errno == errno.EINTR: 450 if e.errno == errno.EINTR:
451 continue 451 continue
452 raise 452 raise
453 453
454 454
455 def call(*popenargs, timeout=None, **kwargs): 455 def call(*popenargs, timeout=None, **kwargs):
456 """Run command with arguments. Wait for command to complete or 456 """Run command with arguments. Wait for command to complete or
457 timeout, then return the returncode attribute. 457 timeout, then return the returncode attribute.
458 458
459 The arguments are the same as for the Popen constructor. Example: 459 The arguments are the same as for the Popen constructor. Example:
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 if p2cwrite != -1: 721 if p2cwrite != -1:
722 p2cwrite = msvcrt.open_osfhandle(p2cwrite.Detach(), 0) 722 p2cwrite = msvcrt.open_osfhandle(p2cwrite.Detach(), 0)
723 if c2pread != -1: 723 if c2pread != -1:
724 c2pread = msvcrt.open_osfhandle(c2pread.Detach(), 0) 724 c2pread = msvcrt.open_osfhandle(c2pread.Detach(), 0)
725 if errread != -1: 725 if errread != -1:
726 errread = msvcrt.open_osfhandle(errread.Detach(), 0) 726 errread = msvcrt.open_osfhandle(errread.Detach(), 0)
727 727
728 if p2cwrite != -1: 728 if p2cwrite != -1:
729 self.stdin = io.open(p2cwrite, 'wb', bufsize) 729 self.stdin = io.open(p2cwrite, 'wb', bufsize)
730 if self.universal_newlines: 730 if self.universal_newlines:
731 self.stdin = io.TextIOWrapper(self.stdin, write_through=True) 731 self.stdin = io.TextIOWrapper(self.stdin)
732 if c2pread != -1: 732 if c2pread != -1:
733 self.stdout = io.open(c2pread, 'rb', bufsize) 733 self.stdout = io.open(c2pread, 'rb', bufsize)
734 if universal_newlines: 734 if universal_newlines:
735 self.stdout = io.TextIOWrapper(self.stdout) 735 self.stdout = io.TextIOWrapper(self.stdout)
736 if errread != -1: 736 if errread != -1:
737 self.stderr = io.open(errread, 'rb', bufsize) 737 self.stderr = io.open(errread, 'rb', bufsize)
738 if universal_newlines: 738 if universal_newlines:
739 self.stderr = io.TextIOWrapper(self.stderr) 739 self.stderr = io.TextIOWrapper(self.stderr)
740 740
741 try: 741 try:
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 stderr = None 813 stderr = None
814 if self.stdin: 814 if self.stdin:
815 if input: 815 if input:
816 try: 816 try:
817 self.stdin.write(input) 817 self.stdin.write(input)
818 except IOError as e: 818 except IOError as e:
819 if e.errno != errno.EPIPE and e.errno != errno.EINVAL: 819 if e.errno != errno.EPIPE and e.errno != errno.EINVAL:
820 raise 820 raise
821 self.stdin.close() 821 self.stdin.close()
822 elif self.stdout: 822 elif self.stdout:
823 stdout = _eintr_retry_call(self.stdout.read) 823 stdout = self.stdout.read()
824 self.stdout.close() 824 self.stdout.close()
825 elif self.stderr: 825 elif self.stderr:
826 stderr = _eintr_retry_call(self.stderr.read) 826 stderr = self.stderr.read()
827 self.stderr.close() 827 self.stderr.close()
828 self.wait() 828 self.wait()
829 else: 829 else:
830 if timeout is not None: 830 if timeout is not None:
831 endtime = time.time() + timeout 831 endtime = time.time() + timeout
832 else: 832 else:
833 endtime = None 833 endtime = None
834 834
835 try: 835 try:
836 stdout, stderr = self._communicate(input, endtime, timeout) 836 stdout, stderr = self._communicate(input, endtime, timeout)
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 1624
1625 def terminate(self): 1625 def terminate(self):
1626 """Terminate the process with SIGTERM 1626 """Terminate the process with SIGTERM
1627 """ 1627 """
1628 self.send_signal(signal.SIGTERM) 1628 self.send_signal(signal.SIGTERM)
1629 1629
1630 def kill(self): 1630 def kill(self):
1631 """Kill the process with SIGKILL 1631 """Kill the process with SIGKILL
1632 """ 1632 """
1633 self.send_signal(signal.SIGKILL) 1633 self.send_signal(signal.SIGKILL)
OLDNEW
« no previous file with comments | « Lib/stat.py ('k') | Lib/tempfile.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+