eric6/DebugClients/Python/DebugUtilities.py

branch
multi_processing
changeset 7412
0a995393d2ba
parent 7360
9190402e4505
child 7419
9c1163735448
equal deleted inserted replaced
7411:6d8dcb3551b3 7412:0a995393d2ba
6 """ 6 """
7 Module implementing utilities functions for the debug client. 7 Module implementing utilities functions for the debug client.
8 """ 8 """
9 9
10 import json 10 import json
11 import os
11 12
12 # 13 #
13 # Taken from inspect.py of Python 3.4 14 # Taken from inspect.py of Python 3.4
14 # 15 #
15 16
143 "method": method, 144 "method": method,
144 "params": params, 145 "params": params,
145 } 146 }
146 return json.dumps(commandDict) + '\n' 147 return json.dumps(commandDict) + '\n'
147 148
149
150 def isPythonProgram(program, arguments):
151 """
152 Function to check, if program is a Python interpreter and
153 arguments don't include '-m'.
154
155 @param program program to be executed
156 @type str
157 @param arguments list of command line arguments
158 @type list of str
159 @return flag indicating a python program and a tuple containing the
160 interpreter to be used and the arguments
161 @rtype tuple of (bool, tuple of (str, list of str))
162 """
163 prog = program.lower()
164 ok = (
165 ("python" in prog and arguments[0] != '-m') or
166 "pypy" in prog
167 )
168 return ok, (program, arguments[:])
169
170
171 def patchArguments(debugClient, arguments, multiprocessSupport,
172 noRedirect=False):
173 """
174 Function to patch the arguments given to start a program in order to
175 execute it in our debugger.
176
177 @param debugClient reference to the debug client object
178 @type DebugClient
179 @param arguments list of program arguments
180 @type list of str
181 @param multiprocessSupport flag indicating multi process debug support
182 @type bool
183 @param noRedirect flag indicating to not redirect stdin and stdout
184 @type bool
185 @return modified argument list
186 @rtype list of str
187 """
188 (wd, host, port, exceptions, tracePython, redirect, noencoding
189 ) = debugClient.startOptions[:7]
190
191 modifiedArguments = [
192 os.path.join(os.path.dirname(__file__), "DebugClient.py"),
193 "-h", host,
194 "-p", str(port),
195 "--no-passive",
196 ]
197
198 if wd:
199 modifiedArguments.extend(["-w", wd])
200 if not exceptions:
201 modifiedArguments.append("-e")
202 if tracePython:
203 modifiedArguments.append("-t")
204 if noRedirect or not redirect:
205 modifiedArguments.append("-n")
206 if noencoding:
207 modifiedArguments.append("--no-encoding")
208 if multiprocessSupport:
209 modifiedArguments.append("--multiprocess")
210 modifiedArguments.append("--")
211 # end the arguments for DebugClient
212 modifiedArguments.extend(arguments)
213
214 return modifiedArguments
215
148 # 216 #
149 # eflag: noqa = M702 217 # eflag: noqa = M702

eric ide

mercurial