Sat, 15 Feb 2020 20:00:22 +0100
Continued with the multiprocess debugger.
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 | |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
3 | # Copyright (c) 2020 Detlev Offenbach <detlev@die-offenbachs.de> |
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 | |
7412
0a995393d2ba
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7411
diff
changeset
|
13 | from DebugUtilities import isPythonProgram, 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 | |
7412
0a995393d2ba
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7411
diff
changeset
|
29 | # TODO: implement a process tracer |
0a995393d2ba
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7411
diff
changeset
|
30 | # i.e. report which processes are started |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | class QProcessWrapper(module.QProcess): |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | """ |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | Wrapper class for *.QProcess. |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | """ |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
35 | _origQProcessStartDetached = module.QProcess.startDetached |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
36 | |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | def __init__(self, parent=None): |
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 | Constructor |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | """ |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | super(QProcessWrapper, self).__init__(parent) |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | |
7410
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 | ## Handling of 'start(...)' below |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
45 | ################################################################### |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
46 | |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | def start(self, *args, **kwargs): |
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 | 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
|
50 | |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | 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
|
52 | 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
|
53 | 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
|
54 | |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | @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
|
56 | @type list |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | @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
|
58 | @type dict |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | """ |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | if ( |
7409
1413bfe73d41
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7407
diff
changeset
|
61 | _debugClient.debugging and |
1413bfe73d41
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7407
diff
changeset
|
62 | _debugClient.multiprocessSupport and |
1413bfe73d41
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7407
diff
changeset
|
63 | ((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
|
64 | (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
|
65 | len(args) == 0) |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | ): |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | if len(args) >= 2: |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | program = args[0] |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | arguments = args[1] |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | if len(args) > 2: |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | mode = args[2] |
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 | mode = module.QIODevice.ReadWrite |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | else: |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | program = self.program() |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | arguments = self.arguments() |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | if len(args) == 1: |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | mode = args[0] |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | else: |
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | mode = module.QIODevice.ReadWrite |
7419
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
81 | ok = isPythonProgram(program) |
7411
6d8dcb3551b3
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7410
diff
changeset
|
82 | if ( |
6d8dcb3551b3
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7410
diff
changeset
|
83 | ok and ( |
6d8dcb3551b3
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7410
diff
changeset
|
84 | not os.path.basename(arguments[0]) |
6d8dcb3551b3
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7410
diff
changeset
|
85 | in _debugClient.noDebugList |
6d8dcb3551b3
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7410
diff
changeset
|
86 | ) |
6d8dcb3551b3
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7410
diff
changeset
|
87 | ): |
7412
0a995393d2ba
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7411
diff
changeset
|
88 | newArgs = patchArguments( |
7419
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
89 | _debugClient, |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
90 | [program] + arguments, |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
91 | ) |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
92 | super(QProcessWrapper, self).start( |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
93 | newArgs[0], newArgs[1:], mode) |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
94 | return |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
95 | |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
96 | 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
|
97 | |
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 | ################################################################### |
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 | 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. |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
105 | |
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'. |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
109 | |
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): |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
118 | return QProcessWrapper.startDetachedStatic( |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
119 | self, *args) |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
120 | else: |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
121 | 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
|
122 | |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
123 | 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
|
124 | """ |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
125 | 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
|
126 | |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
127 | 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
|
128 | 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
|
129 | 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
|
130 | |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
131 | @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
|
132 | @type list |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
133 | @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
|
134 | @type dict |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
135 | @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
|
136 | @rtype bool |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
137 | """ |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
138 | if ( |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
139 | _debugClient.debugging and |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
140 | _debugClient.multiprocessSupport and |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
141 | len(args) == 0 |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
142 | ): |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
143 | program = self.program() |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
144 | arguments = self.arguments() |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
145 | wd = self.workingDirectory() |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
146 | |
7419
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
147 | ok = isPythonProgram(program) |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
148 | if ok: |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
149 | return QProcessWrapper.startDetachedStatic( |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
150 | program, arguments, wd) |
7419
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
151 | |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
152 | 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
|
153 | |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
154 | @staticmethod |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
155 | def startDetachedStatic(*args, **kwargs): |
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 | 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
|
158 | |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
159 | 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
|
160 | 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
|
161 | 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
|
162 | |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
163 | @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
|
164 | @type list |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
165 | @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
|
166 | @type dict |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
167 | @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
|
168 | @rtype bool |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
169 | """ |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
170 | if ( |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
171 | _debugClient.debugging and |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
172 | _debugClient.multiprocessSupport and |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
173 | (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
|
174 | ): |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
175 | program = args[0] |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
176 | arguments = args[1] |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
177 | if len(args) >= 3: |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
178 | wd = args[2] |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
179 | else: |
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
180 | wd = "" |
7419
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
181 | ok = isPythonProgram(program) |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
182 | if ok: |
7412
0a995393d2ba
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7411
diff
changeset
|
183 | newArgs = patchArguments( |
7419
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
184 | _debugClient, |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
185 | [program] + arguments, |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
186 | ) |
7410
401791e6f50f
Continued with the multiprocess debugger. Implemented QProcess.startDetached() wrapper.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7409
diff
changeset
|
187 | return QProcessWrapper._origQProcessStartDetached( |
7419
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
188 | newArgs[0], newArgs[1:], wd) |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
189 | |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
190 | return QProcessWrapper._origQProcessStartDetached( |
9c1163735448
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7412
diff
changeset
|
191 | *args, **kwargs) |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | |
7409
1413bfe73d41
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7407
diff
changeset
|
193 | _debugClient = debugClient |
7407
a0b6acee2c20
Continued with the multiprocess debugger. Started with QProcess support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | module.QProcess = QProcessWrapper |