78 prepareProcess(self.__server, self.__encoding) |
78 prepareProcess(self.__server, self.__encoding) |
79 |
79 |
80 self.__server.start('hg', self.__serverArgs) |
80 self.__server.start('hg', self.__serverArgs) |
81 serverStarted = self.__server.waitForStarted(5000) |
81 serverStarted = self.__server.waitForStarted(5000) |
82 if not serverStarted: |
82 if not serverStarted: |
83 return False, self.trUtf8( |
83 return False, self.tr( |
84 'The process {0} could not be started. ' |
84 'The process {0} could not be started. ' |
85 'Ensure, that it is in the search path.' |
85 'Ensure, that it is in the search path.' |
86 ).format('hg') |
86 ).format('hg') |
87 |
87 |
88 self.__server.setReadChannel(QProcess.StandardOutput) |
88 self.__server.setReadChannel(QProcess.StandardOutput) |
125 @return tuple of flag indicating success (boolean) and an error message |
125 @return tuple of flag indicating success (boolean) and an error message |
126 in case of failure (string) |
126 in case of failure (string) |
127 """ |
127 """ |
128 ch, msg = self.__readChannel() |
128 ch, msg = self.__readChannel() |
129 if not ch: |
129 if not ch: |
130 return False, self.trUtf8("Did not receive the 'hello' message.") |
130 return False, self.tr("Did not receive the 'hello' message.") |
131 elif ch != "o": |
131 elif ch != "o": |
132 return False, self.trUtf8("Received data on unexpected channel.") |
132 return False, self.tr("Received data on unexpected channel.") |
133 |
133 |
134 msg = msg.split("\n") |
134 msg = msg.split("\n") |
135 |
135 |
136 if not msg[0].startswith("capabilities: "): |
136 if not msg[0].startswith("capabilities: "): |
137 return False, self.trUtf8( |
137 return False, self.tr( |
138 "Bad 'hello' message, expected 'capabilities: '" |
138 "Bad 'hello' message, expected 'capabilities: '" |
139 " but got '{0}'.").format(msg[0]) |
139 " but got '{0}'.").format(msg[0]) |
140 self.__capabilities = msg[0][len('capabilities: '):] |
140 self.__capabilities = msg[0][len('capabilities: '):] |
141 if not self.__capabilities: |
141 if not self.__capabilities: |
142 return False, self.trUtf8("'capabilities' message did not contain" |
142 return False, self.tr("'capabilities' message did not contain" |
143 " any capability.") |
143 " any capability.") |
144 |
144 |
145 self.__capabilities = set(self.__capabilities.split()) |
145 self.__capabilities = set(self.__capabilities.split()) |
146 if "runcommand" not in self.__capabilities: |
146 if "runcommand" not in self.__capabilities: |
147 return False, "'capabilities' did not contain 'runcommand'." |
147 return False, "'capabilities' did not contain 'runcommand'." |
148 |
148 |
149 if not msg[1].startswith("encoding: "): |
149 if not msg[1].startswith("encoding: "): |
150 return False, self.trUtf8( |
150 return False, self.tr( |
151 "Bad 'hello' message, expected 'encoding: '" |
151 "Bad 'hello' message, expected 'encoding: '" |
152 " but got '{0}'.").format(msg[1]) |
152 " but got '{0}'.").format(msg[1]) |
153 encoding = msg[1][len('encoding: '):] |
153 encoding = msg[1][len('encoding: '):] |
154 if not encoding: |
154 if not encoding: |
155 return False, self.trUtf8("'encoding' message did not contain" |
155 return False, self.tr("'encoding' message did not contain" |
156 " any encoding.") |
156 " any encoding.") |
157 self.__encoding = encoding |
157 self.__encoding = encoding |
158 |
158 |
159 return True, "" |
159 return True, "" |
160 |
160 |
161 def __serverFinished(self, exitCode, exitStatus): |
161 def __serverFinished(self, exitCode, exitStatus): |
331 return reply |
331 return reply |
332 inputChannels["L"] = func |
332 inputChannels["L"] = func |
333 else: |
333 else: |
334 def myprompt(size): |
334 def myprompt(size): |
335 if outputBuffer is None: |
335 if outputBuffer is None: |
336 msg = self.trUtf8("For message see output dialog.") |
336 msg = self.tr("For message see output dialog.") |
337 else: |
337 else: |
338 msg = outputBuffer.getvalue() |
338 msg = outputBuffer.getvalue() |
339 reply = self.__prompt(size, msg) |
339 reply = self.__prompt(size, msg) |
340 return reply |
340 return reply |
341 inputChannels["L"] = myprompt |
341 inputChannels["L"] = myprompt |