[asterisk-commits] pabelanger: testsuite/asterisk/trunk r680 - /asterisk/trunk/lib/python/asterisk/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Aug 2 10:11:27 CDT 2010
Author: pabelanger
Date: Mon Aug 2 10:11:23 2010
New Revision: 680
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=680
Log:
New install_configs() function and ability for backwards compatible configs
Add the ability to specify a config directory to be installed. Everything within
the directory, except the .svn, branch-1.4, branch-1.6.2 and branch-1.8
directories, will be copied over.
Also includes in functionality for backwards compatible config files. If a
sub-directory is found to be the same as the running instance, it will use that
version of .config file.
For example: If testsuite is running a test against 1.4 (branch-1.4):
configs/manager.conf
configs/sip.conf
configs/branch-1.4/sip.conf
Because the sip.conf file exists in the branch-1.4 directory, it will be used
in place of the top-level sip.conf. As for the manager.conf file, because it
does not exists in the branch-1.4 direcory, the top-level manager.conf will
be used.
Review: https://reviewboard.asterisk.org/r/831/
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=680&r1=679&r2=680
==============================================================================
--- asterisk/trunk/lib/python/asterisk/asterisk.py (original)
+++ asterisk/trunk/lib/python/asterisk/asterisk.py Mon Aug 2 10:11:23 2010
@@ -138,14 +138,38 @@
self.process.wait()
return self.process.returncode
- def install_config(self, cfg_path):
- """Install a custom configuration file for this instance of Asterisk.
+ def install_configs(self, cfg_path):
+ """Installs all files located in the configuration directory for this
+ instance of Asterisk.
By default, the configuration used will be whatever is found in the
system install of Asterisk. However, custom configuration files to be
used only by this instance can be provided via this API call.
Keyword Arguments:
+ cfg_path -- This argument must be the path to the configuration directory
+ to be installed into this instance of Asterisk.
+
+ Example Usage:
+ asterisk.install_configs("tests/my-cool-test/configs")
+ """
+ for dirname, dirnames, filenames in os.walk(cfg_path):
+ blacklist = [ ".svn", "branch-1.4", "branch-1.6.2", "branch-1.8" ]
+ for b in blacklist:
+ if b in dirnames:
+ dirnames.remove(b)
+ for filename in filenames:
+ target = "%s/%s" % (dirname, filename)
+ self.install_config(target)
+
+ def install_config(self, cfg_path):
+ """Install a custom configuration file for this instance of Asterisk.
+
+ By default, the configuration used will be whatever is found in the
+ system install of Asterisk. However, custom configuration files to be
+ used only by this instance can be provided via this API call.
+
+ Keyword Arguments:
cfg_path -- This argument must be the path to the configuration file
to be installed into the directory tree for this instance of Asterisk.
@@ -155,6 +179,10 @@
if not os.path.exists(cfg_path):
print "Config file '%s' does not exist" % cfg_path
return
+
+ tmp = "%s/%s/%s" % (os.path.dirname(cfg_path), self.ast_version.branch, os.path.basename(cfg_path))
+ if os.path.exists(tmp):
+ cfg_path = tmp
target_path = os.path.join(self.astetcdir, os.path.basename(cfg_path))
if os.path.exists(target_path):
os.remove(target_path)
@@ -302,4 +330,3 @@
for dirname, dirnames, filenames in os.walk(ast_dir_path):
for d in dirnames:
self.__makedirs(os.path.join(target_dir, dirname, d))
-
More information about the asterisk-commits
mailing list