From 53b59aa2cf78d465f471916c7fae60b9f212840b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 11 Feb 2009 18:44:57 +0100 Subject: Use convenience function for finding setup_dir based on location of python module. --- source4/scripting/python/samba/provision.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source4/scripting') diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 1d7011d305..d77b487512 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -45,6 +45,23 @@ from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError, \ __docformat__ = "restructuredText" + +def find_setup_dir(): + """Find the setup directory used by provision.""" + dirname = os.path.dirname(__file__) + if "/site-packages/" in dirname: + prefix = dirname[:dirname.index("/site-packages/")] + for suffix in ["share/setup", "share/samba/setup", "setup"]: + ret = os.path.join(prefix, suffix) + if os.path.isdir(ret): + return ret + # In source tree + ret = os.path.join(dirname, "../../../setup") + if os.path.isdir(ret): + return ret + raise Exception("Unable to find setup directory.") + + DEFAULTSITE = "Default-First-Site-Name" class InvalidNetbiosName(Exception): -- cgit