summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/param/tests/bindings.py20
-rw-r--r--source4/scripting/python/samba/provision.py4
-rw-r--r--source4/scripting/python/samba/samba3.py12
-rw-r--r--source4/scripting/python/samba/tests/samba3.py24
-rwxr-xr-xsource4/setup/provision2
5 files changed, 38 insertions, 24 deletions
diff --git a/source4/param/tests/bindings.py b/source4/param/tests/bindings.py
index d1d71e4485..41a67f93fc 100644
--- a/source4/param/tests/bindings.py
+++ b/source4/param/tests/bindings.py
@@ -50,23 +50,3 @@ class LoadParmTestCase(unittest.TestCase):
file = param.LoadParm()
file.load_default()
-class ParamTestCase(unittest.TestCase):
- def test_init(self):
- file = param.ParamFile()
- self.assertTrue(file is not None)
-
- def test_add_section(self):
- file = param.ParamFile()
- file.add_section("global")
- self.assertTrue(file["global"] is not None)
-
- def test_set_param_string(self):
- file = param.ParamFile()
- file.add_section("global")
- file.set_string("data", "bar")
- self.assertEquals("bar", file.get_string("data"))
-
- def test_get_section(self):
- file = param.ParamFile()
- self.assertEquals(None, file.get_section("unknown"))
- self.assertRaises(KeyError, lambda: file["unknown"])
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 1da4e885f5..6b3c26a11a 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -261,7 +261,7 @@ def provision_paths_from_lp(lp, dnsdomain):
paths.netlogon = lp.get("path", "netlogon")
- paths.smbconf = lp.configfile()
+ paths.smbconf = lp.configfile
return paths
@@ -291,7 +291,7 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, serverrole=
if lp.get("realm").upper() != realm:
raise Exception("realm '%s' in %s must match chosen realm '%s'" %
- (lp.get("realm"), lp.configfile(), realm))
+ (lp.get("realm"), lp.configfile, realm))
dnsdomain = dnsdomain.lower()
diff --git a/source4/scripting/python/samba/samba3.py b/source4/scripting/python/samba/samba3.py
index 083386a0c5..1dc90bfcf3 100644
--- a/source4/scripting/python/samba/samba3.py
+++ b/source4/scripting/python/samba/samba3.py
@@ -709,6 +709,18 @@ class ParamFile(object):
def __getitem__(self, section):
return self._sections[section]
+ def get_section(self, section):
+ return self._sections.get(section)
+
+ def add_section(self, section):
+ self._sections[self._sanitize_name(section)] = {}
+
+ def set_string(self, name, value):
+ self._sections["global"][name] = value
+
+ def get_string(self, name):
+ return self._sections["global"].get(name)
+
class Samba3(object):
"""Samba 3 configuration and state data reader."""
diff --git a/source4/scripting/python/samba/tests/samba3.py b/source4/scripting/python/samba/tests/samba3.py
index 95a9fc2b56..71e08bdd7f 100644
--- a/source4/scripting/python/samba/tests/samba3.py
+++ b/source4/scripting/python/samba/tests/samba3.py
@@ -19,7 +19,7 @@
import unittest
from samba.samba3 import GroupMappingDatabase, Registry, PolicyDatabase, SecretsDatabase, TdbSam
-from samba.samba3 import WinsDatabase, SmbpasswdFile, ACB_NORMAL, IdmapDatabase, SAMUser
+from samba.samba3 import WinsDatabase, SmbpasswdFile, ACB_NORMAL, IdmapDatabase, SAMUser, ParamFile
import os
DATADIR=os.path.join(os.path.dirname(__file__), "../../../../../testdata/samba3")
@@ -208,3 +208,25 @@ class ShareInfoTestCase(unittest.TestCase):
def tearDown(self):
self.shareinfodb.close()
+
+
+class ParamTestCase(unittest.TestCase):
+ def test_init(self):
+ file = ParamFile()
+ self.assertTrue(file is not None)
+
+ def test_add_section(self):
+ file = ParamFile()
+ file.add_section("global")
+ self.assertTrue(file["global"] is not None)
+
+ def test_set_param_string(self):
+ file = ParamFile()
+ file.add_section("global")
+ file.set_string("data", "bar")
+ self.assertEquals("bar", file.get_string("data"))
+
+ def test_get_section(self):
+ file = ParamFile()
+ self.assertEquals(None, file.get_section("unknown"))
+ self.assertRaises(KeyError, lambda: file["unknown"])
diff --git a/source4/setup/provision b/source4/setup/provision
index 68f5d4fac7..c6b3491cdb 100755
--- a/source4/setup/provision
+++ b/source4/setup/provision
@@ -140,7 +140,7 @@ if opts.interactive:
break
lp = sambaopts.get_loadparm()
-smbconf = lp.configfile()
+smbconf = lp.configfile
if opts.aci is not None:
print "set ACI: %s" % opts.aci