[asterisk-commits] russell: testsuite/asterisk/trunk r349 - /asterisk/trunk/lib/python/asterisk/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 4 14:41:42 CDT 2010


Author: russell
Date: Fri Jun  4 14:41:39 2010
New Revision: 349

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=349
Log:
Make Asterisk.stop() more graceful by starting with "core stop gracefully"

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

Modified: asterisk/trunk/lib/python/asterisk/asterisk.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/asterisk.py?view=diff&rev=349&r1=348&r2=349
==============================================================================
--- asterisk/trunk/lib/python/asterisk/asterisk.py (original)
+++ asterisk/trunk/lib/python/asterisk/asterisk.py Fri Jun  4 14:41:39 2010
@@ -19,6 +19,8 @@
 import subprocess
 
 from config import ConfigFile
+
+from version import AsteriskVersion
 
 
 class Asterisk:
@@ -49,6 +51,8 @@
         self.asterisk = Asterisk(base=os.path.join(os.getcwd(),
                                                    "tests/ami-login/tmp"))
         """
+        self.ast_version = AsteriskVersion()
+
         self.astetcdir = "/etc/asterisk"
         # Find the system installed asterisk.conf
         ast_confs = [
@@ -114,6 +118,10 @@
         Example Usage:
         asterisk.stop()
         """
+        if self.ast_version < AsteriskVersion("1.6.0"):
+            self.cli_exec("stop gracefully")
+        else:
+            self.cli_exec("core stop gracefully")
         try:
             os.kill(self.process.pid, signal.SIGTERM)
             time.sleep(5.0)
@@ -160,13 +168,10 @@
         Example Usage:
         asterisk.cli_exec("core set verbose 10")
         """
-        cmd = [
-            "asterisk",
-            "-C", "%s" % os.path.join(self.astetcdir, "asterisk.conf"),
-            "-rx", "%s" % cli_cmd
-        ]
+        cmd = 'asterisk -C %s -rx "%s"' % \
+                (os.path.join(self.astetcdir, "asterisk.conf"), cli_cmd)
         print "Executing %s ..." % cmd
-        process = subprocess.Popen(cmd)
+        process = subprocess.Popen(cmd, shell=True)
         process.wait()
 
     def __gen_ast_conf(self, ast_conf, dir_cat):




More information about the asterisk-commits mailing list