Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/spawn.py @ 25838:8540887bcec6 2.2
Backport of 2.183:
Fix memory leak in add_subclass() found by NealN with valgrind.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 18 Oct 2002 13:42:21 +0000 |
| parents | 7a7f557b4d54 |
| children | e0fc286d57a4 |
| rev | line source |
|---|---|
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1 """distutils.spawn |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
2 |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
3 Provides the 'spawn()' function, a front-end to various platform- |
|
13803
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
4 specific functions for launching another program in a sub-process. |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
5 Also provides the 'find_executable()' to search the path for a given |
| 14861 | 6 executable name. |
| 7 """ | |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
8 |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
9 # created 1999/07/24, Greg Ward |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
10 |
|
11897
017e592c0fd2
Changed '__rcsid__' to '__revision__'.
Greg Ward <gward@python.net>
parents:
11665
diff
changeset
|
11 __revision__ = "$Id$" |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
12 |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
13 import sys, os, string |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
14 from distutils.errors import * |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
15 |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
16 |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
17 def spawn (cmd, |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
18 search_path=1, |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
19 verbose=0, |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
20 dry_run=0): |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
21 |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
22 """Run another program, specified as a command list 'cmd', in a new |
| 14861 | 23 process. 'cmd' is just the argument list for the new process, ie. |
| 24 cmd[0] is the program to run and cmd[1:] are the rest of its arguments. | |
| 25 There is no way to run a program with a name different from that of its | |
| 26 executable. | |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
27 |
| 14861 | 28 If 'search_path' is true (the default), the system's executable search |
| 29 path will be used to find the program; otherwise, cmd[0] must be the | |
| 30 exact path to the executable. If 'verbose' is true, a one-line summary | |
| 31 of the command will be printed before it is run. If 'dry_run' is true, | |
| 32 the command will not actually be run. | |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
33 |
| 14861 | 34 Raise DistutilsExecError if running the program fails in any way; just |
| 35 return on success. | |
| 36 """ | |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
37 if os.name == 'posix': |
| 14861 | 38 _spawn_posix(cmd, search_path, verbose, dry_run) |
| 11257 | 39 elif os.name == 'nt': |
| 14861 | 40 _spawn_nt(cmd, search_path, verbose, dry_run) |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
41 else: |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
42 raise DistutilsPlatformError, \ |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
43 "don't know how to spawn programs on platform '%s'" % os.name |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
44 |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
45 # spawn () |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
46 |
| 11257 | 47 |
|
11933
68e0ef052815
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
48 def _nt_quote_args (args): |
| 14861 | 49 """Quote command-line arguments for DOS/Windows conventions: just |
| 50 wraps every argument which contains blanks in double quotes, and | |
| 51 returns a new argument list. | |
| 52 """ | |
|
11933
68e0ef052815
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
53 |
|
68e0ef052815
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
54 # XXX this doesn't seem very robust to me -- but if the Windows guys |
|
68e0ef052815
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
55 # say it'll work, I guess I'll have to accept it. (What if an arg |
|
68e0ef052815
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
56 # contains quotes? What other magic characters, other than spaces, |
|
68e0ef052815
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
57 # have to be escaped? Is there an escaping mechanism other than |
|
68e0ef052815
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
58 # quoting?) |
|
68e0ef052815
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
59 |
| 14861 | 60 for i in range(len(args)): |
| 61 if string.find(args[i], ' ') != -1: | |
|
11933
68e0ef052815
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
62 args[i] = '"%s"' % args[i] |
|
12058
c6cb0d266839
Duh, it helps if '_nt_quote_args()' actually returns the mutated list,
Greg Ward <gward@python.net>
parents:
12043
diff
changeset
|
63 return args |
|
11933
68e0ef052815
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
64 |
|
68e0ef052815
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
65 def _spawn_nt (cmd, |
|
68e0ef052815
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
66 search_path=1, |
|
68e0ef052815
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
67 verbose=0, |
|
68e0ef052815
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
68 dry_run=0): |
|
68e0ef052815
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
69 |
|
11250
b3f1abd3027f
Patch from Perry Stoll: support for Windows.
Greg Ward <gward@python.net>
parents:
11198
diff
changeset
|
70 executable = cmd[0] |
| 14861 | 71 cmd = _nt_quote_args(cmd) |
|
11250
b3f1abd3027f
Patch from Perry Stoll: support for Windows.
Greg Ward <gward@python.net>
parents:
11198
diff
changeset
|
72 if search_path: |
|
13803
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
73 # either we find one or it stays the same |
| 21267 | 74 executable = find_executable(executable) or executable |
|
11250
b3f1abd3027f
Patch from Perry Stoll: support for Windows.
Greg Ward <gward@python.net>
parents:
11198
diff
changeset
|
75 if verbose: |
| 14861 | 76 print string.join([executable] + cmd[1:], ' ') |
|
11250
b3f1abd3027f
Patch from Perry Stoll: support for Windows.
Greg Ward <gward@python.net>
parents:
11198
diff
changeset
|
77 if not dry_run: |
|
b3f1abd3027f
Patch from Perry Stoll: support for Windows.
Greg Ward <gward@python.net>
parents:
11198
diff
changeset
|
78 # spawn for NT requires a full path to the .exe |
|
11665
e998b350a4bb
Catch OSError from 'spawnv()' in '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
11257
diff
changeset
|
79 try: |
| 14861 | 80 rc = os.spawnv(os.P_WAIT, executable, cmd) |
|
11665
e998b350a4bb
Catch OSError from 'spawnv()' in '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
11257
diff
changeset
|
81 except OSError, exc: |
|
e998b350a4bb
Catch OSError from 'spawnv()' in '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
11257
diff
changeset
|
82 # this seems to happen when the command isn't found |
|
e998b350a4bb
Catch OSError from 'spawnv()' in '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
11257
diff
changeset
|
83 raise DistutilsExecError, \ |
|
e998b350a4bb
Catch OSError from 'spawnv()' in '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
11257
diff
changeset
|
84 "command '%s' failed: %s" % (cmd[0], exc[-1]) |
|
11250
b3f1abd3027f
Patch from Perry Stoll: support for Windows.
Greg Ward <gward@python.net>
parents:
11198
diff
changeset
|
85 if rc != 0: |
|
11665
e998b350a4bb
Catch OSError from 'spawnv()' in '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
11257
diff
changeset
|
86 # and this reflects the command running but failing |
|
e998b350a4bb
Catch OSError from 'spawnv()' in '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
11257
diff
changeset
|
87 raise DistutilsExecError, \ |
|
e998b350a4bb
Catch OSError from 'spawnv()' in '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
11257
diff
changeset
|
88 "command '%s' failed with exit status %d" % (cmd[0], rc) |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
89 |
| 21267 | 90 |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
91 def _spawn_posix (cmd, |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
92 search_path=1, |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
93 verbose=0, |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
94 dry_run=0): |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
95 |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
96 if verbose: |
| 14861 | 97 print string.join(cmd, ' ') |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
98 if dry_run: |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
99 return |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
100 exec_fn = search_path and os.execvp or os.execv |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
101 |
| 14861 | 102 pid = os.fork() |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
103 |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
104 if pid == 0: # in the child |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
105 try: |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
106 #print "cmd[0] =", cmd[0] |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
107 #print "cmd =", cmd |
| 14861 | 108 exec_fn(cmd[0], cmd) |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
109 except OSError, e: |
| 14861 | 110 sys.stderr.write("unable to execute %s: %s\n" % |
| 111 (cmd[0], e.strerror)) | |
| 112 os._exit(1) | |
| 21267 | 113 |
| 14861 | 114 sys.stderr.write("unable to execute %s for unknown reasons" % cmd[0]) |
| 115 os._exit(1) | |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
116 |
| 21267 | 117 |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
118 else: # in the parent |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
119 # Loop until the child either exits or is terminated by a signal |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
120 # (ie. keep waiting if it's merely stopped) |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
121 while 1: |
| 14861 | 122 (pid, status) = os.waitpid(pid, 0) |
| 123 if os.WIFSIGNALED(status): | |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
124 raise DistutilsExecError, \ |
|
11665
e998b350a4bb
Catch OSError from 'spawnv()' in '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
11257
diff
changeset
|
125 "command '%s' terminated by signal %d" % \ |
| 14861 | 126 (cmd[0], os.WTERMSIG(status)) |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
127 |
| 14861 | 128 elif os.WIFEXITED(status): |
| 129 exit_status = os.WEXITSTATUS(status) | |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
130 if exit_status == 0: |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
131 return # hey, it succeeded! |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
132 else: |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
133 raise DistutilsExecError, \ |
|
11665
e998b350a4bb
Catch OSError from 'spawnv()' in '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
11257
diff
changeset
|
134 "command '%s' failed with exit status %d" % \ |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
135 (cmd[0], exit_status) |
| 21267 | 136 |
| 14861 | 137 elif os.WIFSTOPPED(status): |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
138 continue |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
139 |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
140 else: |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
141 raise DistutilsExecError, \ |
|
11665
e998b350a4bb
Catch OSError from 'spawnv()' in '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
11257
diff
changeset
|
142 "unknown error executing '%s': termination status %d" % \ |
|
11198
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
143 (cmd[0], status) |
|
e8b24cd17df2
Module to spawn sub-commands in a platform-independent way.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
144 # _spawn_posix () |
|
13803
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
145 |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
146 |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
147 def find_executable(executable, path=None): |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
148 """Try to find 'executable' in the directories listed in 'path' (a |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
149 string listing directories separated by 'os.pathsep'; defaults to |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
150 os.environ['PATH']). Returns the complete filename or None if not |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
151 found. |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
152 """ |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
153 if path is None: |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
154 path = os.environ['PATH'] |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
155 paths = string.split(path, os.pathsep) |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
156 (base, ext) = os.path.splitext(executable) |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
157 if (sys.platform == 'win32') and (ext != '.exe'): |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
158 executable = executable + '.exe' |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
159 if not os.path.isfile(executable): |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
160 for p in paths: |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
161 f = os.path.join(p, executable) |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
162 if os.path.isfile(f): |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
163 # the file exists, we have a shot at spawn working |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
164 return f |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
165 return None |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
166 else: |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
167 return executable |
|
e8b22bc88d95
Rene Liebscher: factor 'find_executable()' out of '_spawn_nt()'.
Greg Ward <gward@python.net>
parents:
12058
diff
changeset
|
168 |
| 21267 | 169 # find_executable() |
