Python Debugging
Information
Remote debugging
- For server and client based applications it is often helpful to be able to carry out debugging from another site
Preparation
Information
- For the debug server, a current version of Eclipse with pydev must be installed.
- On part of the application, the
py/
Python directory of the PLANTA server is required, which contains a version of the pysrc/
directory which is prepared to a great extent and must be changed to the extent that it reflects the location of the debugging environment.
Procedure
Mapping of source code paths between Eclipse and the Python interpreter embedded in the PLANTA Server
- The
paths.py
file in the pysrc/
directory on your device must be changed.
- The
PATHS_FROM_ECLIPSE_TO_PYTHON
variable for debug client and server.
- Since the server knows its own working directory, the values defined by
os.path.abspath()
are correct and you only have to adjust the path to your local PLANTA Server Python code directory and the OLE directory of the client you wish to use (the working directory of your test system client with attached \Ole
subdirectory).
- The
DEBUG_CLIENT_SERVER_TRANSLATION
variable must be set to True
in the pydevd_file_utils.py
as well, which should already be the case in the version available via TFS.
Activate pydevd via
planta_server.conf
- To activate the debugger, you have to adjust both
config/planta_server.conf
in the server directory of your test system as well as the relevant parameters.
Parameter |
Type |
VALUE |
DEBUG_PYTHON |
boolean |
1 |
DEBUG_PYTHON_HOST |
string |
host use of Eclipse with PyDev |
DEBUG_PYTHON_PORT |
number |
same as configured in the remote debug server of PyDev. Please select an arbitrary value and do not use default value 5678 |
- The port of the Python debug server can be configured in Eclipse using Window Preferences PyDev Debug Port for remote debugger.
Connect to debug host
- In Eclipse, a debug view can be opened and the server can be started.
- The debug server must already run before the
planta_py_debug.debug_break()
function in the Python code is opened for the first time.
- Start PLANTA server and PLANTA client as soon as the server accepts connections.
- The application can now be debugged.
Set break point
-
planta_py_debug
und py_debug
from planta_py_debug
must be imported and the debug flag above py_debug.set_debug_flag(True)
must be enabled.
- Opening
planta_py_debug.debug_break()
in Python establishes a connection to Eclipse and enables you to set further break points in the future.
- Every call of
planta_py_debug.debug_break()
behaves like a programmed break point, which is why caution should be exercised here.
- Current limitation: Since DB resident, Python objects no longer exist on the server side in the form of actual files; PyDevd indicates that break points cannot be set although the setting of break points works flawlessly.
- When leaving a Python context, the Python runtime secedes under debug from the debug server. In order to return to the remote debugging you have to reopen
planta_py_debug.debug_break()
.