This guide is a short review of Python Layer 1 (L1) driver debugging process.
To attach PyCharms debugger to the driver process called by CloudShell it should be run as SYSTEM. An easy way to get a CMD prompt as SYSTEM is to grab PSEXEC from Microsoft Sysinternals:
- Download PSEXEC and unzip to some folder.
- Open an elevated CMD prompt as an administrator.
- Navigate to the folder where you unzipped PSEXEC.EXE
- Run:
PSEXEC -i -s -d CMDYou will have a new CMD prompt open, as SYSTEM
- Run PyCharm in the opened CMD:
C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.4\bin\pycharm.exe- Press Open and select the driver folder, like C:\Program Files (x86)\QualiSystems\CloudShell\Server\Drivers\cloudshell-L1-driver_example
- Specify Project interpreter from the driver virtualenv. Set python executable from the driver folder, like C:\Program Files (x86)\QualiSystems\CloudShell\Server\Drivers\cloudshell-L1-driver_example\Scripts\python.exe
- Edit Runtime Configuration of the driver C:\Program Files (x86)\QualiSystems\CloudShell\Server\Drivers\cloudshell-L1-driver_example\driver_example_RuntimeConfig.yml
- Specify DEBUG_ENABLED option to TRUE
DEBUG_ENABLED: TRUE- Kill the python process of the driver. Find the PID (process id) of the driver process in the commands log and kill it in the Task Manager.
- Specify breakpoints in the driver project's source files.
- Use CloudShell to call a driver commands. For example, call Autoload in ResourceManager.
- Find in the commands log of the driver the PID of the driver process.
- Attach PyCharms debugger to the driver process. In PyCharm press Run>Attach to LocalProcess and choose the process with the same PID you found in the commands log.
- Wait until it stops on the breakpoint.