• Stars
    star
    23
  • Rank 1,016,462 (Top 21 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 7 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Debug the whole project, particular app or file with only one terminal command. Also pdbe provides features to work with debugging in the Git style.

pdbe

Your favorite debugger to everywhere!

Release Build Python3 Python3

Medium Habrahabr

Getting started

What is pdbe

pdbe puts import pdb statement import pdb; pdb.set_trace() in specified python's file, files in directory and nested files in directory (files in directory, that located in another directory with files also).

Motivation

There could be a situations, when you need to debug project (i.e. super old framework with millions of code lines) for knowing how it works. So put import pdb statement with pdbe tools, run this project and handle any bunch of code.

How to install

$ pip3 install pdbe

Usage

Common usage

Import pdb statements into particular file:

$ pdbe --file path/to/file.py

As result you will see:

def first_function():
    import pdb; pdb.set_trace()
    ...

def second_function():
    import pdb; pdb.set_trace()
    ...

    def third_function():
        import pdb; pdb.set_trace()
        ...

Remove pdb statement from that file with:

$ pdbe --file path/to/file.py --clear

The same works with files in directories:

$ pdbe --dir path/to/dir-with-python-files

And clear:

$ pdbe --dir path/to/dir-with-python-files --clear

Flag --ew instead of --dir allows you to put import pdb statement into all python files in all directories (nested from specified).

Advanced usage

pdbe provides some commands, that seems like git's arsenal.

First of all, you can commit (save to ususing in future) state of import pdb statements:

$ pdbe --commit 'Commit message'

Then you are able to see logs (all logs of commits you did in your dev-history):

$ pdbe --log

The result will be something like that:

commit  | add336b6a204bb7b3abe76c296b67f92
date    | 23:17:00 29-01-2018
message | Commit message

And the final point is a checkout command, that can restore changes, that were bind to your commit:

$ pdbe --checkout add336b6a204bb7b3abe76c296b67f92

You are able to write not less 5 symbols of commit number (SHA).

Advanced flow example

To clearify how it works, imagine that you wrote pdbe --file path/to/file.py:

def first_function():
    import pdb; pdb.set_trace()
    ...

def second_function():
    import pdb; pdb.set_trace()
    ...

    def third_function():
        import pdb; pdb.set_trace()
        ...

That commited state of imports with:

$ pdbe --commit 'Commit message'

Next step is a clearing imports:

$ pdbe --file path/to/file.py --clear
def first_function():
    ...

def second_function():
    ...

    def third_function():
        ...

And now you do not need remember which file you did debug (you could go to the lunch) and put imports again.

Take a look at logs:

commit  | add336b6a204bb7b3abe76c296b67f92
date    | 23:17:00 29-01-2018
message | Commit message

And restore it with checkout command:

$ pdbe --checkout add336b6a204bb7b3abe76c296b67f92

Remember, all history of commits and it's data stored in hided folder called .pdbe, so do not forget put following line .pdbe/ to your .gitignore.

Configuration file

Pdbe supports a configurations. Configurations have the following view.

debugger=ipdb
ignore=migrations,fixtures,setup.py
#ignore=contributions,test_view.py

To use the configuration file, create a file called .pdberc within home directory (cd ~). And for now there are two points are supported:

  1. debugger to set ipdb (only ipdb is supported for now).
  2. ignore to set directories (files in this directory will never be handled by pdbe) and files. Use , symbol to separate content of this setting.

Also you are able to comment configuration line with # symbol.

Development

Install packages, that needed for testing:

$ pip3 install requirements-dev.txt

Run tests before development to be sure pdbe works properly:

$ python -m unittest discover tests

Follow codestyle with linters:

$ flake8 pdbe && pycodestyle pdbe && pylint pdbe

More Repositories

1

threads-net

Unofficial and reverse-engineered Threads (threads.net) Python API wrapper. Created for academic purposes and is not intended to be used in real software.
Python
422
star
2

diagrams-as-code

Diagrams as code: declarative configurations using YAML for drawing cloud system architectures.
Python
303
star
3

accessify

Python design kit: interfaces, declared exception throws, class members accessibility levels (private and protected methods for humans).
Python
108
star
4

django-telegram-login

The reusable Django application for Telegram authorization (also known as Telegram login).
Python
100
star
5

8-bit-computer-memory-init

Initialize the 8-bit computer memory with a program to be executed automatically on powering.
C++
65
star
6

heroku-load-balancer

Inexpensive load balancer to replace Herokuโ€™s built-in one. The way to host CPU-bound.
Python
65
star
7

stale-feature-branch-operator

Delete stale feature branches in a Kubernetes cluster.
Go
51
star
8

DuttyBot

University timetable bot.
Python
28
star
9

Rutetider

iOS, Android, Web-based and Telegram-bots timetable framework for universities. [not supported]
Python
23
star
10

utbone

Bones for faster unit testing based on the command line.
Python
13
star
11

github-story

Chrome and Firefox extension to use pull request description template with a single button click.
JavaScript
10
star
12

acg

Custom API-client based on any existing API from one configuration file.
Python
9
star
13

project-version

Explicit, strict and automatic project version management based on semantic versioning.
Python
5
star
14

DOU

Read dou.ua on your iPhone.
Swift
2
star