Step 1 : configure debug server in Pycharm
Go to Run => Edit Configurations, click on "+" => Python Remote Debug
In "Local Host name " enter ip or host name of your local machine. Enter a available port in "Port :"
Give a name, here it's "NSO debug".
Click ok.
Step 2 : install pydevd_pycharm
The debug tool uses pydevd-pycharm library to attach to the local debug server we just created.
Run
python -m pip install pydevd-pycharm
with the python interpreter used by NSO.
Step 3 : run debug server
Select NSO Debug and click on the green bug (or Shift + F9).
The debug server is now listening on port 8885
Step 4 : call the server from the service/action thread.
Insert the following code in the callback function of the service/action (change host and port) :
import pydevd_pycharm
pydevd_pycharm.settrace('host', port=port, stdoutToServer=True, stderrToServer=True)
That's all , now the service/action callback will try to reach the debug server (don't forget to do a packages reload)
You can now debug with pycharm :
And have full information about the variables :