src/eric7/DebugClients/Python/SubprocessExtension.py

branch
eric7
changeset 11088
0299c9ba1c6f
parent 10633
dda7e43934dc
child 11090
f5f5f5803935
equal deleted inserted replaced
11087:8f5d1b5e16c9 11088:0299c9ba1c6f
8 of the process. 8 of the process.
9 """ 9 """
10 10
11 import os 11 import os
12 import shlex 12 import shlex
13 import shutil
13 14
14 from DebugUtilities import ( 15 from DebugUtilities import (
15 isPythonProgram, 16 isPythonProgram,
16 isWindowsPlatform, 17 isWindowsPlatform,
17 patchArguments, 18 patchArguments,
53 and _debugClient.multiprocessSupport 54 and _debugClient.multiprocessSupport
54 and isinstance(args, (str, list)) 55 and isinstance(args, (str, list))
55 ): 56 ):
56 if isinstance(args, str): 57 if isinstance(args, str):
57 # convert to arguments list 58 # convert to arguments list
58 args = ( 59 args_list = (
59 stringToArgumentsWindows(args) 60 stringToArgumentsWindows(args)
60 if isWindowsPlatform() 61 if isWindowsPlatform()
61 else shlex.split(args) 62 else shlex.split(args)
62 ) 63 )
63 else: 64 else:
64 # create a copy of the arguments 65 # create a copy of the arguments
65 args = args[:] 66 args_list = args[:]
66 ok = isPythonProgram(args[0]) 67 isPythonProg = isPythonProgram(
67 if ok: 68 args_list[0],
68 scriptName = os.path.basename(args[0]) 69 withPath="shell" in kwargs and kwargs["shell"] is True,
70 )
71 if isPythonProg:
72 scriptName = os.path.basename(args_list[0])
69 if not _debugClient.skipMultiProcessDebugging(scriptName): 73 if not _debugClient.skipMultiProcessDebugging(scriptName):
70 args = patchArguments(_debugClient, args, noRedirect=True) 74 if (
71 if "shell" in kwargs and kwargs["shell"] is True: 75 "shell" in kwargs
72 # shell=True interferes with eric debugger 76 and kwargs["shell"] is True
73 kwargs["shell"] = False 77 and not os.path.isabs(args_list[0])
78 ):
79 prog = shutil.which(args_list[0])
80 if prog:
81 args_list[0] = prog
82 args = patchArguments(
83 _debugClient,
84 args_list,
85 noRedirect=True,
86 isPythonProg=isPythonProg,
87 )
88 if "shell" in kwargs and kwargs["shell"] is True:
89 args = shlex.join(args)
74 90
75 super().__init__(args, *popenargs, **kwargs) 91 super().__init__(args, *popenargs, **kwargs)
76 92
77 _debugClient = debugClient 93 _debugClient = debugClient
78 module.Popen = PopenWrapper 94 module.Popen = PopenWrapper

eric ide

mercurial