# eric7.Debugger.DebuggerInterfacePython

Module implementing the Python3 debugger interface for the debug server.

### Global Attributes

ClientDefaultCapabilities

### Classes

DebuggerInterfacePython | Class implementing the debugger interface for the debug server for Python 3.

### Functions

createDebuggerInterfacePython3 | Module function to create a debugger interface instance.
getRegistryData | Module function to get characterizing data for the supported debugger interfaces.

## DebuggerInterfacePython

Class implementing the debugger interface for the debug server for Python 3.

### Derived from

QObject

### Class Attributes

None

### Class Methods

None

### Methods

DebuggerInterfacePython | Constructor
__assignDebuggerId | Private method to set the debugger id for a recent debugger connection attempt.
__flush | Private slot to flush the queue.
__handleJsonCommand | Private method to handle a command or response serialized as a JSON string.
__identityTranslation | Private method to perform the identity path translation.
__parseClientLine | Private method to handle data from the client.
__remoteTranslation | Private method to perform the path translation.
__sendJsonCommand | Private method to send a single command to the client.
__shutdownSocket | Private slot to shut down a socket.
__socketDisconnected | Private slot handling a socket disconnecting.
__startProcess | Private method to start the debugger client process.
__writeJsonCommandToSocket | Private method to write a JSON command to the socket.
getClientCapabilities | Public method to retrieve the debug clients capabilities.
getDebuggerIds | Public method to return the IDs of the connected debugger backends.
isConnected | Public method to test, if a debug client has connected.
newConnection | Public slot to handle a new connection.
remoteBanner | Public slot to get the banner info of the remote client.
remoteBreakpoint | Public method to set or clear a breakpoint.
remoteBreakpointEnable | Public method to enable or disable a breakpoint.
remoteBreakpointIgnore | Public method to ignore a breakpoint the next couple of occurrences.
remoteCapabilities | Public slot to get the debug clients capabilities.
remoteClientDisassembly | Public method to ask the client for the latest traceback disassembly.
remoteClientSetFilter | Public method to set a variables filter list.
remoteClientStack | Public method to request the stack of the main thread.
remoteClientVariable | Public method to request the variables of the debugged program.
remoteClientVariables | Public method to request the variables of the debugged program.
remoteCompletion | Public slot to get the a list of possible commandline completions from the remote client.
remoteContinue | Public method to continue the debugged program.
remoteContinueUntil | Public method to continue the debugged program to the given line or until returning from the current frame.
remoteCoverage | Public method to load a new program to collect coverage data.
remoteEnvironment | Public method to set the environment for a program to debug, run, ...
remoteLoad | Public method to load a new program to debug.
remoteMoveIP | Public method to move the instruction pointer to a different line.
remoteNoDebugList | Public method to set a list of programs not to be debugged.
remoteProfile | Public method to load a new program to collect profiling data.
remoteRawInput | Public method to send the raw input to the debugged program.
remoteRun | Public method to load a new program to run.
remoteSetThread | Public method to request to set the given thread as current thread.
remoteStatement | Public method to execute a Python statement.
remoteStep | Public method to single step the debugged program.
remoteStepOut | Public method to step out the debugged program.
remoteStepOver | Public method to step over the debugged program.
remoteStepQuit | Public method to stop the debugged program.
remoteThreadList | Public method to request the list of threads from the client.
remoteUTDiscover | Public method to perform a test case discovery.
remoteUTPrepare | Public method to prepare a new unittest run.
remoteUTRun | Public method to start a unittest run.
remoteUTStop | Public method to stop a unittest run.
remoteWatchpoint | Public method to set or clear a watch expression.
remoteWatchpointEnable | Public method to enable or disable a watch expression.
remoteWatchpointIgnore | Public method to ignore a watch expression the next couple of occurrences.
setCallTraceEnabled | Public method to set the call trace state.
shutdown | Public method to cleanly shut down.
startRemote | Public method to start a remote Python interpreter.
startRemoteForProject | Public method to start a remote Python interpreter for a project.

### Static Methods

None

#### DebuggerInterfacePython (Constructor)

DebuggerInterfacePython(debugServer, passive)

Constructor

debugServer (DebugServer)
  reference to the debug server
