epyunit :: debug :: pydevrdc :: PyDevRDC :: Class PyDevRDC
[hide private]
[frames] | no frames]

Class PyDevRDC

source code


Provides automation for remote debugging of external Python process with PyDev.

This particularly provides a prepared environment for cross-process debugging by 'pydevd'.

Instance Methods [hide private]
 
__init__(self, **kargs)
Create a control stub for a remote debugger.
source code
 
setDebugParams(self, **kargs)
Sets the parameters for debug.
source code
 
scanEclipseForPydevd(self, rootforscan=None, **kargs)
Scans filesystem directory tree of Eclipse for PyDev plugin containing 'pydevd'.
source code
 
startDebug(self, **kargs)
Starts remote debugging for PyDev.
source code
 
stopDebug(self)
Stops remote debugging for PyDev.
source code
 
setFork(self)
Prepares debugging after fork.
source code
 
__str__(self)
Prints current remote debug parameters.
source code
 
__repr__(self)
Prints the current representation of remote debug parameters.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Variables [hide private]
  _initok = False
Controls whether to be initialized.
  defaultargs = {}
  dgbargs_default = {'host': 'localhost', 'overwrite_prev_trace'...
Final default configuration arguments for a debug controller, see pydevd.settrace.
  pydevd_glob = 'org.python.pydev_[0-9]*.[0-9]*.[0-9]*/pysrc/pyd...
Subpath glob pattern of PyDev plugin.
  eclipse_glob = '/home/acue/eclipse'
Subpath glob pattern for any eclipse based PyDev installation.
  _clrargs = {'abs': True, 'non-existent': True, 'normpath': Tru...
Args for 'filesysobjects.clearPath'
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **kargs)
(Constructor)

source code 

Create a control stub for a remote debugger.

Search and load 'pydevd' for cross-process remote debugging.

Args:

**kargs:

debug:

Debug RDBG itself, developer output.

label=<name>:

An optional label for identifying the currrent instance. The label could be provided as debugging flag.

remotedebug:

Switches remote debugging support On/Off. Dependent of this parameter an internal call of startRemoteDebugExt is performed and a new instance initialized.

rootforscan:

Directory path for the module 'pydevd.py', else defaults of 'scanEclipseForPydevd'.

fpname:

The file path name of the main file for the current process, default:=callname.

label:

The label identifying the current process, default:=callname.

noargv:

Suppresses argv processing completely for the previous arguments. The testflags are still processed.

rdbg:

Same as '--rdbg', for additional processing see 'noargv'.

rdbgsrv:

Same as '--rdbg'srv, for additional processing see 'noargv'.

rdbgforward:

Same as '--rdbg-forward', for additional processing see 'noargv'.

rdbgroot:

Same as '--rdbg-root', for additional processing see 'noargv'.

rdbgsub:

Same as '--rdbg-sub', for additional processing see 'noargv'.

testflags:

Flags to force specific behaviour - mostly faulty - in order to test the module itself. So, do not use these if you do not know what these actually do.

These partially fail, but provide a sufficient part of the control flow for the aspect of interest.

ignorePydevd:

Debugging the initial bootstrap of an simulated external process. Ignores present loaded debug support. For debugging of the debug support.

ignorePydevdSysPath:

Debugging the initial bootstrap of an simulated external process. Ignores load by current 'sys.path'. For debugging of the debug support.

ignorePydevdCallParam:

Debugging the initial bootstrap of an simulated external process. Ignores current parameter for load. For debugging of the debug support.

verbose:

Display data for user parameters.
Returns:
Creates a proxy instance.
Raises:
passed through exceptions:
Overrides: object.__init__

setDebugParams(self, **kargs)

source code 

Sets the parameters for debug.

Args:
**kargs:

host:

Hostname where the debug server is running.

From pdevd.py: The user may specify another host, if the debug server is not in the same machine (default is the local host).

ignore:

When set to False success is mandatory, else an exception it raised. Set this to True/default, when in production systems.

port:

Port the debug server is listening on. From pdevd.py: Specifies which port to use for communicating with the server (note that the server must be started in the same port). Note: currently it's hard-coded at 5678 in the client

pydevdpath:

Required path pointing to directory for source of pydevd in PyDev subdirectory tree.

remotedebug:

Switches remote debugging support On/Off.

stderrToServer:

Sets whether stderr is directed to debugserver. From pdevd.py: When this is true, the stderr is passed to the debug server so that they are printed in its console and not in this process console.

stdoutToServer:

Sets whether stdout is directed to debugserver. From pdevd.py: When this is true, the stdout is passed to the debug server.

suspend:

If set to True, stops immediately after settrace() call, else at next valid break-condition. From pdevd.py: Whether a breakpoint should be emulated as soon as this function is called.

trace_only_current_thread:

From pdevd.py: Determines if only the current thread will be traced or all future threads will also have the tracing enabled.
Returns:
The location of pydevd.py
Raises:
AttributeError:

scanEclipseForPydevd(self, rootforscan=None, **kargs)

source code 
Scans filesystem directory tree of Eclipse for PyDev plugin containing 'pydevd'.

Scans for 'pydevd' required for subprocess debugging
by the Debug-Server of PyDev. See PyDev manual for
path reference, the default pattern for 'marketplace' installation is:
    ::

        eclipse/plugins/org.python.pydev_x.x.x/pysrc/pydevd.py

in case of drop-in installation
    ::

        eclipse/dropins/<pydev-dropin-name>/plugins/org.python.pydev_x.x.x/pysrc/pydevd.py

The matching versions could be varied by glob-expressions.

The provided parameters match as follows:
    ::

        rdbgroot := /path/to/eclipse
        rdbgsub  := org.python.pydev_x.x.x/pysrc/pydevd.py

The glue-hook depends on the type of installation and is determined
dynamically:
    ::

        dropin-install       := dropins/<pydev-dropin-name>/plugins
        market-place-install :=  plugins

Basically any path could be used, in particular a rdbgsub directory
containing a subset for 'pydevd.py' on a remote machine as stated
by the PyDev project for remote debugging of server processes. The
filesystem resolution is performed on a local filesystem only, but
could be performed by command line start of the headless process
on the remote machine too.

The path is the containment path of the file *pydevd.py* and has to be
included in the *sys.path* variable for activation.

The *scanEclipseForPydevd* method performs a search and returns the
absolute path in case of a match.

The search for the root directory into the Eclipse package installation
is performed in the following order and priority:

    1. **parameters**

       Consume call/command line parameters, ENV, and hard/coded.

       Parameter mix by environment variables as present:
       For the actual main control of environment variables
       refer to epyunit.checkRDbg.checkAndRemoveRDbgOptions.
        ::

           (rdbgroot or RDBGROOT) + ( rdbgsub or RDBGSUB )

        Contains the value for the option '--rdbg-root',
        either literal or as a 'glob' pattern.
        The following priorities are applied:

            1. CLI call option
            2. API call option
            3. RDBGROOT/RDBGSUB + missing from
            4. Code defaults

    2. **sys.path**

        Each separate path is tried with the sub-path pattern,
        first match wins.

    3. **PATH - which eclipse**

        Each separate path is tried with the sub-path pattern,
        first match wins.

    4. **<HOME>/eclipse/eclipse**

        A convention of the author, where the the path is
        a symbolic link to the executable.
        When present, the realpath is evaluated from the link.

    5. **search install directory - dropins**

        When 'ePyUnit' itself is installed as a drop-in within eclipse,
        the search is performed within the current Eclipse release
        only::

           os.path.dirname(__file__) + rdbgsub

        For example::

           eclipse/dropins/epyunit

The first match of containing directory for 'pydevd.py'
is returned, thus ambiguity in case of multiple occurrences
has to be avoided.

The pattern resolution into the PyDev dir is performed by the steps:
    ::

        0. <eclipse-root>/plugins/<rdbgsub>

        1. <eclipse-root>/dropins/<rdbgsub>

        2. <eclipse-root>/dropins/*/plugins/<rdbgsub>

Args:
    rootforscan: Start directory for tree-scan, either a
        single, multiple in PATH notation. Each path points
        to an Eclipse installation directory.

**kargs:
    altpat=(<literal>|<glob>): Alternative pattern, varies 'eclipse_glob',
        and 'pydevd_glob'.

    strict: Provided parameter has to match, else error.

        Default is to try all, when supplied params do not
        match default values are checked.

    version=(a,b,c): Provide version to be requested. It is recommended
        to combine this with 'strict'.

        The parameters 'altpat' and 'version' are EXOR.

        version=(a,b,c)
        a := [0-9]+
        b := [0-9]+
        b := [0-9]+

Returns:
    The location of pydevd.py

Raises:
    AttributeError:

__str__(self)
(Informal representation operator)

source code 
Prints current remote debug parameters.
Overrides: object.__str__

__repr__(self)
(Representation operator)

source code 
Prints the current representation of remote debug parameters.
Overrides: object.__repr__

Class Variable Details [hide private]

dgbargs_default

Final default configuration arguments for a debug controller, see pydevd.settrace.
Value:
{'host': 'localhost',
 'overwrite_prev_trace': False,
 'patch_multiprocessing': True,
 'port': 5678,
 'stderrToServer': True,
 'stdoutToServer': True,
 'suspend': False,
 'trace_only_current_thread': True}

pydevd_glob

Subpath glob pattern of PyDev plugin.
Value:
'org.python.pydev_[0-9]*.[0-9]*.[0-9]*/pysrc/pydevd.py'

_clrargs

Args for 'filesysobjects.clearPath'
Value:
{'abs': True,
 'non-existent': True,
 'normpath': True,
 'redundant': True,
 'shrink': True,
 'split': True}