Show More
@@ -22,14 +22,6 b' import os' | |||
|
22 | 22 | from IPython.utils import py3compat |
|
23 | 23 | from ._process_common import arg_split |
|
24 | 24 | |
|
25 | def _find_cmd(cmd): | |
|
26 | """Find the full path to a command using which.""" | |
|
27 | paths = System.Environment.GetEnvironmentVariable("PATH").Split(os.pathsep) | |
|
28 | for path in paths: | |
|
29 | filename = os.path.join(path, cmd) | |
|
30 | if System.IO.File.Exists(filename): | |
|
31 | return py3compat.decode(filename) | |
|
32 | raise OSError("command %r not found" % cmd) | |
|
33 | 25 | |
|
34 | 26 | def system(cmd): |
|
35 | 27 | """ |
@@ -31,14 +31,6 b' from IPython.utils.encoding import DEFAULT_ENCODING' | |||
|
31 | 31 | # Function definitions |
|
32 | 32 | #----------------------------------------------------------------------------- |
|
33 | 33 | |
|
34 | def _find_cmd(cmd): | |
|
35 | """Find the full path to a command using which.""" | |
|
36 | ||
|
37 | path = sp.Popen(['/usr/bin/env', 'which', cmd], | |
|
38 | stdout=sp.PIPE, stderr=sp.PIPE).communicate()[0] | |
|
39 | return py3compat.decode(path) | |
|
40 | ||
|
41 | ||
|
42 | 34 | class ProcessHandler(object): |
|
43 | 35 | """Execute subprocesses under the control of pexpect. |
|
44 | 36 | """ |
@@ -71,27 +71,6 b' class AvoidUNCPath(object):' | |||
|
71 | 71 | os.chdir(self.path) |
|
72 | 72 | |
|
73 | 73 | |
|
74 | def _find_cmd(cmd): | |
|
75 | """Find the full path to a .bat or .exe using the win32api module.""" | |
|
76 | try: | |
|
77 | from win32api import SearchPath | |
|
78 | except ImportError as e: | |
|
79 | raise ImportError('you need to have pywin32 installed for this to work') from e | |
|
80 | else: | |
|
81 | PATH = os.environ['PATH'] | |
|
82 | extensions = ['.exe', '.com', '.bat', '.py'] | |
|
83 | path = None | |
|
84 | for ext in extensions: | |
|
85 | try: | |
|
86 | path = SearchPath(PATH, cmd, ext)[0] | |
|
87 | except: | |
|
88 | pass | |
|
89 | if path is None: | |
|
90 | raise OSError("command %r not found" % cmd) | |
|
91 | else: | |
|
92 | return path | |
|
93 | ||
|
94 | ||
|
95 | 74 | def _system_body(p): |
|
96 | 75 | """Callback for _system.""" |
|
97 | 76 | enc = DEFAULT_ENCODING |
General Comments 0
You need to be logged in to leave comments.
Login now