passive (bool)
  flag indicating passive connection mode

#### DebuggerInterfacePython.__assignDebuggerId

__assignDebuggerId(sock, debuggerId)

Private method to set the debugger id for a recent debugger connection attempt.

sock (QTcpSocket)
  reference to the socket object
debuggerId (str)
  id of the connected debug client

#### DebuggerInterfacePython.__flush

__flush()

Private slot to flush the queue.

#### DebuggerInterfacePython.__handleJsonCommand

__handleJsonCommand(jsonStr, sock)

Private method to handle a command or response serialized as a JSON string.

jsonStr (str)
  string containing the command or response received from the debug backend
sock (QTcpSocket)
  reference to the socket the data was received from

#### DebuggerInterfacePython.__identityTranslation

__identityTranslation(fn, remote2local=True)

Private method to perform the identity path translation.

fn (str)
  filename to be translated
remote2local (bool)
  flag indicating the direction of translation (False = local to remote, True = remote to local [default])

Return:
  translated filename

Return Type:
  str

#### DebuggerInterfacePython.__parseClientLine

__parseClientLine(sock)

Private method to handle data from the client.

sock (QTcpSocket)
  reference to the socket to read data from

#### DebuggerInterfacePython.__remoteTranslation

__remoteTranslation(fn, remote2local=True)

Private method to perform the path translation.

fn (str)
  filename to be translated
remote2local (bool)
  flag indicating the direction of translation (False = local to remote, True = remote to local [default])

Return:
  translated filename

Return Type:
  str

#### DebuggerInterfacePython.__sendJsonCommand

__sendJsonCommand(command, params, debuggerId="", sock=None)

Private method to send a single command to the client.

command (str)
  command name to be sent
params (dict)
  dictionary of named parameters for the command
debuggerId (str)
  id of the debug client to send the command to
sock (QTcpSocket)
  reference to the socket object to be used (only used if debuggerId is not given)

#### DebuggerInterfacePython.__shutdownSocket

__shutdownSocket(sock)

Private slot to shut down a socket.

sock (QTcpSocket)
  reference to the socket

#### DebuggerInterfacePython.__socketDisconnected

__socketDisconnected(sock)

Private slot handling a socket disconnecting.

sock (QTcpSocket)
  reference to the disconnected socket

#### DebuggerInterfacePython.__startProcess

__startProcess(program, arguments, environment=None, workingDir=None)

Private method to start the debugger client process.

program (str)
  name of the executable to start
arguments (list of str)
  arguments to be passed to the program
environment (dict of str)
  dictionary of environment settings to pass
workingDir (str)
  directory to start the debugger client in

Return:
  the process object

Return Type:
  QProcess or None

#### DebuggerInterfacePython.__writeJsonCommandToSocket

__writeJsonCommandToSocket(cmd, sock)

Private method to write a JSON command to the socket.

cmd (str)
  JSON command to be sent
sock (QTcpSocket)
  reference to the socket to write to

#### DebuggerInterfacePython.getClientCapabilities

getClientCapabilities()

Public method to retrieve the debug clients capabilities.

Return:
  debug client capabilities

Return Type:
  int

#### DebuggerInterfacePython.getDebuggerIds

getDebuggerIds()

Public method to return the IDs of the connected debugger backends.

Return:
  list of connected debugger backend IDs

Return Type:
  list of str

#### DebuggerInterfacePython.isConnected

isConnected()

Public method to test, if a debug client has connected.

Return:
  flag indicating the connection status

Return Type:
  bool

#### DebuggerInterfacePython.newConnection

newConnection(sock)

Public slot to handle a new connection.

sock (QTcpSocket)
  reference to the socket object

Return:
  flag indicating success

Return Type:
  bool

#### DebuggerInterfacePython.remoteBanner

remoteBanner()

Public slot to get the banner info of the remote client.

#### DebuggerInterfacePython.remoteBreakpoint

remoteBreakpoint(debuggerId, fn, line, setBreakpoint, cond=None, temp=False)

Public method to set or clear a breakpoint.

debuggerId (str)
  ID of the debugger backend
fn (str)
  filename the breakpoint belongs to
line (int)
  linenumber of the breakpoint
setBreakpoint (bool)
  flag indicating setting or resetting a breakpoint
