Skip to content

Instantly share code, notes, and snippets.

@charlieknoll
Last active April 15, 2020 21:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charlieknoll/a2ee69befa846e17b69bdea12474cd73 to your computer and use it in GitHub Desktop.
Save charlieknoll/a2ee69befa846e17b69bdea12474cd73 to your computer and use it in GitHub Desktop.
Debugging Rotki

Debugging Rotki

First be sure you can run rotki locally using the build from source install directions

Setting up the python backend for debugging

  • Open the root rotki folder in a vscode instance
  • Install the Python vscode extension
  • Create a new launch configuration (Run -> Add configuration...) of type Python
  • Update the launch.json:
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Python Backend",
      "type": "python",
      "request": "launch",
      "module": "rotkehlchen",
      "env": {
        "GEVENT_SUPPORT": "True"
      },
      "args": [
        "--api-port",
        "4242",
        "--api-cors",
        "http://localhost:8080",
        // "--data-dir",
        // "${workspaceFolder}\\data-dir"
      ]
    }
  ]
}
  • Press Ctrl+Shift+P and select Python:Select Interpreter
  • Select your phython virtual environment for the rotki app
  • Verify in the status bar at the bottom of vscode that the virtual env and correct debug configuration is selected
  • Set a breakpoint in the unlock_user function in rotkehlchen.py (Press Ctrl+P to search for files)
  • Open the Run panel, select Python Backend from the dropdown in the header and press the green arrow to start debugging
  • Vscode should open a new "Python Debug Console" terminal window and you should see the message Rotki API server is running at: 127.0.0.1:4242

Debugging the backend using the frontend in a debugger process

  • Open a new instance of vscode and open the electron-app directory
  • Ensure the Debugger for Chrome vscode extension is installed
  • Follow the instructions here
  • Add the env section to the "Electron:Main" configuration (updating the VIRTUAL_ENV directory as necessary):
      "env": {
        //"IS_TEST": "true",
        "VIRTUAL_ENV": "C:\\Users\\Charlie\\Envs\\rotki",
        "SKIP_PYTHON_BACKEND": "True"
      },
  • Update your vue.config to point to the dist_electron directory -OR- update your launch.json args and outFiles to point to the ./dist directory
  • Set a breakpoint at the first line of the createPyProc function in py_handler.ts
  • Set a breakpoint at the first line of the created lifecycle handler in App.vue

TIP: Be sure to shutdown any Chrome instances that you have running that were started in debug mode

  • Open the Run panel, select Electron All from the dropdown in the header and press the green arrow to start debugging
  • Vscode will start an electron-debug task terminal and you should see the app building

TIP: If you update any of the electron-app .ts files that run outside of the packaged vue app (e.g. py-handler.ts) you should press Ctrl+C then spacebar in the electron-debug task terminal so that the electron app is rebuilt

  • Your breakpoint should be hit in py-handler.ts and if you step through you should see it skipping starting the python child process
  • Press F5 to continue running the electron app then you should see the Rotki app start up and present the login with Developer Tools window started as well
  • Click View->Reload in the Rotki app and you should see the breakpoint hit in the App.vue created handler, press F5 to continue running
  • Log in to Rotki and you should see the breakpoint hit in the python backend vscode debugger process
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment