The documentation from version 39.5.17 of PLANTA project can be found in the new PLANTA Online Help.

From DB 39.5.11

Python Debugging

Problem

  • The complex options to create macros and value ranges give rise to manifold error sources. Resulting errors can only be identified by mere thinking through or by means of dialog messages.

Objectives

  • A debugger allows the error seeker to go through the program code line by line during execution or to stop at a particular position to check the values which have just been set and find errors in program operation.

Debugging with rpdb2 / Winpdb

Information

Start the Debugger

Information

  • The debugger can be used in each Python program, hence in
    • Python value ranges,
    • Python macros and
    • in external Python scripts
  • To do so, you can rely on the Debugger API or you can start the debugger via the Tools -> Python -> Start Winpdb Debugger menu item.

from ppms.debugging import start_embedded_debugger

def function_to_debug():
    # ...
    start_embedded_debugger(password='foobar')
    # ...

Graphic Debugging with Winpdb

Information

  • Winpdb is suitable for debugging PLANTA
  • If you have started the debugger as described above, you have to connect to Winpdb:
    • Select the Attach option in the File menu.
    • Enter the current password
    • Specify the address of the computer on which the script is running.
    • Select and connect debugger instance
  • Now a surface is displayed in the right window of which you can see the source text where the interruption took place.
  • You can navigate through the program using function keys. For more information on this, see the Controls menu entry.
  • Break points can be set via function key F9.
  • Via File -> Open Source, the path to a Python file in the Server directory can be specified in order to set break points within it

Tip:

  • In order to prevent the ongoing reloading of the GUI, the Python Service Functions in planta_server.conf must be deactivated by setting ENABLE_PY_SERVICE_FUNCTIONS to 0

Debugging with PyCharm

Information

  • "PyCharm Professional" contains a remote debugger which can be used to debug PLANTA as well

Start the Debugger

Information

  • First the remote debugging must be set up and restarted in PyCharm
  • Afterwards you can connect to the debugger via the Tools -> Python -> Connect with PyCharm Debugger menu item in PLANTA

From S 39.5.1

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().

From S 39.5.0

Python Debugging

Stop
  • In this server version, this function does not work.

Up to S 39.5.0

Python Debugging

Problem
  • The complex options to create macros and value ranges give rise to manifold error sources. Resulting errors can only be identified by mere thinking through or by means of dialog messages.

Objectives

  • A debugger allows the error seeker to go through the program code line by line during execution or to stop at a particular position to check the values which have just been set and find errors in program operation.
  • Download Winpdb Python Platform Independent Python Debugger

Manual Use of the Debuggers

Information
  • The debugger can be used in each Python program, hence in
    • Python value ranges,
    • Python macros and
    • in external Python scripts
  • To do so, it is inserted using the following line in the Python code:
import ppms_debug

ppms_debug.start_debugger(<string>)

Details

  • The <string> parameter represents a character chain here. It must start with a letter and must not contain any umlauts.
    • On one hand it represents a password for the protection of the connection between debugger and its GUI, on the other hand it is an identifier with the help of which you can establish the proper connection.
  • Winpdb is used as GUI.
  • If the script to be checked (including the inserted lines mentioned above) is started, you have 30 seconds to
    • open the Attach option in the File menu,
    • enter the password mentioned above in the dialog window,
    • specify the address of the computer on which the script is running, and
    • click on the entry displayed in the subsequent window.
  • Now a surface is displayed in the right upper window of which you can see the Python source text of the ppms_debug.py file.
    • To get a view on the script to be actually checked, click on the lower left window named Start in the entry under start_debugger.
  • You can navigate through the program using function keys. For more information on this, see the Controls menu entry.
  • Break points can be set via function key F9.

Automatic Use of the Debugger From PLANTA

Information
  • The debugger can be started from PLANTA via the Tools Activate Debugger menu item.
  • In the course of this, both the debugger server and the graphical surface (WINPDB) are started for debugging.
    • The target folder of the WINPDB debugger is stored in the @G99030 variable.

Topic attachments
I Attachment History Size Date Comment
Jpgjpg debugger_icon.JPG r1 1.0 K 2009-08-28 - 15:28 Debugging Icon

         PLANTA project









 
  • Suche in Topic-Namen

  • Suche in Topic-Inhalten
This site is powered by the TWiki collaboration platform Powered by Perl