cond (str)
  condition of the breakpoint
temp (bool)
  flag indicating a temporary breakpoint

#### DebuggerInterfacePython.remoteBreakpointEnable

remoteBreakpointEnable(debuggerId, fn, line, enable)

Public method to enable or disable a breakpoint.

debuggerId (str)
  ID of the debugger backend
fn (str)
  filename the breakpoint belongs to
line (int)
  linenumber of the breakpoint
enable (bool)
  flag indicating enabling or disabling a breakpoint

#### DebuggerInterfacePython.remoteBreakpointIgnore

remoteBreakpointIgnore(debuggerId, fn, line, count)

Public method to ignore a breakpoint the next couple of occurrences.

debuggerId (str)
  ID of the debugger backend
fn (str)
  filename the breakpoint belongs to
line (int)
  linenumber of the breakpoint
count (int)
  number of occurrences to ignore

#### DebuggerInterfacePython.remoteCapabilities

remoteCapabilities(debuggerId)

Public slot to get the debug clients capabilities.

debuggerId (str)
  ID of the debugger backend

#### DebuggerInterfacePython.remoteClientDisassembly

remoteClientDisassembly(debuggerId)

Public method to ask the client for the latest traceback disassembly.

debuggerId (str)
  ID of the debugger backend

#### DebuggerInterfacePython.remoteClientSetFilter

remoteClientSetFilter(debuggerId, scope, filterStr)

Public method to set a variables filter list.

debuggerId (str)
  ID of the debugger backend
scope (int)
  the scope of the variables (0 = local, 1 = global)
filterStr (str)
  regexp string for variable names to filter out

#### DebuggerInterfacePython.remoteClientStack

remoteClientStack(debuggerId)

Public method to request the stack of the main thread.

debuggerId (str)
  ID of the debugger backend

#### DebuggerInterfacePython.remoteClientVariable

remoteClientVariable(debuggerId, scope, filterList, var, framenr=0, maxSize=0)

Public method to request the variables of the debugged program.

debuggerId (str)
  ID of the debugger backend
scope (int)
  the scope of the variables (0 = local, 1 = global)
filterList (list of str)
  list of variable types to filter out
var (list of str)
  list encoded name of variable to retrieve
framenr (int)
  framenumber of the variables to retrieve
maxSize (int)
  maximum size the formatted value of a variable will be shown. If it is bigger than that, a 'too big' indication will be given (@@TOO_BIG_TO_SHOW@@).

#### DebuggerInterfacePython.remoteClientVariables

remoteClientVariables(debuggerId, scope, filterList, framenr=0, maxSize=0)

Public method to request the variables of the debugged program.

debuggerId (str)
  ID of the debugger backend
scope (int)
  the scope of the variables (0 = local, 1 = global)
filterList (list of str)
  list of variable types to filter out
framenr (int)
  framenumber of the variables to retrieve
maxSize (int)
  maximum size the formatted value of a variable will be shown. If it is bigger than that, a 'too big' indication will be given (@@TOO_BIG_TO_SHOW@@).

#### DebuggerInterfacePython.remoteCompletion

remoteCompletion(debuggerId, text)

Public slot to get the a list of possible commandline completions from the remote client.

debuggerId (str)
  ID of the debugger backend
text (str)
  the text to be completed

#### DebuggerInterfacePython.remoteContinue

remoteContinue(debuggerId, special=False)

Public method to continue the debugged program.

debuggerId (str)
  ID of the debugger backend
special (bool)
  flag indicating a special continue operation

#### DebuggerInterfacePython.remoteContinueUntil

remoteContinueUntil(debuggerId, line)

Public method to continue the debugged program to the given line or until returning from the current frame.

debuggerId (str)
  ID of the debugger backend
line (int)
  the new line, where execution should be continued to

#### DebuggerInterfacePython.remoteCoverage

remoteCoverage(fn, argv, wd, erase=False)

Public method to load a new program to collect coverage data.

fn (str)
  the filename to run
argv (str)
  the commandline arguments to pass to the program
wd (str)
  the working directory for the program
erase (bool)
  flag indicating that coverage info should be cleared first

#### DebuggerInterfacePython.remoteEnvironment

