[asterisk-commits] kmoore: testsuite/asterisk/trunk r3601 - /asterisk/trunk/lib/python/asterisk/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 7 13:31:44 CST 2013


Author: kmoore
Date: Mon Jan  7 13:31:40 2013
New Revision: 3601

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3601
Log:
Make AMIEventModule more tolerant of missing sections

This prevents AMIEventModule from throwing an exception if the
'requirements' configuration section does not exist in the YAML
configuration. It can currently handle empty 'match' and 'nomatch'
sections, so it should also be able to handle the lack of a
'requirements' section.

Modified:
    asterisk/trunk/lib/python/asterisk/ami.py

Modified: asterisk/trunk/lib/python/asterisk/ami.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/ami.py?view=diff&rev=3601&r1=3600&r2=3601
==============================================================================
--- asterisk/trunk/lib/python/asterisk/ami.py (original)
+++ asterisk/trunk/lib/python/asterisk/ami.py Mon Jan  7 13:31:40 2013
@@ -144,10 +144,14 @@
     def __init__(self, instance_config, test_object):
         super(AMIHeaderMatchInstance, self).__init__(instance_config, test_object)
         logger.debug("Initializing an AMIHeaderMatchInstance")
-        self.match_requirements = (
-                instance_config['requirements'].get('match', {}))
-        self.nonmatch_requirements = (
-                instance_config['requirements'].get('nomatch', {}))
+        if 'requirements' in instance_config:
+            self.match_requirements = (
+                    instance_config['requirements'].get('match', {}))
+            self.nonmatch_requirements = (
+                    instance_config['requirements'].get('nomatch', {}))
+        else:
+            self.match_requirements = {}
+            self.nonmatch_requirements = {}
 
     def event_callback(self, ami, event):
         for k,v in self.match_requirements.items():




More information about the asterisk-commits mailing list