Customizing

Python Debugging

Problem

  • The complex options to create macros and value ranges give rise to manifold error sources. Any errors that occur can only be identified with a great deal of effort through pure thinking or 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 any 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.

Python
from ppms.debugging import start_embedded_debugger

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

Graphical 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 displaying the source text at which 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 repetitive 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