Skip to main content

Web interface for Python's built-in PDB debugger

Project description

Web-PDB

Travis-CI tests PyPI version

Web-PDB is a web-interface for Python’s built-in PDB debugger. It allows to debug Python scripts remotely in a web-browser.

Features

  • Responsive design based on Bootstrap.

  • Python syntax highlighting with Prism (“Okaida” theme).

  • Supports all PDB features.

  • Standard input and output can be redirected to the web-console to interact with Python scripts remotely.

  • Current file box tracks current position in a file being executed. Red line numbers indicate breakpoints, if any.

  • Globals and Locals boxes show local and global variables in the current scope. Special variables that start and end with double underscores __ are excluded (you can always view them using PDB commands).

  • Human-readable Unicode literals for Python 2.

  • Command history that stores up to 10 last unique PDB commands (accessed by arrow UP/DOWN keys).

Web-PDB screenshot

Web-PDB console in Chrome browser

Usage

Install Web-PDB into your working Python environment:

pip install web-pdb

Insert the following line into your Python program at the point where you want to start debugging:

import web_pdb; web_pdb.set_trace()

The set_trace() call will suspend your program and open a web-UI at the default port 5555 (port value can be changed). Enter in your browser’s address bar: http://<your Python machine hostname or IP>:5555, for example http://monty-python:5555, and you should see the web-UI like the one on the preceding screenshot. Now you can use all PDB commands and features. Additional Current file, Globals and Locals information boxes help you better track your program runtime state.

Note: it is strongly recommended to work with the Web-PDB web-UI only in one browser session. With more than one browser window accessing the web-UI it can display incorrect data in one or more browser sessions.

Subsequent set_trace() calls can be used as hardcoded breakpoints.

Additionally, Web-PDB provides catch_post_mortem context manager that can catch unhandled exceptions raised within its scope and automatically start PDB post-mortem debugging session. For example:

import web_pdb

with web_pdb.catch_post_mortem():
    # Some error-prone code
    assert foo == bar, 'Oops!'

For more detailed info about the Web-PDB API read docstrings in the ./web_pdb/__init__.py file.

Note: Web-PDB periodically sends AJAX GET requests to /output/update endpoint. This is normal behaviour.

Considerations for Multithreading and Multiprocessing Programs

Multithreading

Web-PDB maintains one debugger instance that traces only one thread. You should not call set_trace() from different threads to avoid race conditions. Each thread needs to be debugged separately one at a time.

Multiprocessing

Each process can have its own debugger instance provided you call set_trace with a different port value for each process. This way you can debug each process in a separate browser tab/window. To simplify this you can use set_trace(port=-1) to select a random port between 32768 and 65536.

Compatibility

  • Python: 2.7, 3+

  • Browsers: Firefox, Chrome (all modern browsers should work)

License

MIT, see LICENSE.txt.

The debugger icon made by Freepik from www.flaticon.com is licensed by CC 3.0 BY.

Changelog

v.1.3.2 (2017-07-19)

  • Internal changes.

v.1.3.1 (2017-03-14)

  • Now if web-console data haven’t changed the back-end sends “null” response body instead of a 403 error.

v.1.3.0 (2016-12-12)

  • Implemented a multi-threaded WSGI server to increase responsiveness of the web-UI.

v.1.2.2 (2016-11-03)

  • Added deflate compression for data sent to a browser.

  • Attempt to fix Current file box auto-scrolling.

v.1.2.1 (2016-10-08)

  • Logger fix.

v.1.2.0 (2016-10-03)

  • Minor UI redesign.

  • Added a quick action toolbar and hotkeys for common commands.

  • Added a quick help dialog.

  • Breakpoints can be added/deleted with a click on a line number.

  • The Currrent file box is not auto-scrolled if the current line hasn’t changed.

  • Multiple set_trace() and post_mortem() calls are processed correctly.

  • Added random web-UI port selection with port=-1.

v.1.1.0 (2016-09-24)

  • Initial PyPI release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

web-pdb-1.3.2.tar.gz (197.6 kB view details)

Uploaded Source

Built Distributions

web_pdb-1.3.2-py3.6.egg (207.6 kB view details)

Uploaded Source

web_pdb-1.3.2-py2.py3-none-any.whl (202.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file web-pdb-1.3.2.tar.gz.

File metadata

  • Download URL: web-pdb-1.3.2.tar.gz
  • Upload date:
  • Size: 197.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for web-pdb-1.3.2.tar.gz
Algorithm Hash digest
SHA256 afd76d8e2bbaa61c403bbc2ea6fd402e4056dee21bdfb92944faa43d73c8c4ed
MD5 2e631033c2fe85b899a3e0df84f7b05e
BLAKE2b-256 0d60105a6011470e3ff0a90d1588de9c8b6c5498871cd103f8e06958ac8df5b6

See more details on using hashes here.

File details

Details for the file web_pdb-1.3.2-py3.6.egg.

File metadata

  • Download URL: web_pdb-1.3.2-py3.6.egg
  • Upload date:
  • Size: 207.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for web_pdb-1.3.2-py3.6.egg
Algorithm Hash digest
SHA256 d29211b58f792d2f214e815c873ad2de01d17924334aef0789140c13d93e8840
MD5 61b5d72f1dc3fe1a80ec92ce843e8906
BLAKE2b-256 39bac6c6410de0605901569693482a479e029e35aaf5a2e3c727b35310e3c597

See more details on using hashes here.

File details

Details for the file web_pdb-1.3.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for web_pdb-1.3.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 86db1eabc0caf9446bbf768c3d44a5da9463b13f0bf74409913e3b8aaf716709
MD5 5e3adccbffa24c496f01b7ca8932b5cf
BLAKE2b-256 d1315d658dfb8625ee4ba60b277b8297d66add53847950bdfe0d6cdf8d7e10f5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page