eric6/DebugClients/Python/DebugUtilities.py

branch
multi_processing
changeset 7873
cb2badbdf26c
parent 7871
eb65864ca038
child 7892
bd6b9e401166
equal deleted inserted replaced
7872:433dacbfa456 7873:cb2badbdf26c
192 for line in f: 192 for line in f:
193 line = line.strip() 193 line = line.strip()
194 if line: 194 if line:
195 for name in PYTHON_NAMES: 195 for name in PYTHON_NAMES:
196 if line.startswith('#!/usr/bin/env {0}'.format(name)): 196 if line.startswith('#!/usr/bin/env {0}'.format(name)):
197 return True
198 elif line.startswith('#!') and name in line:
197 return True 199 return True
198 return False 200 return False
199 except UnicodeDecodeError: 201 except UnicodeDecodeError:
200 return False 202 return False
201 except Exception: 203 except Exception:
285 @param noRedirect flag indicating to not redirect stdin and stdout 287 @param noRedirect flag indicating to not redirect stdin and stdout
286 @type bool 288 @type bool
287 @return modified argument list 289 @return modified argument list
288 @rtype list of str 290 @rtype list of str
289 """ 291 """
292 debugClientScript = os.path.join(
293 os.path.dirname(__file__), "DebugClient.py")
294 if debugClientScript in arguments:
295 # it is already patched
296 return arguments
297
290 args = list(arguments[:]) # create a copy of the arguments list 298 args = list(arguments[:]) # create a copy of the arguments list
291 args = removeQuotesFromArgs(args) 299 args = removeQuotesFromArgs(args)
292 300
293 # support for shebang line 301 # support for shebang line
294 program = os.path.basename(args[0]).lower() 302 program = os.path.basename(args[0]).lower()
296 if pyname in program: 304 if pyname in program:
297 break 305 break
298 else: 306 else:
299 if not isWindowsPlatform() and startsWithShebang(args[0]): 307 if not isWindowsPlatform() and startsWithShebang(args[0]):
300 # insert our interpreter as first argument 308 # insert our interpreter as first argument
309 args.insert(0, sys.executable)
310 elif isWindowsPlatform() and args[0].lower().endswith(".py"):
311 # it is a Python script; insert our interpreter as first argument
301 args.insert(0, sys.executable) 312 args.insert(0, sys.executable)
302 313
303 # check for -m invocation => debugging not supported yet 314 # check for -m invocation => debugging not supported yet
304 if "-m" in args: 315 if "-m" in args:
305 cm_position = args.index("-m") 316 cm_position = args.index("-m")
344 ) = debugClient.startOptions[:7] 355 ) = debugClient.startOptions[:7]
345 356
346 modifiedArguments = [interpreter] 357 modifiedArguments = [interpreter]
347 modifiedArguments.extend(interpreterArgs) 358 modifiedArguments.extend(interpreterArgs)
348 modifiedArguments.extend([ 359 modifiedArguments.extend([
349 os.path.join(os.path.dirname(__file__), "DebugClient.py"), 360 debugClientScript,
350 "-h", host, 361 "-h", host,
351 "-p", str(port), 362 "-p", str(port),
352 "--no-passive", 363 "--no-passive",
353 ]) 364 ])
354 365

eric ide

mercurial