Debugger/DebuggerInterfaceRuby.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3357
2390df6f42ba
child 3656
441956d8fce5
child 3925
5afc73bf9c57
equal deleted inserted replaced
3456:96232974dcdb 3484:645c12de6b0c
39 Module function to get characterising data for the debugger interface. 39 Module function to get characterising data for the debugger interface.
40 40
41 @return list of the following data. Client type (string), client 41 @return list of the following data. Client type (string), client
42 capabilities (integer), client type association (list of strings) 42 capabilities (integer), client type association (list of strings)
43 """ 43 """
44 return ["Ruby", ClientDefaultCapabilities, ClientTypeAssociations] 44 if Preferences.getDebugger("RubyInterpreter"):
45 return ["Ruby", ClientDefaultCapabilities, ClientTypeAssociations]
46 else:
47 return ["", 0, []]
45 48
46 49
47 class DebuggerInterfaceRuby(QObject): 50 class DebuggerInterfaceRuby(QObject):
48 """ 51 """
49 Class implementing the Ruby debugger interface for the debug server. 52 Class implementing the Ruby debugger interface for the debug server.
138 Public method to start a remote Ruby interpreter. 141 Public method to start a remote Ruby interpreter.
139 142
140 @param port portnumber the debug server is listening on (integer) 143 @param port portnumber the debug server is listening on (integer)
141 @param runInConsole flag indicating to start the debugger in a 144 @param runInConsole flag indicating to start the debugger in a
142 console window (boolean) 145 console window (boolean)
143 @return client process object (QProcess) and a flag to indicate 146 @return client process object (QProcess), a flag to indicate
144 a network connection (boolean) 147 a network connection (boolean) and the name of the interpreter
148 in case of a local execution (string)
145 """ 149 """
146 interpreter = Preferences.getDebugger("RubyInterpreter") 150 interpreter = Preferences.getDebugger("RubyInterpreter")
147 if interpreter == "": 151 if interpreter == "":
148 interpreter = "/usr/bin/ruby" 152 E5MessageBox.critical(
153 None,
154 self.tr("Start Debugger"),
155 self.tr("""<p>No Ruby interpreter configured.</p>"""))
156 return None, False, ""
157
149 debugClient = os.path.join( 158 debugClient = os.path.join(
150 getConfig('ericDir'), "DebugClients", "Ruby", "DebugClient.rb") 159 getConfig('ericDir'), "DebugClients", "Ruby", "DebugClient.rb")
151 160
152 redirect = str(Preferences.getDebugger("RubyRedirect")) 161 redirect = str(Preferences.getDebugger("RubyRedirect"))
153 162
164 args[0] = Utilities.getExecutablePath(args[0]) 173 args[0] = Utilities.getExecutablePath(args[0])
165 process = self.__startProcess(args[0], args[1:]) 174 process = self.__startProcess(args[0], args[1:])
166 if process is None: 175 if process is None:
167 E5MessageBox.critical( 176 E5MessageBox.critical(
168 None, 177 None,
169 self.trUtf8("Start Debugger"), 178 self.tr("Start Debugger"),
170 self.trUtf8( 179 self.tr(
171 """<p>The debugger backend could not be""" 180 """<p>The debugger backend could not be"""
172 """ started.</p>""")) 181 """ started.</p>"""))
173 182
174 # set translation function 183 # set translation function
175 if Preferences.getDebugger("PathTranslation"): 184 if Preferences.getDebugger("PathTranslation"):
178 self.translateLocal = \ 187 self.translateLocal = \
179 Preferences.getDebugger("PathTranslationLocal") 188 Preferences.getDebugger("PathTranslationLocal")
180 self.translate = self.__remoteTranslation 189 self.translate = self.__remoteTranslation
181 else: 190 else:
182 self.translate = self.__identityTranslation 191 self.translate = self.__identityTranslation
183 return process, self.__isNetworked 192 return process, self.__isNetworked, ""
184 193
185 # set translation function 194 # set translation function
186 self.translate = self.__identityTranslation 195 self.translate = self.__identityTranslation
187 196
188 # setup the environment for the debugger 197 # setup the environment for the debugger
211 args[0] = Utilities.getExecutablePath(args[0]) 220 args[0] = Utilities.getExecutablePath(args[0])
212 process = self.__startProcess(args[0], args[1:], clientEnv) 221 process = self.__startProcess(args[0], args[1:], clientEnv)
213 if process is None: 222 if process is None:
214 E5MessageBox.critical( 223 E5MessageBox.critical(
215 None, 224 None,
216 self.trUtf8("Start Debugger"), 225 self.tr("Start Debugger"),
217 self.trUtf8( 226 self.tr(
218 """<p>The debugger backend could not be""" 227 """<p>The debugger backend could not be"""
219 """ started.</p>""")) 228 """ started.</p>"""))
220 return process, self.__isNetworked 229 return process, self.__isNetworked, interpreter
221 230
222 process = self.__startProcess( 231 process = self.__startProcess(
223 interpreter, 232 interpreter,
224 [debugClient, str(port), redirect, ipaddr], 233 [debugClient, str(port), redirect, ipaddr],
225 clientEnv) 234 clientEnv)
226 if process is None: 235 if process is None:
227 E5MessageBox.critical( 236 E5MessageBox.critical(
228 None, 237 None,
229 self.trUtf8("Start Debugger"), 238 self.tr("Start Debugger"),
230 self.trUtf8( 239 self.tr(
231 """<p>The debugger backend could not be started.</p>""")) 240 """<p>The debugger backend could not be started.</p>"""))
232 return process, self.__isNetworked 241 return process, self.__isNetworked, interpreter
233 242
234 def startRemoteForProject(self, port, runInConsole): 243 def startRemoteForProject(self, port, runInConsole):
235 """ 244 """
236 Public method to start a remote Ruby interpreter for a project. 245 Public method to start a remote Ruby interpreter for a project.
237 246
238 @param port portnumber the debug server is listening on (integer) 247 @param port portnumber the debug server is listening on (integer)
239 @param runInConsole flag indicating to start the debugger in a 248 @param runInConsole flag indicating to start the debugger in a
240 console window (boolean) 249 console window (boolean)
241 @return pid of the client process (integer) and a flag to indicate 250 @return client process object (QProcess), a flag to indicate
242 a network connection (boolean) 251 a network connection (boolean) and the name of the interpreter
252 in case of a local execution (string)
243 """ 253 """
244 project = e5App().getObject("Project") 254 project = e5App().getObject("Project")
245 if not project.isDebugPropertiesLoaded(): 255 if not project.isDebugPropertiesLoaded():
246 return None, self.__isNetworked 256 return None, self.__isNetworked, ""
247 257
248 # start debugger with project specific settings 258 # start debugger with project specific settings
249 interpreter = project.getDebugProperty("INTERPRETER") 259 interpreter = project.getDebugProperty("INTERPRETER")
250 debugClient = project.getDebugProperty("DEBUGCLIENT") 260 debugClient = project.getDebugProperty("DEBUGCLIENT")
251 261
264 args[0] = Utilities.getExecutablePath(args[0]) 274 args[0] = Utilities.getExecutablePath(args[0])
265 process = self.__startProcess(args[0], args[1:]) 275 process = self.__startProcess(args[0], args[1:])
266 if process is None: 276 if process is None:
267 E5MessageBox.critical( 277 E5MessageBox.critical(
268 None, 278 None,
269 self.trUtf8("Start Debugger"), 279 self.tr("Start Debugger"),
270 self.trUtf8( 280 self.tr(
271 """<p>The debugger backend could not be""" 281 """<p>The debugger backend could not be"""
272 """ started.</p>""")) 282 """ started.</p>"""))
273 # set translation function 283 # set translation function
274 if project.getDebugProperty("PATHTRANSLATION"): 284 if project.getDebugProperty("PATHTRANSLATION"):
275 self.translateRemote = \ 285 self.translateRemote = \
277 self.translateLocal = \ 287 self.translateLocal = \
278 project.getDebugProperty("LOCALPATH") 288 project.getDebugProperty("LOCALPATH")
279 self.translate = self.__remoteTranslation 289 self.translate = self.__remoteTranslation
280 else: 290 else:
281 self.translate = self.__identityTranslation 291 self.translate = self.__identityTranslation
282 return process, self.__isNetworked 292 return process, self.__isNetworked, ""
283 293
284 # set translation function 294 # set translation function
285 self.translate = self.__identityTranslation 295 self.translate = self.__identityTranslation
286 296
287 # setup the environment for the debugger 297 # setup the environment for the debugger
311 args[0] = Utilities.getExecutablePath(args[0]) 321 args[0] = Utilities.getExecutablePath(args[0])
312 process = self.__startProcess(args[0], args[1:], clientEnv) 322 process = self.__startProcess(args[0], args[1:], clientEnv)
313 if process is None: 323 if process is None:
314 E5MessageBox.critical( 324 E5MessageBox.critical(
315 None, 325 None,
316 self.trUtf8("Start Debugger"), 326 self.tr("Start Debugger"),
317 self.trUtf8( 327 self.tr(
318 """<p>The debugger backend could not be""" 328 """<p>The debugger backend could not be"""
319 """ started.</p>""")) 329 """ started.</p>"""))
320 return process, self.__isNetworked 330 return process, self.__isNetworked, interpreter
321 331
322 process = self.__startProcess( 332 process = self.__startProcess(
323 interpreter, 333 interpreter,
324 [debugClient, str(port), redirect, ipaddr], 334 [debugClient, str(port), redirect, ipaddr],
325 clientEnv) 335 clientEnv)
326 if process is None: 336 if process is None:
327 E5MessageBox.critical( 337 E5MessageBox.critical(
328 None, 338 None,
329 self.trUtf8("Start Debugger"), 339 self.tr("Start Debugger"),
330 self.trUtf8( 340 self.tr(
331 """<p>The debugger backend could not be started.</p>""")) 341 """<p>The debugger backend could not be started.</p>"""))
332 return process, self.__isNetworked 342 return process, self.__isNetworked, interpreter
333 343
334 def getClientCapabilities(self): 344 def getClientCapabilities(self):
335 """ 345 """
336 Public method to retrieve the debug clients capabilities. 346 Public method to retrieve the debug clients capabilities.
337 347
349 # If we already have a connection, refuse this one. It will be closed 359 # If we already have a connection, refuse this one. It will be closed
350 # automatically. 360 # automatically.
351 if self.qsock is not None: 361 if self.qsock is not None:
352 return False 362 return False
353 363
354 sock.disconnected[()].connect(self.debugServer.startClient) 364 sock.disconnected.connect(self.debugServer.startClient)
355 sock.readyRead[()].connect(self.__parseClientLine) 365 sock.readyRead.connect(self.__parseClientLine)
356 366
357 self.qsock = sock 367 self.qsock = sock
358 368
359 # Get the remote clients capabilities 369 # Get the remote clients capabilities
360 self.remoteCapabilities() 370 self.remoteCapabilities()
380 if self.qsock is None: 390 if self.qsock is None:
381 return 391 return
382 392
383 # do not want any slots called during shutdown 393 # do not want any slots called during shutdown
384 self.qsock.disconnected.disconnect(self.debugServer.startClient) 394 self.qsock.disconnected.disconnect(self.debugServer.startClient)
385 self.qsock.readyRead[()].disconnect(self.__parseClientLine) 395 self.qsock.readyRead.disconnect(self.__parseClientLine)
386 396
387 # close down socket, and shut down client as well. 397 # close down socket, and shut down client as well.
388 self.__sendCommand('{0}\n'.format(DebugProtocol.RequestShutdown)) 398 self.__sendCommand('{0}\n'.format(DebugProtocol.RequestShutdown))
389 self.qsock.flush() 399 self.qsock.flush()
390 400

eric ide

mercurial