This guide is a short review of Python Layer 1 (L1) shell 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 CMD
You 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
- Click Open and select the shell's root folder. For example, C:\Program Files (x86)\QualiSystems\CloudShell\Server\Drivers\cloudshell-L1-driver_example.
- Specify the Project interpreter from the shell's virtualenv. Set the python executable from the shell's folder, for example, C:\Program Files (x86)\QualiSystems\CloudShell\Server\Drivers\cloudshell-L1-driver_example\Scripts\python.exe
- Edit the shell's Runtime Configuration - 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 shell's python process. Find the PID (process id) of the shell's driver process in the commands log and kill it in Task Manager.
- Specify breakpoints in the shell project's source files.
- Use CloudShell to call one of the shell's commands. For example, call Autoload in Resource Manager Client.
- In the shell's commands log, find the PID of the driver process.
- Attach PyCharms debugger to the driver process. In PyCharm, click Run>Attach to LocalProcess and select the process with the same PID you found in the commands log.
- Wait until it stops on the breakpoint.