remoteEnvironment(env)

Public method to set the environment for a program to debug, run, ...

env (dict)
  environment settings

#### DebuggerInterfacePython.remoteLoad

remoteLoad(fn, argv, wd, traceInterpreter=False, autoContinue=True, enableMultiprocess=False)

Public method to load a new program to debug.

fn (str)
  the filename to debug
argv (str)
  the commandline arguments to pass to the program
wd (str)
  the working directory for the program
traceInterpreter (bool)
  flag indicating if the interpreter library should be traced as well
autoContinue (bool)
  flag indicating, that the debugger should not stop at the first executable line
enableMultiprocess (bool)
  flag indicating to perform multiprocess debugging

#### DebuggerInterfacePython.remoteMoveIP

remoteMoveIP(debuggerId, line)

Public method to move the instruction pointer to a different line.

debuggerId (str)
  ID of the debugger backend
line (int)
  the new line, where execution should be continued

#### DebuggerInterfacePython.remoteNoDebugList

remoteNoDebugList(debuggerId, noDebugList)

Public method to set a list of programs not to be debugged.

The programs given in the list will not be run under the control of the multi process debugger.

debuggerId (str)
  ID of the debugger backend
noDebugList (list of str)
  list of Python programs not to be debugged

#### DebuggerInterfacePython.remoteProfile

remoteProfile(fn, argv, wd, erase=False)

Public method to load a new program to collect profiling data.

fn (str)
  the filename to run
argv (str)
  the commandline arguments to pass to the program
wd (str)
  the working directory for the program
erase (bool)
  flag indicating that timing info should be cleared first

#### DebuggerInterfacePython.remoteRawInput

remoteRawInput(debuggerId, inputString)

Public method to send the raw input to the debugged program.

debuggerId (str)
  ID of the debugger backend
inputString (str)
  the raw input

#### DebuggerInterfacePython.remoteRun

remoteRun(fn, argv, wd)

Public method to load a new program to run.

fn (str)
  the filename to run
argv (str)
  the commandline arguments to pass to the program
wd (str)
  the working directory for the program

#### DebuggerInterfacePython.remoteSetThread

remoteSetThread(debuggerId, tid)

Public method to request to set the given thread as current thread.

debuggerId (str)
  ID of the debugger backend
tid (int)
  id of the thread

#### DebuggerInterfacePython.remoteStatement

remoteStatement(debuggerId, stmt)

Public method to execute a Python statement.

debuggerId (str)
  ID of the debugger backend
stmt (str)
  the Python statement to execute.

#### DebuggerInterfacePython.remoteStep

remoteStep(debuggerId)

Public method to single step the debugged program.

debuggerId (str)
  ID of the debugger backend

#### DebuggerInterfacePython.remoteStepOut

remoteStepOut(debuggerId)

Public method to step out the debugged program.

debuggerId (str)
  ID of the debugger backend

#### DebuggerInterfacePython.remoteStepOver

remoteStepOver(debuggerId)

Public method to step over the debugged program.

debuggerId (str)
  ID of the debugger backend

#### DebuggerInterfacePython.remoteStepQuit

remoteStepQuit(debuggerId)

Public method to stop the debugged program.

debuggerId (str)
  ID of the debugger backend

#### DebuggerInterfacePython.remoteThreadList

remoteThreadList(debuggerId)

Public method to request the list of threads from the client.

debuggerId (str)
  ID of the debugger backend

#### DebuggerInterfacePython.remoteUTDiscover

remoteUTDiscover(syspath, workdir, discoveryStart)

Public method to perform a test case discovery.

syspath (list of str)
  list of directories to be added to sys.path on the remote side
workdir (str)
  path name of the working directory
discoveryStart (str)
  directory to start auto-discovery at

#### DebuggerInterfacePython.remoteUTPrepare

remoteUTPrepare(fn, tn, tfn, failed, cov, covname, coverase, syspath, workdir, discover, discoveryStart, testCases, debug)

Public method to prepare a new unittest run.

fn (str)
  name of file to load
tn (str)
  name of test to load
tfn (str)
  test function name to load tests from
failed (list of str)
  list of failed test, if only failed test should be run
cov (bool)
  flag indicating collection of coverage data is requested
