Thursday, October 25, 2012

Debugging Asterisk AGI in Python

Here is a one-liner that can literally save you days when developing a new asterisk AGI script in Python.

sys.stderr = open('/tmp/ast_agi_err.txt', 'w')

What it does is that it redirects STDERR to a file in /tmp so you can see the python console output after an un-handled  exception for example, that resulted in your agi script terminating early.
These kind of errors are not easy to find even with agi debug on, and can have you "scratching your head"  for hours if not days when debugging a new agi script