Mon, 24 Feb 2025 15:43:49 +0100
Adjusted the code to the modified issue codes.
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
11090
f5f5f5803935
Updated copyright for 2025.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
3 | # Copyright (c) 2020 - 2025 Detlev Offenbach <detlev@die-offenbachs.de> |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a function to patch QProcess to support debugging of the |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | process. |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | """ |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | import os |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
13 | from DebugUtilities import isPythonProgram, patchArguments, startsWithShebang |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
7412
0a995393d2ba
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7411
diff
changeset
|
15 | _debugClient = None |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
16 | |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
17 | |
7409
1413bfe73d41
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7407
diff
changeset
|
18 | def patchQProcess(module, debugClient): |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | """ |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | Function to patch the QtCore module's QProcess. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
21 | |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | @param module reference to the imported module to be patched |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | @type module |
7409
1413bfe73d41
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7407
diff
changeset
|
24 | @param debugClient reference to the debug client object |
1413bfe73d41
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7407
diff
changeset
|
25 | @type DebugClient |
11148
15e30f0c76a8
Adjusted the code to the modified issue codes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
11090
diff
changeset
|
26 | """ # __IGNORE_WARNING_D-234__ |
7409
1413bfe73d41
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7407
diff
changeset
|
27 | global _debugClient |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
28 | |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | class QProcessWrapper(module.QProcess): |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | """ |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | Wrapper class for *.QProcess. |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
33 | |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
34 | _origQProcessStartDetached = module.QProcess.startDetached |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
35 | |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | def __init__(self, parent=None): |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | """ |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | Constructor |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
40 | super().__init__(parent) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
41 | |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
42 | ################################################################### |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
43 | ## Handling of 'start(...)' below |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
44 | ################################################################### |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
45 | |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | def start(self, *args, **kwargs): |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | """ |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | Public method to start the process. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
49 | |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | This method patches the arguments such, that a debug client is |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | started for the Python script. A Python script is assumed, if the |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | program to be started contains the string 'python'. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
53 | |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | @param args arguments of the start call |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | @type list |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | @param kwargs keyword arguments of the start call |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | @type dict |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | """ |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | if ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
60 | _debugClient.debugging |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
61 | and _debugClient.multiprocessSupport |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
62 | and ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
63 | (len(args) >= 2 and isinstance(args[1], list)) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
64 | or (len(args) == 1 and not isinstance(args[0], str)) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
65 | or len(args) == 0 |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
66 | ) |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | ): |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | if len(args) >= 2: |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | program = args[0] |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | arguments = args[1] |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | if len(args) > 2: |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | mode = args[2] |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | else: |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
74 | mode = module.QIODevice.OpenModeFlag.ReadWrite |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | else: |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | program = self.program() |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | arguments = self.arguments() |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | if len(args) == 1: |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | mode = args[0] |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | else: |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
81 | mode = module.QIODevice.OpenModeFlag.ReadWrite |
7419
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
82 | ok = isPythonProgram(program) |
7424
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
83 | if ok: |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
84 | if startsWithShebang(program): |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
85 | scriptName = os.path.basename(program) |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
86 | else: |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
87 | scriptName = os.path.basename(arguments[0]) |
7901
6ff7ccf0cb50
Debugger: refined the handling of not to be debugged scripts for multiprocess debugging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7424
diff
changeset
|
88 | if not _debugClient.skipMultiProcessDebugging(scriptName): |
7424
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
89 | newArgs = patchArguments( |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
90 | _debugClient, |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
91 | [program] + arguments, |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
92 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
93 | super().start(newArgs[0], newArgs[1:], mode) |
7424
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
94 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
95 | |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
96 | super().start(*args, **kwargs) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
97 | |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
98 | ################################################################### |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
99 | ## Handling of 'startDetached(...)' below |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
100 | ################################################################### |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
101 | |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
102 | def startDetached(self, *args, **kwargs): |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
103 | """ |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
104 | Public method to start the detached process. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
105 | |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
106 | This method patches the arguments such, that a debug client is |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
107 | started for the Python script. A Python script is assumed, if the |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
108 | program to be started contains the string 'python'. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
109 | |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
110 | @param args arguments of the start call |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
111 | @type list |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
112 | @param kwargs keyword arguments of the start call |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
113 | @type dict |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
114 | @return flag indicating a successful start |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
115 | @rtype bool |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
116 | """ |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
117 | if isinstance(self, str): |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
118 | return QProcessWrapper.startDetachedStatic(self, *args) |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
119 | else: |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
120 | return self.__startDetached(*args, **kwargs) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
121 | |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
122 | def __startDetached(self, *args, **kwargs): |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
123 | """ |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
124 | Private method to start the detached process. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
125 | |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
126 | This method patches the arguments such, that a debug client is |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
127 | started for the Python script. A Python script is assumed, if the |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
128 | program to be started contains the string 'python'. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
129 | |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
130 | @param args arguments of the start call |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
131 | @type list |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
132 | @param kwargs keyword arguments of the start call |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
133 | @type dict |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
134 | @return flag indicating a successful start |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
135 | @rtype bool |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
136 | """ |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
137 | if ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
138 | _debugClient.debugging |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
139 | and _debugClient.multiprocessSupport |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
140 | and len(args) == 0 |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
141 | ): |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
142 | program = self.program() |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
143 | arguments = self.arguments() |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
144 | wd = self.workingDirectory() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
145 | |
7419
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
146 | ok = isPythonProgram(program) |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
147 | if ok: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
148 | return QProcessWrapper.startDetachedStatic(program, arguments, wd) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
149 | |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
150 | return super().startDetached(*args, **kwargs) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
151 | |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
152 | @staticmethod |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
153 | def startDetachedStatic(*args, **kwargs): |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
154 | """ |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
155 | Static method to start the detached process. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
156 | |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
157 | This method patches the arguments such, that a debug client is |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
158 | started for the Python script. A Python script is assumed, if the |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
159 | program to be started contains the string 'python'. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
160 | |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
161 | @param args arguments of the start call |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
162 | @type list |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
163 | @param kwargs keyword arguments of the start call |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
164 | @type dict |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
165 | @return flag indicating a successful start |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
166 | @rtype bool |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
167 | """ |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
168 | if ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
169 | _debugClient.debugging |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
170 | and _debugClient.multiprocessSupport |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
171 | and (len(args) >= 2 and isinstance(args[1], list)) |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
172 | ): |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
173 | program = args[0] |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
174 | arguments = args[1] |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
175 | if len(args) >= 3: |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
176 | wd = args[2] |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
177 | else: |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
178 | wd = "" |
7419
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
179 | ok = isPythonProgram(program) |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
180 | if ok: |
7424
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
181 | if startsWithShebang(program): |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
182 | scriptName = os.path.basename(program) |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
183 | else: |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
184 | scriptName = os.path.basename(arguments[0]) |
7901
6ff7ccf0cb50
Debugger: refined the handling of not to be debugged scripts for multiprocess debugging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7424
diff
changeset
|
185 | if not _debugClient.skipMultiProcessDebugging(scriptName): |
7424
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
186 | newArgs = patchArguments( |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
187 | _debugClient, |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
188 | [program] + arguments, |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
189 | ) |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
190 | return QProcessWrapper._origQProcessStartDetached( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
191 | newArgs[0], newArgs[1:], wd |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
192 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
193 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
194 | return QProcessWrapper._origQProcessStartDetached(*args, **kwargs) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
195 | |
7409
1413bfe73d41
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7407
diff
changeset
|
196 | _debugClient = debugClient |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | module.QProcess = QProcessWrapper |