cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1848
Views
10
Helpful
0
Comments
Rodolphe Trujillo
Cisco Employee
Cisco Employee

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.

nso-debug-server.png

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

run-debug-server.PNG

The debug server is now listening on port 8885

running-debug-server.png

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)

code-callback.png

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 :

running-debug-1.PNG

And have full information about the variables :

running-debug-variables.PNG

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community:

Quick Links