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 if channel == "L": |
259 if channel == "L": |
260 input, isPassword = inputChannels[channel](data) |
260 inputData, 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 if not isPassword: |
262 if not isPassword: |
263 outputChannels["o"](input) |
263 outputChannels["o"](inputData) |
264 else: |
264 else: |
265 input = inputChannels[channel](data) |
265 inputData = inputChannels[channel](data) |
266 self.__writeDataBlock(input) |
266 self.__writeDataBlock(inputData) |
267 |
267 |
268 # output channels |
268 # output channels |
269 elif channel in outputChannels: |
269 elif channel in outputChannels: |
270 outputChannels[channel](data) |
270 outputChannels[channel](data) |
271 |
271 |
289 @param size maximum length of the requested input (integer) |
289 @param size maximum length of the requested input (integer) |
290 @param message message sent by the server (string) |
290 @param message message sent by the server (string) |
291 @return data entered by the user (string) |
291 @return data entered by the user (string) |
292 """ |
292 """ |
293 from .HgClientPromptDialog import HgClientPromptDialog |
293 from .HgClientPromptDialog import HgClientPromptDialog |
294 input = "" |
294 inputData = "" |
295 isPassword = False |
295 isPassword = False |
296 dlg = HgClientPromptDialog(size, message) |
296 dlg = HgClientPromptDialog(size, message) |
297 if dlg.exec_() == QDialog.Accepted: |
297 if dlg.exec_() == QDialog.Accepted: |
298 input = dlg.getInput() + '\n' |
298 inputData = dlg.getInput() + '\n' |
299 isPassword = dlg.isPassword() |
299 isPassword = dlg.isPassword() |
300 return input, isPassword |
300 return inputData, isPassword |
301 |
301 |
302 def runcommand(self, args, prompt=None, input=None, output=None, |
302 def runcommand(self, args, prompt=None, inputData=None, output=None, |
303 error=None): |
303 error=None): |
304 """ |
304 """ |
305 Public method to execute a command via the command server. |
305 Public method to execute a command via the command server. |
306 |
306 |
307 @param args list of arguments for the command (list of string) |
307 @param args list of arguments for the command (list of string) |
308 @keyparam prompt function to reply to prompts by the server. It |
308 @keyparam prompt function to reply to prompts by the server. It |
309 receives the max number of bytes to return and the contents |
309 receives the max number of bytes to return and the contents |
310 of the output channel received so far. |
310 of the output channel received so far. |
311 @keyparam input function to reply to bulk data requests by the server. |
311 @keyparam inputData function to reply to bulk data requests by the |
312 It receives the max number of bytes to return. |
312 server. It receives the max number of bytes to return. |
313 @keyparam output function receiving the data from the server (string). |
313 @keyparam output function receiving the data from the server (string). |
314 If a prompt function is given, this parameter will be ignored. |
314 If a prompt function is given, this parameter will be ignored. |
315 @keyparam error function receiving error messages from the server |
315 @keyparam error function receiving error messages from the server |
316 (string) |
316 (string) |
317 @return output and errors of the command server (string). In case |
317 @return output and errors of the command server (string). In case |
347 else: |
347 else: |
348 msg = outputBuffer.getvalue() |
348 msg = outputBuffer.getvalue() |
349 reply, isPassword = self.__prompt(size, msg) |
349 reply, isPassword = self.__prompt(size, msg) |
350 return reply, isPassword |
350 return reply, isPassword |
351 inputChannels["L"] = myprompt |
351 inputChannels["L"] = myprompt |
352 if input is not None: |
352 if inputData is not None: |
353 inputChannels["I"] = input |
353 inputChannels["I"] = inputData |
354 |
354 |
355 self.__cancel = False |
355 self.__cancel = False |
356 self.__runcommand(args, inputChannels, outputChannels) |
356 self.__runcommand(args, inputChannels, outputChannels) |
357 if outputBuffer: |
357 if outputBuffer: |
358 out = outputBuffer.getvalue() |
358 out = outputBuffer.getvalue() |