254 continue |
254 continue |
255 channel, data = self.__readChannel() |
255 channel, data = self.__readChannel() |
256 |
256 |
257 # input channels |
257 # input channels |
258 if channel in inputChannels: |
258 if channel in inputChannels: |
259 input = inputChannels[channel](data) |
|
260 if channel == "L": |
259 if channel == "L": |
|
260 input, isPassword = inputChannels[channel](data) |
261 # echo the input to the output if it was a prompt |
261 # echo the input to the output if it was a prompt |
262 outputChannels["o"](input) |
262 if not isPassword: |
|
263 outputChannels["o"](input) |
|
264 else: |
|
265 input = inputChannels[channel](data) |
263 self.__writeDataBlock(input) |
266 self.__writeDataBlock(input) |
264 |
267 |
265 # output channels |
268 # output channels |
266 elif channel in outputChannels: |
269 elif channel in outputChannels: |
267 outputChannels[channel](data) |
270 outputChannels[channel](data) |
287 @param message message sent by the server (string) |
290 @param message message sent by the server (string) |
288 @return data entered by the user (string) |
291 @return data entered by the user (string) |
289 """ |
292 """ |
290 from .HgClientPromptDialog import HgClientPromptDialog |
293 from .HgClientPromptDialog import HgClientPromptDialog |
291 input = "" |
294 input = "" |
|
295 isPassword = False |
292 dlg = HgClientPromptDialog(size, message) |
296 dlg = HgClientPromptDialog(size, message) |
293 if dlg.exec_() == QDialog.Accepted: |
297 if dlg.exec_() == QDialog.Accepted: |
294 input = dlg.getInput() + '\n' |
298 input = dlg.getInput() + '\n' |
295 return input |
299 isPassword = dlg.isPassword() |
|
300 return input, isPassword |
296 |
301 |
297 def runcommand(self, args, prompt=None, input=None, output=None, |
302 def runcommand(self, args, prompt=None, input=None, output=None, |
298 error=None): |
303 error=None): |
299 """ |
304 """ |
300 Public method to execute a command via the command server. |
305 Public method to execute a command via the command server. |
331 |
336 |
332 inputChannels = {} |
337 inputChannels = {} |
333 if prompt is not None: |
338 if prompt is not None: |
334 def func(size): |
339 def func(size): |
335 reply = prompt(size, outputBuffer.getvalue()) |
340 reply = prompt(size, outputBuffer.getvalue()) |
336 return reply |
341 return reply, False |
337 inputChannels["L"] = func |
342 inputChannels["L"] = func |
338 else: |
343 else: |
339 def myprompt(size): |
344 def myprompt(size): |
340 if outputBuffer is None: |
345 if outputBuffer is None: |
341 msg = self.tr("For message see output dialog.") |
346 msg = self.tr("For message see output dialog.") |
342 else: |
347 else: |
343 msg = outputBuffer.getvalue() |
348 msg = outputBuffer.getvalue() |
344 reply = self.__prompt(size, msg) |
349 reply, isPassword = self.__prompt(size, msg) |
345 return reply |
350 return reply, isPassword |
346 inputChannels["L"] = myprompt |
351 inputChannels["L"] = myprompt |
347 if input is not None: |
352 if input is not None: |
348 inputChannels["I"] = input |
353 inputChannels["I"] = input |
349 |
354 |
350 self.__cancel = False |
355 self.__cancel = False |