##// END OF EJS Templates
IPython/utils/_process_posix.py: import pexpect only when needed
Matthias Koeppe -
Show More
@@ -20,8 +20,6 b' import os'
20 20 import subprocess as sp
21 21 import sys
22 22
23 import pexpect
24
25 23 # Our own
26 24 from ._process_common import getoutput, arg_split
27 25 from IPython.utils.encoding import DEFAULT_ENCODING
@@ -51,6 +49,7 b' class ProcessHandler(object):'
51 49 @property
52 50 def sh(self):
53 51 if self._sh is None:
52 import pexpect
54 53 shell_name = os.environ.get("SHELL", "sh")
55 54 self._sh = pexpect.which(shell_name)
56 55 if self._sh is None:
@@ -83,6 +82,7 b' class ProcessHandler(object):'
83 82 file descriptors (so the order of the information in this string is the
84 83 correct order as would be seen if running the command in a terminal).
85 84 """
85 import pexpect
86 86 try:
87 87 return pexpect.run(self.sh, args=['-c', cmd]).replace('\r\n', '\n')
88 88 except KeyboardInterrupt:
@@ -104,6 +104,7 b' class ProcessHandler(object):'
104 104 file descriptors (so the order of the information in this string is the
105 105 correct order as would be seen if running the command in a terminal).
106 106 """
107 import pexpect
107 108 try:
108 109 return pexpect.run(self.sh, args=['-c', cmd]).replace('\r\n', '\n')
109 110 except KeyboardInterrupt:
@@ -121,6 +122,8 b' class ProcessHandler(object):'
121 122 -------
122 123 int : child's exitstatus
123 124 """
125 import pexpect
126
124 127 # Get likely encoding for the output.
125 128 enc = DEFAULT_ENCODING
126 129
General Comments 0
You need to be logged in to leave comments. Login now