Tue, 02 Mar 2021 17:17:09 +0100
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
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 | |
7923
91e843545d9a
Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7906
diff
changeset
|
3 | # Copyright (c) 2020 - 2021 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 | |
7424
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
13 | from DebugUtilities import isPythonProgram, startsWithShebang, patchArguments |
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. |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
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 |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | """ # __IGNORE_WARNING_D234__ |
7409
1413bfe73d41
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7407
diff
changeset
|
27 | global _debugClient |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | |
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 | """ |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
33 | _origQProcessStartDetached = module.QProcess.startDetached |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
34 | |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | def __init__(self, parent=None): |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | """ |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | Constructor |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | """ |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | super(QProcessWrapper, self).__init__(parent) |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
41 | ################################################################### |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
42 | ## Handling of 'start(...)' below |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
43 | ################################################################### |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
44 | |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | def start(self, *args, **kwargs): |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | """ |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | Public method to start the process. |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | 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
|
50 | 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
|
51 | program to be started contains the string 'python'. |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | @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
|
54 | @type list |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | @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
|
56 | @type dict |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | """ |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | if ( |
7409
1413bfe73d41
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7407
diff
changeset
|
59 | _debugClient.debugging and |
1413bfe73d41
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7407
diff
changeset
|
60 | _debugClient.multiprocessSupport and |
1413bfe73d41
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7407
diff
changeset
|
61 | ((len(args) >= 2 and isinstance(args[1], list)) or |
1413bfe73d41
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7407
diff
changeset
|
62 | (len(args) == 1 and not isinstance(args[0], str)) or |
1413bfe73d41
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7407
diff
changeset
|
63 | len(args) == 0) |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | ): |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | if len(args) >= 2: |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | program = args[0] |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | arguments = args[1] |
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 | mode = args[2] |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | 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
|
71 | 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
|
72 | else: |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | program = self.program() |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | arguments = self.arguments() |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | if len(args) == 1: |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | mode = args[0] |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | 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
|
78 | mode = module.QIODevice.OpenModeFlag.ReadWrite |
7419
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
79 | ok = isPythonProgram(program) |
7424
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
80 | if ok: |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
81 | if startsWithShebang(program): |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
82 | 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
|
83 | else: |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
84 | 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
|
85 | 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
|
86 | newArgs = patchArguments( |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
87 | _debugClient, |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
88 | [program] + arguments, |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
89 | ) |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
90 | super(QProcessWrapper, self).start( |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
91 | newArgs[0], newArgs[1:], mode) |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
92 | return |
7419
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
93 | |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
94 | super(QProcessWrapper, self).start(*args, **kwargs) |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
95 | |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
96 | ################################################################### |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
97 | ## Handling of 'startDetached(...)' below |
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 | |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
100 | 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
|
101 | """ |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
102 | Public method to start the detached process. |
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 | 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
|
105 | 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
|
106 | program to be started contains the string 'python'. |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
107 | |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
108 | @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
|
109 | @type list |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
110 | @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
|
111 | @type dict |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
112 | @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
|
113 | @rtype bool |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
114 | """ |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
115 | if isinstance(self, str): |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
116 | return QProcessWrapper.startDetachedStatic( |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
117 | self, *args) |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
118 | else: |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
119 | return self.__startDetached(*args, **kwargs) |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
120 | |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
121 | 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
|
122 | """ |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
123 | Private method to start the detached process. |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
124 | |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
125 | 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
|
126 | 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
|
127 | program to be started contains the string 'python'. |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
128 | |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
129 | @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
|
130 | @type list |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
131 | @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
|
132 | @type dict |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
133 | @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
|
134 | @rtype bool |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
135 | """ |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
136 | if ( |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
137 | _debugClient.debugging and |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
138 | _debugClient.multiprocessSupport and |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
139 | len(args) == 0 |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
140 | ): |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
141 | program = self.program() |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
142 | arguments = self.arguments() |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
143 | wd = self.workingDirectory() |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
144 | |
7419
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
145 | ok = isPythonProgram(program) |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
146 | if ok: |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
147 | return QProcessWrapper.startDetachedStatic( |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
148 | program, arguments, wd) |
7419
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
149 | |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
150 | return super(QProcessWrapper, self).startDetached(*args, **kwargs) |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
151 | |
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. |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
156 | |
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'. |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
160 | |
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 ( |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
169 | _debugClient.debugging and |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
170 | _debugClient.multiprocessSupport and |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
171 | (len(args) >= 2 and isinstance(args[1], list)) |
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( |
9bb7d8b0f966
Implemented multi process debugging support for the 'subprocess' module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7419
diff
changeset
|
191 | newArgs[0], newArgs[1:], wd) |
7419
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
192 | |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
193 | return QProcessWrapper._origQProcessStartDetached( |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
194 | *args, **kwargs) |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
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 |