[asterisk-commits] jpeeler: branch jpeeler/event_watcher r285 - in /asterisk/team/jpeeler/event_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 5 17:49:02 CDT 2010


Author: jpeeler
Date: Wed May  5 17:48:59 2010
New Revision: 285

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=285
Log:
move client module into lib/python and parse passed arguments to determine if standalone or not

Added:
    asterisk/team/jpeeler/event_watcher/lib/python/client.py   (contents, props changed)
      - copied, changed from r283, asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py
Removed:
    asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py
Modified:
    asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test

Copied: asterisk/team/jpeeler/event_watcher/lib/python/client.py (from r283, asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py)
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/jpeeler/event_watcher/lib/python/client.py?view=diff&rev=285&p1=asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py&r1=283&p2=asterisk/team/jpeeler/event_watcher/lib/python/client.py&r2=285
==============================================================================
--- asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py (original)
+++ asterisk/team/jpeeler/event_watcher/lib/python/client.py Wed May  5 17:48:59 2010
@@ -5,13 +5,8 @@
 from starpy import manager, fastagi, utilapplication, menu
 import os, logging, pprint, time, sys, threading
 
-try:
-    sys.path.append("lib/python")
-    from asterisk.asterisk import Asterisk
-    STANDALONE = False
-except ImportError:
-    print "Running in standalone mode"
-    STANDALONE = True
+sys.path.append("lib/python")
+from asterisk.asterisk import Asterisk
 
 """
 This module is meant to be instantiated and then the following methods
@@ -101,7 +96,7 @@
         self.asterisk.cli_exec("core set debug 3")
 
     def stop_asterisk(self):
-        if not STANDALONE:
+        if not self.standalone:
             self.asterisk.stop()
 
     def clear_vars(self):
@@ -119,13 +114,14 @@
         self.passed = True
         self.call_id = None
         self.timeout_sec = 5
+        self.standalone = False
 
         self.reactor_lock = threading.Lock()
         self.reactor_stopped = False
 
         self.clear_vars()
 
-        if STANDALONE:
+        if self.standalone:
             return
 
         self.log.info("Creating Asterisk instance...")
@@ -134,6 +130,12 @@
         self.asterisk.install_config("tests/ami-monitor/configs/logger.conf")
 
         self.start_asterisk()
+
+    def set_standalone(self, value):
+        if value == True:
+            self.log.debug("Running in standalone mode")
+            print "Running in standalone mode"
+        self.standalone = value
 
     def set_timeout(self, seconds):
         self.timeout_sec = seconds

Propchange: asterisk/team/jpeeler/event_watcher/lib/python/client.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/jpeeler/event_watcher/lib/python/client.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/team/jpeeler/event_watcher/lib/python/client.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/jpeeler/event_watcher/lib/python/client.py
------------------------------------------------------------------------------
    svn:mergeinfo = 

Propchange: asterisk/team/jpeeler/event_watcher/lib/python/client.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test?view=diff&rev=285&r1=284&r2=285
==============================================================================
--- asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test (original)
+++ asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test Wed May  5 17:48:59 2010
@@ -7,6 +7,9 @@
 from twisted.internet import reactor
 from starpy import manager, fastagi, utilapplication, menu
 import os, logging, pprint, time, sys
+
+from optparse import OptionParser
+
 
 """
 This test module should serve as a template for new event monitoring tests. A
@@ -25,7 +28,10 @@
         event_send = {'Action' : 'ping'}
         watcher.add_send_event(event_send)
 
-def main():
+def main(argv=None):
+    if argv is None:
+        argv = sys.argv
+
     logging.basicConfig()
 
     watcher = client.EventWatcher()
@@ -33,6 +39,15 @@
 
     #watcher.log.setLevel(logging.DEBUG)
     #manager.log.setLevel(logging.DEBUG)
+
+
+    if len(argv) == 1: # options are NOT being passed
+        watcher.set_standalone(True)
+    else:
+        parser = OptionParser()
+        parser.add_option("-v", "--version", dest="ast_version",
+                              help="Asterisk version string")
+        (options, args) = parser.parse_args(argv)
 
     watcher.set_test_obj(tester)
     watcher.set_timeout(5)




More information about the asterisk-commits mailing list