Git Product home page Git Product logo

epdb's Introduction

Overview

Adds functionality to the python debugger, including support for remote debugging

Installation

pip install epdb

Usage

For debugging code locally, epdb generally works the same as pdb. You can debug a program from the python interpreter:

>>> import epdb
>>> import mymodule
>>> epdb.Epdb().run('mymodule.test()')
*** NameError: name 'execfile' is not defined
> /home/wasche/git/epdb/<string>(1)<module>()
-> """
(Epdb) continue
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib64/python3.5/bdb.py", line 431, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "/home/wasche/git/epdb/mymodule.py", line 2, in test
    import spam
ImportError: No module named 'spam'

You can also drop breakpoints at specific places in a program's code by inserting:

import epdb; epdb.set_trace()

or by using the alias st:

import epdb; epdb.st()

To debug code that is either running on a remote system, or in a process that isn't attached to your tty you can use epdb in server mode:

import epdb; epdb.serve()

By default epdb.serve() will start a simple telnet server on port 8080, but you can use the port keyword argument to use a different port:

import epdb; epdb.serve(port=8888)

You can connect to the epdb server by using epdb.connect():

>>> import epdb
>>> epdb.connect()

By default epdb.connect() will attempt to connect to port 8080 on localhost. If you are debugging a process on another host or port, you can call connect with the host or port keyword arguments:

>>> import epdb
>>> epdb.connect(host='some.host.com', port=8888)

Known Issues

  • epdb.serve() does not work with python 2.7.5 [#7]

epdb's People

Contributors

elliotpeele avatar mibanescu avatar mtharp avatar wfscheper avatar xbcsmith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

epdb's Issues

epdb.serve() does not work on python 3.x

The server waits on the socket, but as soon as a client connects, it terminates.

Some debugging shows the problem to be in SavedFile.save() - fdopen() has changed behavior to not allow opening an fd in read/write mode, because they're not seekable.

Remote debugging fails to connect

I installed latest epdb and did a test run. Had a sample file like this:

import epdb
epdb.serve(port=8124)
print("Hello World")

Started this on one terminal:

$ ~/python/bin/python /tmp/t.py
Starting epdb server

When I tried to connect to this from another terminal, it kept disconnecting:

$ ~/python/bin/python -c 'import epdb; epdb.connect(port=8124)'
> /tmp/t.py(3)<module>()
-> print("Hello World")
(Epdb) *** Connection closed by remote host ***

On the server side, I don't see any error. I even tried to put the serve call in an exception block, but there was no exception.

When I used telnet I was able to connect:

 telnet localhost 8124
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
> /tmp/t.py(3)<module>()
-> print("Hello World")
(Epdb)

(Epdb)
(Epdb)

However, this has the issue that pressing <CR> ends up sending extra blank line or something like that. E.g., typing next ends up running it twice (the second time for the extra blank line), so this is not a very good workaround.

Remote debugging breaks but does not enter the debugger

I am trying to debug an ansible module.
I run the playbook and then connect:

$ python3.6 -c 'import epdb; epdb.connect()'
> /Users/stephen/test/provisioning_ansible/env/lib/python3.8/site-packages/pyvcloud/vcd/vdc.py(2056)create_gateway_api_version_31()
-> gateway_params = E.EdgeGateway(name=name)
n
c
s

As you can see it never enters (Epdb)

When I C-c (Ctrl-c) the following error is show:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/epdb/__init__.py", line 1091, in connect
    t.interact()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/epdb/epdb_client.py", line 117, in interact
    neededWriters, [])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/epdb/epdb_client.py", line 82, in ctrl_c
    self.sock.sendall('close\n')
TypeError: a bytes-like object is required, not 'str'

Is there something I need to do extra?

Trying to use this on macbook

I use epdb to debug ansible modules on my Ubuntu server without any problems but I can't seem to get it to work on my mac. I am hoping someone maintaining this project can give me some ideas.

When I connect to localhost 8080 it connects but then just hangs.

Connected to localhost.
Escape character is '^]'.

I have tried playing with the telnet mode to make sure it is set to character but I don't get the epdb debug shell.

Submit ebdb to PyPi (sdist)

Submitting to PyPi will ensure that the 'epdb' package name is reserved, and that the package is installable via pip/easy_install/etc

Please include (in the sdist):

  • LICENCE file
  • Test suite/files (if present)

Documentation?

This looks like an interesting project but I have no idea how to use it.

Where can I start learning about epdb?

Feature request: silent mode

Hello.

Thanks for your work!

Could you please implement some option to prevent messages to process' stdout?

I use epdb as remote debugger with epdb.serve().
When telnet server is started, it spits out Serving on port... to debugged process' stdout (here).
But my process must produce valid JSON as its output.

I commented out this line to prevent printing, but may be there is better way to control epdb's silent mode.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.