[svn-commits] jpeeler: branch jpeeler/event_watcher r243 - /asterisk/team/jpeeler/event_wat...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Apr 22 15:12:19 CDT 2010
Author: jpeeler
Date: Thu Apr 22 15:12:16 2010
New Revision: 243
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=243
Log:
change logging to not be global so module importing works properly
Modified:
asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py
asterisk/team/jpeeler/event_watcher/tests/ami-monitor/test.py
Modified: asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py?view=diff&rev=243&r1=242&r2=243
==============================================================================
--- asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py (original)
+++ asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py Thu Apr 22 15:12:16 2010
@@ -8,8 +8,6 @@
import subprocess
-log = logging.getLogger('TestAMI')
-log.setLevel(logging.INFO)
class EventWatcher(propertied.Propertied):
@@ -17,6 +15,8 @@
self.eventList = list()
self.count = 0
self.ordered = False
+ self.log = logging.getLogger('TestAMI')
+ self.log.setLevel(logging.INFO)
def set_ordered(self, ordered):
self.ordered = ordered
@@ -63,7 +63,7 @@
self.show_events()
def onAMIFailure(self, ami):
- log.critical("Stop asterisk")
+ self.log.critical("Stop asterisk")
def onAMIConnect(self, ami):
"""Register for AMI events"""
@@ -71,25 +71,25 @@
# interface will just stop generating events), not a practical
# problem at the moment, but should have a periodic check to be sure
# the interface is still up, and if not, should close and restart
- log.debug('onAMIConnect')
+ self.log.debug('onAMIConnect')
ami.status().addCallback(self.onStatus, ami=ami)
if len(self.eventList) == 0:
- log.critical("No events to monitor!")
+ self.log.critical("No events to monitor!")
ami.registerEvent(None, self.onAnyEvent)
def onAnyEvent(self, ami, event):
- log.critical("DEBUG: RUNNING onAnyEvent")
+ self.log.critical("DEBUG: RUNNING onAnyEvent")
if not self.ordered:
for next_events in self.eventList:
for next_event in next_events:
- #log.critical("DEBUG: Looking at %s of type %s and count %s" % (next_events, type(next_events), len(next_events)))
+ #self.log.critical("DEBUG: Looking at %s of type %s and count %s" % (next_events, type(next_events), len(next_events)))
if self.dict_in_dict(event, next_event):
next_event.update({"match": time.time()})
- log.critical("new event %s" % next_event)
+ self.log.critical("new event %s" % next_event)
self.count = self.count - 1
if self.count == 0:
self.stopMonitoring(ami)
@@ -98,7 +98,7 @@
for next_event in self.eventList[index]:
if self.dict_in_dict(event, next_event):
next_event.update({"match": time.time()})
- log.critical("new event %s" % next_event)
+ self.log.critical("new event %s" % next_event)
self.count = self.count - 1
if self.count == 0:
self.stopMonitoring(ami)
@@ -108,15 +108,15 @@
ami.deregisterEvent(None, None)
if reactor.running:
reactor.stop()
- log.critical("DONE")
+ self.log.critical("DONE")
def onStatus(self, events, ami=None):
- log.debug("Initial channel status retrieved")
+ self.log.debug("Initial channel status retrieved")
if events:
- log.critical("Test expects no channels to have started yet, aborting!")
+ self.log.critical("Test expects no channels to have started yet, aborting!")
self.stopMonitoring(ami)
for event in events:
- log.debug("Received event: %s", event)
+ self.log.debug("Received event: %s", event)
APPLICATION = utilapplication.UtilApplication()
@@ -129,10 +129,10 @@
def main():
logging.basicConfig()
- log.setLevel(logging.DEBUG)
manager.log.setLevel(logging.DEBUG)
watcher = EventWatcher()
+ watcher.log.setLevel(logging.DEBUG)
#scenario 1 with optional event matching
#event1 = [{'event' : 'Alarm', 'channel' : '18' }]
Modified: asterisk/team/jpeeler/event_watcher/tests/ami-monitor/test.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/jpeeler/event_watcher/tests/ami-monitor/test.py?view=diff&rev=243&r1=242&r2=243
==============================================================================
--- asterisk/team/jpeeler/event_watcher/tests/ami-monitor/test.py (original)
+++ asterisk/team/jpeeler/event_watcher/tests/ami-monitor/test.py Thu Apr 22 15:12:16 2010
@@ -1,7 +1,6 @@
#! /usr/bin/env python
-#import client
-from client import *
+import client
import sys
from twisted.application import service, internet
@@ -13,7 +12,8 @@
def main():
- watcher = EventWatcher()
+ logging.basicConfig()
+ watcher = client.EventWatcher()
#scenario 2 with optional event matching
event1 = [{'event' : 'Alarm', 'channel' : '18' }]
More information about the svn-commits
mailing list