File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020import subprocess as sp
2121import sys
2222
23- import pexpect
24-
2523# Our own
2624from ._process_common import getoutput , arg_split
2725from IPython .utils .encoding import DEFAULT_ENCODING
@@ -51,6 +49,7 @@ class ProcessHandler(object):
5149 @property
5250 def sh (self ):
5351 if self ._sh is None :
52+ import pexpect
5453 shell_name = os .environ .get ("SHELL" , "sh" )
5554 self ._sh = pexpect .which (shell_name )
5655 if self ._sh is None :
@@ -83,6 +82,7 @@ def getoutput(self, cmd):
8382 file descriptors (so the order of the information in this string is the
8483 correct order as would be seen if running the command in a terminal).
8584 """
85+ import pexpect
8686 try :
8787 return pexpect .run (self .sh , args = ['-c' , cmd ]).replace ('\r \n ' , '\n ' )
8888 except KeyboardInterrupt :
@@ -104,6 +104,7 @@ def getoutput_pexpect(self, cmd):
104104 file descriptors (so the order of the information in this string is the
105105 correct order as would be seen if running the command in a terminal).
106106 """
107+ import pexpect
107108 try :
108109 return pexpect .run (self .sh , args = ['-c' , cmd ]).replace ('\r \n ' , '\n ' )
109110 except KeyboardInterrupt :
@@ -121,6 +122,8 @@ def system(self, cmd):
121122 -------
122123 int : child's exitstatus
123124 """
125+ import pexpect
126+
124127 # Get likely encoding for the output.
125128 enc = DEFAULT_ENCODING
126129
You can’t perform that action at this time.
0 commit comments