[asterisk-commits] mjordan: testsuite/asterisk/trunk r3153 - /asterisk/trunk/lib/python/asterisk/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Mar 26 16:49:29 CDT 2012
Author: mjordan
Date: Mon Mar 26 16:49:25 2012
New Revision: 3153
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3153
Log:
Add some more error/exception handling to TestCase
Tweaked the exception/error handling some more in the AMI connect
handler. This should handle exceptions as well as calls to the
errback handler.
Modified:
asterisk/trunk/lib/python/asterisk/TestCase.py
Modified: asterisk/trunk/lib/python/asterisk/TestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/TestCase.py?view=diff&rev=3153&r1=3152&r2=3153
==============================================================================
--- asterisk/trunk/lib/python/asterisk/TestCase.py (original)
+++ asterisk/trunk/lib/python/asterisk/TestCase.py Mon Mar 26 16:49:25 2012
@@ -13,6 +13,7 @@
import os
import datetime
import time
+import traceback
from twisted.internet import reactor, defer
from twisted.python import failure
from starpy import manager, fastagi
@@ -346,7 +347,7 @@
if (self.reactor_timeout > 0):
self.timeoutId = reactor.callLater(self.reactor_timeout, self.__reactor_timeout)
- def ami_login_error(self, ami):
+ def ami_login_error(self, reason):
"""
Handler for login errors into AMI. This will stop the test.
@@ -354,9 +355,10 @@
ami -- The instance of AMI that raised the login error
"""
- logger.error("Error logging into AMI")
+ logger.error("Error logging into AMI: %s" % reason.getErrorMessage())
+ logger.error(reason.getTraceback())
self.stop_reactor()
- return failure.Failure()
+ return reason
def ami_connect(self, ami):
"""
@@ -368,7 +370,13 @@
def __ami_connect(self, ami):
logger.info("AMI Connect instance %s" % (ami.id + 1))
self.ami[ami.id] = ami
- self.ami_connect(ami)
+ try:
+ self.ami_connect(ami)
+ except:
+ logger.error("Exception raised in ami_connect:")
+ logger.error(traceback.format_exc())
+ self.stop_reactor()
+ return ami
def pcap_callback(self, packet):
"""
@@ -388,7 +396,7 @@
Keyword arguments:
reason -- The reason the originate failed
"""
- logger.error("Error sending originate:")
+ logger.error("Error sending originate: %s" % reason.getErrorMessage())
logger.error(reason.getTraceback())
self.stop_reactor()
return reason
More information about the asterisk-commits
mailing list