covname (str)
  name of file to be used to assemble the coverage caches filename
coverase (bool)
  flag indicating erasure of coverage data is requested
syspath (list of str)
  list of directories to be added to sys.path on the remote side
workdir (str)
  path name of the working directory
discover (bool)
  flag indicating to discover the tests automatically
discoveryStart (str)
  directory to start auto-discovery at
testCases (list of str)
  list of test cases to be loaded
debug (bool)
  flag indicating to run unittest with debugging

#### DebuggerInterfacePython.remoteUTRun

remoteUTRun(debug, failfast)

Public method to start a unittest run.

debug (bool)
  flag indicating to run unittest with debugging
failfast (bool)
  flag indicating to stop at the first error

#### DebuggerInterfacePython.remoteUTStop

remoteUTStop()

Public method to stop a unittest run.

#### DebuggerInterfacePython.remoteWatchpoint

remoteWatchpoint(debuggerId, cond, setWatch, temp=False)

Public method to set or clear a watch expression.

debuggerId (str)
  ID of the debugger backend
cond (str)
  expression of the watch expression
setWatch (bool)
  flag indicating setting or resetting a watch expression
temp (bool)
  flag indicating a temporary watch expression

#### DebuggerInterfacePython.remoteWatchpointEnable

remoteWatchpointEnable(debuggerId, cond, enable)

Public method to enable or disable a watch expression.

debuggerId (str)
  ID of the debugger backend
cond (str)
  expression of the watch expression
enable (bool)
  flag indicating enabling or disabling a watch expression

#### DebuggerInterfacePython.remoteWatchpointIgnore

remoteWatchpointIgnore(debuggerId, cond, count)

Public method to ignore a watch expression the next couple of occurrences.

debuggerId (str)
  ID of the debugger backend
cond (str)
  expression of the watch expression
count (int)
  number of occurrences to ignore

#### DebuggerInterfacePython.setCallTraceEnabled

setCallTraceEnabled(debuggerId, on)

Public method to set the call trace state.

debuggerId (str)
  ID of the debugger backend
on (bool)
  flag indicating to enable the call trace function

#### DebuggerInterfacePython.shutdown

shutdown()

Public method to cleanly shut down.

It closes our sockets and shuts down the debug clients. (Needed on Win OS)

#### DebuggerInterfacePython.startRemote

startRemote(port, runInConsole, venvName, originalPathString, workingDir=None, configOverride=None)

Public method to start a remote Python interpreter.

port (int)
  port number the debug server is listening on
runInConsole (bool)
  flag indicating to start the debugger in a console window
venvName (str)
  name of the virtual environment to be used
originalPathString (str)
  original PATH environment variable
workingDir (str)
  directory to start the debugger client in
configOverride (dict)
  dictionary containing the global config override data

Return:
  client process object, a flag to indicate a network connection and the name of the interpreter in case of a local execution

Return Type:
  tuple of (QProcess, bool, str)

#### DebuggerInterfacePython.startRemoteForProject

startRemoteForProject(port, runInConsole, venvName, originalPathString, workingDir=None, configOverride=None)

Public method to start a remote Python interpreter for a project.

port (int)
  port number the debug server is listening on
runInConsole (bool)
  flag indicating to start the debugger in a console window
venvName (str)
  name of the virtual environment to be used
originalPathString (str)
  original PATH environment variable
workingDir (str)
  directory to start the debugger client in
configOverride (dict)
  dictionary containing the global config override data

Return:
  client process object, a flag to indicate a network connection and the name of the interpreter in case of a local execution

Return Type:
  tuple of (QProcess, bool, str)

Up

## createDebuggerInterfacePython3

createDebuggerInterfacePython3(debugServer, passive)

Module function to create a debugger interface instance.

debugServer (DebugServer)
  reference to the debug server
passive (bool)
  flag indicating passive connection mode

Return:
  instantiated debugger interface

Return Type:
  DebuggerInterfacePython

Up

## getRegistryData

getRegistryData()

Module function to get characterizing data for the supported debugger interfaces.

Return:
  list of tuples containing the client type, the client capabilities, the client file type associations and a reference to the creation function

Return Type:
  list of tuple of (str, int, list of str, function)

Up