Plugins/VcsPlugins/vcsMercurial/GpgExtension/HgGpgSignaturesDialog.py

changeset 1249
77f836a883c1
parent 1131
7781e396c903
child 1250
dafdd7d97a9f
equal deleted inserted replaced
1248:7d0eff6435a9 1249:77f836a883c1
40 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 40 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
41 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 41 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
42 42
43 self.process = QProcess() 43 self.process = QProcess()
44 self.vcs = vcs 44 self.vcs = vcs
45 self.__hgClient = vcs.getClient()
45 46
46 self.process.finished.connect(self.__procFinished) 47 self.process.finished.connect(self.__procFinished)
47 self.process.readyReadStandardOutput.connect(self.__readStdout) 48 self.process.readyReadStandardOutput.connect(self.__readStdout)
48 self.process.readyReadStandardError.connect(self.__readStderr) 49 self.process.readyReadStandardError.connect(self.__readStderr)
49 50
83 return 84 return
84 85
85 args = [] 86 args = []
86 args.append('sigs') 87 args.append('sigs')
87 88
88 self.process.kill() 89 if self.__hgClient:
89 self.process.setWorkingDirectory(repodir)
90
91 self.process.start('hg', args)
92 procStarted = self.process.waitForStarted()
93 if not procStarted:
94 self.inputGroup.setEnabled(False) 90 self.inputGroup.setEnabled(False)
95 self.inputGroup.hide() 91 self.inputGroup.hide()
96 E5MessageBox.critical(self, 92
97 self.trUtf8('Process Generation Error'), 93 out, err = self.__hgClient.runcommand(args)
98 self.trUtf8( 94 if err:
99 'The process {0} could not be started. ' 95 self.__showError(err)
100 'Ensure, that it is in the search path.' 96 if out:
101 ).format('hg')) 97 for line in out.splitlines():
102 else: 98 self.__processOutputLine(line)
103 self.inputGroup.setEnabled(True) 99 self.__finish()
104 self.inputGroup.show() 100 else:
101 self.process.kill()
102 self.process.setWorkingDirectory(repodir)
103
104 self.process.start('hg', args)
105 procStarted = self.process.waitForStarted()
106 if not procStarted:
107 self.inputGroup.setEnabled(False)
108 self.inputGroup.hide()
109 E5MessageBox.critical(self,
110 self.trUtf8('Process Generation Error'),
111 self.trUtf8(
112 'The process {0} could not be started. '
113 'Ensure, that it is in the search path.'
114 ).format('hg'))
115 else:
116 self.inputGroup.setEnabled(True)
117 self.inputGroup.show()
105 118
106 def __finish(self): 119 def __finish(self):
107 """ 120 """
108 Private slot called when the process finished or the user pressed the button. 121 Private slot called when the process finished or the user pressed the button.
109 """ 122 """
137 @param button button that was clicked (QAbstractButton) 150 @param button button that was clicked (QAbstractButton)
138 """ 151 """
139 if button == self.buttonBox.button(QDialogButtonBox.Close): 152 if button == self.buttonBox.button(QDialogButtonBox.Close):
140 self.close() 153 self.close()
141 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): 154 elif button == self.buttonBox.button(QDialogButtonBox.Cancel):
142 self.__finish() 155 if self.__hgClient:
156 self.__hgClient.cancel()
157 else:
158 self.__finish()
143 159
144 def __procFinished(self, exitCode, exitStatus): 160 def __procFinished(self, exitCode, exitStatus):
145 """ 161 """
146 Private slot connected to the finished signal. 162 Private slot connected to the finished signal.
147 163
200 216
201 while self.process.canReadLine(): 217 while self.process.canReadLine():
202 s = str(self.process.readLine(), 218 s = str(self.process.readLine(),
203 Preferences.getSystem("IOEncoding"), 219 Preferences.getSystem("IOEncoding"),
204 'replace').strip() 220 'replace').strip()
205 l = s.split() 221 self.__processOutputLine(s)
206 if l[-1][0] in "1234567890": 222
207 # last element is a rev:changeset 223 def __processOutputLine(self, line):
208 rev, changeset = l[-1].split(":", 1) 224 """
209 del l[-1] 225 Private method to process the lines of output.
210 signature = " ".join(l) 226
211 self.__generateItem(rev, changeset, signature) 227 @param line output line to be processed (string)
228 """
229 l = line.split()
230 if l[-1][0] in "1234567890":
231 # last element is a rev:changeset
232 rev, changeset = l[-1].split(":", 1)
233 del l[-1]
234 signature = " ".join(l)
235 self.__generateItem(rev, changeset, signature)
212 236
213 def __readStderr(self): 237 def __readStderr(self):
214 """ 238 """
215 Private slot to handle the readyReadStderr signal. 239 Private slot to handle the readyReadStderr signal.
216 240
220 if self.process is not None: 244 if self.process is not None:
221 self.errorGroup.show() 245 self.errorGroup.show()
222 s = str(self.process.readAllStandardError(), 246 s = str(self.process.readAllStandardError(),
223 Preferences.getSystem("IOEncoding"), 247 Preferences.getSystem("IOEncoding"),
224 'replace') 248 'replace')
225 self.errors.insertPlainText(s) 249 self.__showError(s)
226 self.errors.ensureCursorVisible() 250
251 def __showError(self, out):
252 """
253 Private slot to show some error.
254
255 @param out error to be shown (string)
256 """
257 self.errorGroup.show()
258 self.errors.insertPlainText(out)
259 self.errors.ensureCursorVisible()
227 260
228 @pyqtSlot() 261 @pyqtSlot()
229 def on_signaturesList_itemSelectionChanged(self): 262 def on_signaturesList_itemSelectionChanged(self):
230 """ 263 """
231 Private slot handling changes of the selection. 264 Private slot handling changes of the selection.

eric ide

mercurial