eric6/VirtualEnv/VirtualenvExecDialog.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8176
31965986ecd1
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
40 @type QWidget 40 @type QWidget
41 """ 41 """
42 super(VirtualenvExecDialog, self).__init__(parent) 42 super(VirtualenvExecDialog, self).__init__(parent)
43 self.setupUi(self) 43 self.setupUi(self)
44 44
45 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 45 self.buttonBox.button(
46 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 46 QDialogButtonBox.StandardButton.Close).setEnabled(False)
47 self.buttonBox.button(
48 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
47 49
48 self.__pyvenv = configuration["envType"] == "pyvenv" 50 self.__pyvenv = configuration["envType"] == "pyvenv"
49 self.__targetDir = configuration["targetDirectory"] 51 self.__targetDir = configuration["targetDirectory"]
50 self.__openTarget = configuration["openTarget"] 52 self.__openTarget = configuration["openTarget"]
51 self.__createLog = configuration["createLog"] 53 self.__createLog = configuration["createLog"]
119 """ 121 """
120 Private slot called by a button of the button box clicked. 122 Private slot called by a button of the button box clicked.
121 123
122 @param button button that was clicked (QAbstractButton) 124 @param button button that was clicked (QAbstractButton)
123 """ 125 """
124 if button == self.buttonBox.button(QDialogButtonBox.Close): 126 if button == self.buttonBox.button(
127 QDialogButtonBox.StandardButton.Close
128 ):
125 self.accept() 129 self.accept()
126 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): 130 elif button == self.buttonBox.button(
131 QDialogButtonBox.StandardButton.Cancel
132 ):
127 self.__finish(0, 0, giveUp=True) 133 self.__finish(0, 0, giveUp=True)
128 134
129 def __finish(self, exitCode, exitStatus, giveUp=False): 135 def __finish(self, exitCode, exitStatus, giveUp=False):
130 """ 136 """
131 Private slot called when the process finished. 137 Private slot called when the process finished.
137 @param exitStatus exit status of the process (QProcess.ExitStatus) 143 @param exitStatus exit status of the process (QProcess.ExitStatus)
138 @param giveUp flag indicating to not start another attempt (boolean) 144 @param giveUp flag indicating to not start another attempt (boolean)
139 """ 145 """
140 if ( 146 if (
141 self.__process is not None and 147 self.__process is not None and
142 self.__process.state() != QProcess.NotRunning 148 self.__process.state() != QProcess.ProcessState.NotRunning
143 ): 149 ):
144 self.__process.terminate() 150 self.__process.terminate()
145 QTimer.singleShot(2000, self.__process.kill) 151 QTimer.singleShot(2000, self.__process.kill)
146 self.__process.waitForFinished(3000) 152 self.__process.waitForFinished(3000)
147 153
148 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 154 self.buttonBox.button(
149 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) 155 QDialogButtonBox.StandardButton.Close).setEnabled(True)
150 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 156 self.buttonBox.button(
157 QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
158 self.buttonBox.button(
159 QDialogButtonBox.StandardButton.Close).setDefault(True)
151 160
152 if not giveUp: 161 if not giveUp:
153 if exitCode != 0: 162 if exitCode != 0:
154 self.__logOutput(self.tr("Failed\n\n")) 163 self.__logOutput(self.tr("Failed\n\n"))
155 if len(self.errors.toPlainText().splitlines()) == 1: 164 if len(self.errors.toPlainText().splitlines()) == 1:
203 Private slot to handle the readyReadStandardOutput signal. 212 Private slot to handle the readyReadStandardOutput signal.
204 213
205 It reads the output of the process, formats it and inserts it into 214 It reads the output of the process, formats it and inserts it into
206 the contents pane. 215 the contents pane.
207 """ 216 """
208 self.__process.setReadChannel(QProcess.StandardOutput) 217 self.__process.setReadChannel(QProcess.ProcessChannel.StandardOutput)
209 218
210 while self.__process.canReadLine(): 219 while self.__process.canReadLine():
211 s = str(self.__process.readLine(), 220 s = str(self.__process.readLine(),
212 Preferences.getSystem("IOEncoding"), 221 Preferences.getSystem("IOEncoding"),
213 'replace') 222 'replace')
218 Private slot to handle the readyReadStandardError signal. 227 Private slot to handle the readyReadStandardError signal.
219 228
220 It reads the error output of the process and inserts it into the 229 It reads the error output of the process and inserts it into the
221 error pane. 230 error pane.
222 """ 231 """
223 self.__process.setReadChannel(QProcess.StandardError) 232 self.__process.setReadChannel(QProcess.ProcessChannel.StandardError)
224 233
225 while self.__process.canReadLine(): 234 while self.__process.canReadLine():
226 s = str(self.__process.readLine(), 235 s = str(self.__process.readLine(),
227 Preferences.getSystem("IOEncoding"), 236 Preferences.getSystem("IOEncoding"),
228 'replace') 237 'replace')

eric ide

mercurial