35 """ |
35 """ |
36 super(EricapiExecDialog, self).__init__(parent) |
36 super(EricapiExecDialog, self).__init__(parent) |
37 self.setModal(True) |
37 self.setModal(True) |
38 self.setupUi(self) |
38 self.setupUi(self) |
39 |
39 |
40 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
40 self.buttonBox.button( |
41 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
41 QDialogButtonBox.StandardButton.Close).setEnabled(False) |
|
42 self.buttonBox.button( |
|
43 QDialogButtonBox.StandardButton.Cancel).setDefault(True) |
42 |
44 |
43 self.process = None |
45 self.process = None |
44 self.cmdname = cmdname |
46 self.cmdname = cmdname |
45 |
47 |
46 def start(self, args, fn): |
48 def start(self, args, fn): |
97 """ |
99 """ |
98 Private slot called by a button of the button box clicked. |
100 Private slot called by a button of the button box clicked. |
99 |
101 |
100 @param button button that was clicked (QAbstractButton) |
102 @param button button that was clicked (QAbstractButton) |
101 """ |
103 """ |
102 if button == self.buttonBox.button(QDialogButtonBox.Close): |
104 if button == self.buttonBox.button( |
|
105 QDialogButtonBox.StandardButton.Close |
|
106 ): |
103 self.accept() |
107 self.accept() |
104 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): |
108 elif button == self.buttonBox.button( |
|
109 QDialogButtonBox.StandardButton.Cancel |
|
110 ): |
105 self.__finish() |
111 self.__finish() |
106 |
112 |
107 def __finish(self): |
113 def __finish(self): |
108 """ |
114 """ |
109 Private slot called when the process finished. |
115 Private slot called when the process finished. |
111 It is called when the process finished or |
117 It is called when the process finished or |
112 the user pressed the button. |
118 the user pressed the button. |
113 """ |
119 """ |
114 if ( |
120 if ( |
115 self.process is not None and |
121 self.process is not None and |
116 self.process.state() != QProcess.NotRunning |
122 self.process.state() != QProcess.ProcessState.NotRunning |
117 ): |
123 ): |
118 self.process.terminate() |
124 self.process.terminate() |
119 QTimer.singleShot(2000, self.process.kill) |
125 QTimer.singleShot(2000, self.process.kill) |
120 self.process.waitForFinished(3000) |
126 self.process.waitForFinished(3000) |
121 |
127 |
122 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
128 self.buttonBox.button( |
123 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
129 QDialogButtonBox.StandardButton.Close).setEnabled(True) |
124 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
130 self.buttonBox.button( |
|
131 QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
|
132 self.buttonBox.button( |
|
133 QDialogButtonBox.StandardButton.Close).setDefault(True) |
125 |
134 |
126 self.process = None |
135 self.process = None |
127 |
136 |
128 self.contents.insertPlainText( |
137 self.contents.insertPlainText( |
129 self.tr('\n{0} finished.\n').format(self.cmdname)) |
138 self.tr('\n{0} finished.\n').format(self.cmdname)) |
134 Private slot to handle the readyReadStandardOutput signal. |
143 Private slot to handle the readyReadStandardOutput signal. |
135 |
144 |
136 It reads the output of the process, formats it and inserts it into |
145 It reads the output of the process, formats it and inserts it into |
137 the contents pane. |
146 the contents pane. |
138 """ |
147 """ |
139 self.process.setReadChannel(QProcess.StandardOutput) |
148 self.process.setReadChannel(QProcess.ProcessChannel.StandardOutput) |
140 |
149 |
141 while self.process.canReadLine(): |
150 while self.process.canReadLine(): |
142 s = str(self.process.readLine(), |
151 s = str(self.process.readLine(), |
143 Preferences.getSystem("IOEncoding"), |
152 Preferences.getSystem("IOEncoding"), |
144 'replace') |
153 'replace') |
150 Private slot to handle the readyReadStandardError signal. |
159 Private slot to handle the readyReadStandardError signal. |
151 |
160 |
152 It reads the error output of the process and inserts it into the |
161 It reads the error output of the process and inserts it into the |
153 error pane. |
162 error pane. |
154 """ |
163 """ |
155 self.process.setReadChannel(QProcess.StandardError) |
164 self.process.setReadChannel(QProcess.ProcessChannel.StandardError) |
156 |
165 |
157 while self.process.canReadLine(): |
166 while self.process.canReadLine(): |
158 self.errorGroup.show() |
167 self.errorGroup.show() |
159 s = str(self.process.readLine(), |
168 s = str(self.process.readLine(), |
160 Preferences.getSystem("IOEncoding"), |
169 Preferences.getSystem("IOEncoding"), |