Debugger/DebuggerInterfacePython.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3357
2390df6f42ba
child 3640
2bf828881e86
equal deleted inserted replaced
3456:96232974dcdb 3484:645c12de6b0c
150 Public method to start a remote Python interpreter. 150 Public method to start a remote Python interpreter.
151 151
152 @param port portnumber the debug server is listening on (integer) 152 @param port portnumber the debug server is listening on (integer)
153 @param runInConsole flag indicating to start the debugger in a 153 @param runInConsole flag indicating to start the debugger in a
154 console window (boolean) 154 console window (boolean)
155 @return client process object (QProcess) and a flag to indicate 155 @return client process object (QProcess), a flag to indicate
156 a network connection (boolean) 156 a network connection (boolean) and the name of the interpreter
157 in case of a local execution (string)
157 """ 158 """
158 interpreter = Preferences.getDebugger("PythonInterpreter") 159 interpreter = Preferences.getDebugger("PythonInterpreter")
159 if interpreter == "": 160 if interpreter == "":
160 E5MessageBox.critical( 161 E5MessageBox.critical(
161 None, 162 None,
162 self.trUtf8("Start Debugger"), 163 self.tr("Start Debugger"),
163 self.trUtf8( 164 self.tr(
164 """<p>No Python2 interpreter configured.</p>""")) 165 """<p>No Python2 interpreter configured.</p>"""))
165 return None, False 166 return None, False, ""
166 167
167 debugClientType = Preferences.getDebugger("DebugClientType") 168 debugClientType = Preferences.getDebugger("DebugClientType")
168 if debugClientType == "standard": 169 if debugClientType == "standard":
169 debugClient = os.path.join(getConfig('ericDir'), 170 debugClient = os.path.join(getConfig('ericDir'),
170 "DebugClients", "Python", 171 "DebugClients", "Python",
197 args[0] = Utilities.getExecutablePath(args[0]) 198 args[0] = Utilities.getExecutablePath(args[0])
198 process = self.__startProcess(args[0], args[1:]) 199 process = self.__startProcess(args[0], args[1:])
199 if process is None: 200 if process is None:
200 E5MessageBox.critical( 201 E5MessageBox.critical(
201 None, 202 None,
202 self.trUtf8("Start Debugger"), 203 self.tr("Start Debugger"),
203 self.trUtf8( 204 self.tr(
204 """<p>The debugger backend could not be""" 205 """<p>The debugger backend could not be"""
205 """ started.</p>""")) 206 """ started.</p>"""))
206 207
207 # set translation function 208 # set translation function
208 if Preferences.getDebugger("PathTranslation"): 209 if Preferences.getDebugger("PathTranslation"):
211 self.translateLocal = \ 212 self.translateLocal = \
212 Preferences.getDebugger("PathTranslationLocal") 213 Preferences.getDebugger("PathTranslationLocal")
213 self.translate = self.__remoteTranslation 214 self.translate = self.__remoteTranslation
214 else: 215 else:
215 self.translate = self.__identityTranslation 216 self.translate = self.__identityTranslation
216 return process, self.__isNetworked 217 return process, self.__isNetworked, ""
217 218
218 # set translation function 219 # set translation function
219 self.translate = self.__identityTranslation 220 self.translate = self.__identityTranslation
220 221
221 # setup the environment for the debugger 222 # setup the environment for the debugger
244 args[0] = Utilities.getExecutablePath(args[0]) 245 args[0] = Utilities.getExecutablePath(args[0])
245 process = self.__startProcess(args[0], args[1:], clientEnv) 246 process = self.__startProcess(args[0], args[1:], clientEnv)
246 if process is None: 247 if process is None:
247 E5MessageBox.critical( 248 E5MessageBox.critical(
248 None, 249 None,
249 self.trUtf8("Start Debugger"), 250 self.tr("Start Debugger"),
250 self.trUtf8( 251 self.tr(
251 """<p>The debugger backend could not be""" 252 """<p>The debugger backend could not be"""
252 """ started.</p>""")) 253 """ started.</p>"""))
253 return process, self.__isNetworked 254 return process, self.__isNetworked, interpreter
254 255
255 process = self.__startProcess( 256 process = self.__startProcess(
256 interpreter, 257 interpreter,
257 [debugClient, noencoding, str(port), redirect, ipaddr], 258 [debugClient, noencoding, str(port), redirect, ipaddr],
258 clientEnv) 259 clientEnv)
259 if process is None: 260 if process is None:
260 E5MessageBox.critical( 261 E5MessageBox.critical(
261 None, 262 None,
262 self.trUtf8("Start Debugger"), 263 self.tr("Start Debugger"),
263 self.trUtf8( 264 self.tr(
264 """<p>The debugger backend could not be started.</p>""")) 265 """<p>The debugger backend could not be started.</p>"""))
265 return process, self.__isNetworked 266 return process, self.__isNetworked, interpreter
266 267
267 def startRemoteForProject(self, port, runInConsole): 268 def startRemoteForProject(self, port, runInConsole):
268 """ 269 """
269 Public method to start a remote Python interpreter for a project. 270 Public method to start a remote Python interpreter for a project.
270 271
271 @param port portnumber the debug server is listening on (integer) 272 @param port portnumber the debug server is listening on (integer)
272 @param runInConsole flag indicating to start the debugger in a 273 @param runInConsole flag indicating to start the debugger in a
273 console window (boolean) 274 console window (boolean)
274 @return client process object (QProcess) and a flag to indicate 275 @return client process object (QProcess), a flag to indicate
275 a network connection (boolean) 276 a network connection (boolean) and the name of the interpreter
277 in case of a local execution (string)
276 """ 278 """
277 project = e5App().getObject("Project") 279 project = e5App().getObject("Project")
278 if not project.isDebugPropertiesLoaded(): 280 if not project.isDebugPropertiesLoaded():
279 return None, self.__isNetworked 281 return None, self.__isNetworked, ""
280 282
281 # start debugger with project specific settings 283 # start debugger with project specific settings
282 interpreter = project.getDebugProperty("INTERPRETER") 284 interpreter = project.getDebugProperty("INTERPRETER")
283 debugClient = project.getDebugProperty("DEBUGCLIENT") 285 debugClient = project.getDebugProperty("DEBUGCLIENT")
284 286
299 args[0] = Utilities.getExecutablePath(args[0]) 301 args[0] = Utilities.getExecutablePath(args[0])
300 process = self.__startProcess(args[0], args[1:]) 302 process = self.__startProcess(args[0], args[1:])
301 if process is None: 303 if process is None:
302 E5MessageBox.critical( 304 E5MessageBox.critical(
303 None, 305 None,
304 self.trUtf8("Start Debugger"), 306 self.tr("Start Debugger"),
305 self.trUtf8( 307 self.tr(
306 """<p>The debugger backend could not be""" 308 """<p>The debugger backend could not be"""
307 """ started.</p>""")) 309 """ started.</p>"""))
308 # set translation function 310 # set translation function
309 if project.getDebugProperty("PATHTRANSLATION"): 311 if project.getDebugProperty("PATHTRANSLATION"):
310 self.translateRemote = \ 312 self.translateRemote = \
312 self.translateLocal = \ 314 self.translateLocal = \
313 project.getDebugProperty("LOCALPATH") 315 project.getDebugProperty("LOCALPATH")
314 self.translate = self.__remoteTranslation 316 self.translate = self.__remoteTranslation
315 else: 317 else:
316 self.translate = self.__identityTranslation 318 self.translate = self.__identityTranslation
317 return process, self.__isNetworked 319 return process, self.__isNetworked, ""
318 320
319 # set translation function 321 # set translation function
320 self.translate = self.__identityTranslation 322 self.translate = self.__identityTranslation
321 323
322 # setup the environment for the debugger 324 # setup the environment for the debugger
346 args[0] = Utilities.getExecutablePath(args[0]) 348 args[0] = Utilities.getExecutablePath(args[0])
347 process = self.__startProcess(args[0], args[1:], clientEnv) 349 process = self.__startProcess(args[0], args[1:], clientEnv)
348 if process is None: 350 if process is None:
349 E5MessageBox.critical( 351 E5MessageBox.critical(
350 None, 352 None,
351 self.trUtf8("Start Debugger"), 353 self.tr("Start Debugger"),
352 self.trUtf8( 354 self.tr(
353 """<p>The debugger backend could not be""" 355 """<p>The debugger backend could not be"""
354 """ started.</p>""")) 356 """ started.</p>"""))
355 return process, self.__isNetworked 357 return process, self.__isNetworked, interpreter
356 358
357 process = self.__startProcess( 359 process = self.__startProcess(
358 interpreter, 360 interpreter,
359 [debugClient, noencoding, str(port), redirect, ipaddr], 361 [debugClient, noencoding, str(port), redirect, ipaddr],
360 clientEnv) 362 clientEnv)
361 if process is None: 363 if process is None:
362 E5MessageBox.critical( 364 E5MessageBox.critical(
363 None, 365 None,
364 self.trUtf8("Start Debugger"), 366 self.tr("Start Debugger"),
365 self.trUtf8( 367 self.tr(
366 """<p>The debugger backend could not be started.</p>""")) 368 """<p>The debugger backend could not be started.</p>"""))
367 return process, self.__isNetworked 369 return process, self.__isNetworked, interpreter
368 370
369 def getClientCapabilities(self): 371 def getClientCapabilities(self):
370 """ 372 """
371 Public method to retrieve the debug clients capabilities. 373 Public method to retrieve the debug clients capabilities.
372 374
384 # If we already have a connection, refuse this one. It will be closed 386 # If we already have a connection, refuse this one. It will be closed
385 # automatically. 387 # automatically.
386 if self.qsock is not None: 388 if self.qsock is not None:
387 return False 389 return False
388 390
389 sock.disconnected[()].connect(self.debugServer.startClient) 391 sock.disconnected.connect(self.debugServer.startClient)
390 sock.readyRead[()].connect(self.__parseClientLine) 392 sock.readyRead.connect(self.__parseClientLine)
391 393
392 self.qsock = sock 394 self.qsock = sock
393 395
394 # Get the remote clients capabilities 396 # Get the remote clients capabilities
395 self.remoteCapabilities() 397 self.remoteCapabilities()
415 if self.qsock is None: 417 if self.qsock is None:
416 return 418 return
417 419
418 # do not want any slots called during shutdown 420 # do not want any slots called during shutdown
419 self.qsock.disconnected.disconnect(self.debugServer.startClient) 421 self.qsock.disconnected.disconnect(self.debugServer.startClient)
420 self.qsock.readyRead[()].disconnect(self.__parseClientLine) 422 self.qsock.readyRead.disconnect(self.__parseClientLine)
421 423
422 # close down socket, and shut down client as well. 424 # close down socket, and shut down client as well.
423 self.__sendCommand('{0}\n'.format(DebugProtocol.RequestShutdown)) 425 self.__sendCommand('{0}\n'.format(DebugProtocol.RequestShutdown))
424 self.qsock.flush() 426 self.qsock.flush()
425 427
798 800
799 def __askForkTo(self): 801 def __askForkTo(self):
800 """ 802 """
801 Private method to ask the user which branch of a fork to follow. 803 Private method to ask the user which branch of a fork to follow.
802 """ 804 """
803 selections = [self.trUtf8("Parent Process"), 805 selections = [self.tr("Parent Process"),
804 self.trUtf8("Child process")] 806 self.tr("Child process")]
805 res, ok = QInputDialog.getItem( 807 res, ok = QInputDialog.getItem(
806 None, 808 None,
807 self.trUtf8("Client forking"), 809 self.tr("Client forking"),
808 self.trUtf8("Select the fork branch to follow."), 810 self.tr("Select the fork branch to follow."),
809 selections, 811 selections,
810 0, False) 812 0, False)
811 if not ok or res == selections[0]: 813 if not ok or res == selections[0]:
812 self.__sendCommand(DebugProtocol.ResponseForkTo + 'parent\n') 814 self.__sendCommand(DebugProtocol.ResponseForkTo + 'parent\n')
813 else: 815 else:

eric ide

mercurial