📜 ⬆️ ⬇️

ExConsole - Emergency Console for Python

The post promises to be super-short.

ExConsole allows you to embed an interactive console debugger into a Python application. The console is called upon a fatal exception or by receiving SIGQUIT (aka Ctrl- \).

Usage example:
')
import exconsole exconsole.register() do_dangerous_stuff() 


An example of working with the console:

 Activating emergency console ---------------------------- Caused by: ZeroDivisionError integer division or modulo by zero Stack frames: [ 0] example.py:17 [ 1] example.py:15 Tester().test() [ 2] example.py:9 self.inner() [ 3] example.py:6 self.divide(2, 0) > [ 4] example.py:3 return a / b On frame 4 Source: def divide(self, a, b): >> return a / b Press Ctrl-D to leave console Type "_help()"" for built-in commands >>> print a,b 2 0 >>> _f(3) On frame 3 Source: def inner(self): >> self.divide(2, 0) >>> print self <__main__.Tester instance at 0x7f67c9a0e440> 



The console supports moving through stack frames and working with local variables, and also allows you to exit and continue execution of the application.

Built-in commands:


Python 2.6+ and 3 are supported.
Packages for Debian and CentOS are available in the Ajenti repository.
Links: Github PyPI

Source: https://habr.com/ru/post/190924/


All Articles