src/eric7/DebugClients/Python/SubprocessExtension.py

branch
eric7
changeset 10627
40b3df5b933a
parent 10439
21c28b0f9e41
child 10633
dda7e43934dc
equal deleted inserted replaced
10626:42c3c948aafa 10627:40b3df5b933a
35 class PopenWrapper(module.Popen): 35 class PopenWrapper(module.Popen):
36 """ 36 """
37 Wrapper class for subprocess.Popen. 37 Wrapper class for subprocess.Popen.
38 """ 38 """
39 39
40 def __init__(self, arguments, *args, **kwargs): 40 def __init__(self, args, *popenargs, **kwargs):
41 """ 41 """
42 Constructor 42 Constructor
43 43
44 @param arguments command line arguments for the new process 44 @param args command line arguments for the new process
45 @type list of str or str 45 @type list of str or str
46 @param args constructor arguments of Popen 46 @param popenargs constructor arguments of Popen
47 @type list 47 @type list
48 @param kwargs constructor keyword only arguments of Popen 48 @param kwargs constructor keyword only arguments of Popen
49 @type dict 49 @type dict
50 """ 50 """
51 if ( 51 if (
52 _debugClient.debugging 52 _debugClient.debugging
53 and _debugClient.multiprocessSupport 53 and _debugClient.multiprocessSupport
54 and isinstance(arguments, (str, list)) 54 and isinstance(args, (str, list))
55 ): 55 ):
56 if isinstance(arguments, str): 56 if isinstance(args, str):
57 # convert to arguments list 57 # convert to arguments list
58 arguments = ( 58 args = (
59 stringToArgumentsWindows(arguments) 59 stringToArgumentsWindows(args)
60 if isWindowsPlatform() 60 if isWindowsPlatform()
61 else shlex.split(arguments) 61 else shlex.split(args)
62 ) 62 )
63 else: 63 else:
64 # create a copy of the arguments 64 # create a copy of the arguments
65 arguments = arguments[:] 65 args = args[:]
66 ok = isPythonProgram(arguments[0]) 66 ok = isPythonProgram(args[0])
67 if ok: 67 if ok:
68 scriptName = os.path.basename(arguments[0]) 68 scriptName = os.path.basename(args[0])
69 if not _debugClient.skipMultiProcessDebugging(scriptName): 69 if not _debugClient.skipMultiProcessDebugging(scriptName):
70 arguments = patchArguments( 70 args = patchArguments(
71 _debugClient, arguments, noRedirect=True 71 _debugClient, args, noRedirect=True
72 ) 72 )
73 if "shell" in kwargs and kwargs["shell"] is True: 73 if "shell" in kwargs and kwargs["shell"] is True:
74 # shell=True interferes with eric debugger 74 # shell=True interferes with eric debugger
75 kwargs["shell"] = False 75 kwargs["shell"] = False
76 76
77 super().__init__(arguments, *args, **kwargs) 77 super().__init__(args, *popenargs, **kwargs)
78 78
79 _debugClient = debugClient 79 _debugClient = debugClient
80 module.Popen = PopenWrapper 80 module.Popen = PopenWrapper

eric ide

mercurial