summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-09-03 13:03:31 +1000
committerAndrew Tridgell <tridge@samba.org>2009-09-03 18:36:09 +1000
commit617bbd913dcd6335cfcee3db6d23e8d3262dd566 (patch)
tree152d12b80c0fa30a3dc64fdb6cd97924656bd7fa /source4
parent348824da759a78b06e75d6ab7f8f85aa9912957c (diff)
downloadsamba-617bbd913dcd6335cfcee3db6d23e8d3262dd566.tar.gz
samba-617bbd913dcd6335cfcee3db6d23e8d3262dd566.tar.bz2
samba-617bbd913dcd6335cfcee3db6d23e8d3262dd566.zip
allow setting of the debug level in python from C
Diffstat (limited to 'source4')
-rw-r--r--source4/param/provision.c5
-rw-r--r--source4/scripting/python/pyglue.c11
-rw-r--r--source4/scripting/python/samba/provision.py4
3 files changed, 18 insertions, 2 deletions
diff --git a/source4/param/provision.c b/source4/param/provision.c
index c8bff59deb..bbc6837a90 100644
--- a/source4/param/provision.c
+++ b/source4/param/provision.c
@@ -34,7 +34,7 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
struct provision_settings *settings,
struct provision_result *result)
{
- char *configfile;
+ const char *configfile;
PyObject *provision_mod, *provision_dict, *provision_fn, *py_result, *parameters;
DEBUG(0,("Provision for Become-DC test using python\n"));
@@ -123,6 +123,9 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
PyDict_SetItemString(parameters, "machinepass",
PyString_FromString(settings->machine_password));
+
+ PyDict_SetItemString(parameters, "debuglevel", PyInt_FromLong(DEBUGLEVEL));
+
py_result = PyEval_CallObjectWithKeywords(provision_fn, NULL, parameters);
Py_DECREF(parameters);
diff --git a/source4/scripting/python/pyglue.c b/source4/scripting/python/pyglue.c
index 79ee0ec388..42c04c1f38 100644
--- a/source4/scripting/python/pyglue.c
+++ b/source4/scripting/python/pyglue.c
@@ -93,6 +93,15 @@ static PyObject *py_unix2nttime(PyObject *self, PyObject *args)
return PyInt_FromLong((uint64_t)nt);
}
+static PyObject *py_set_debug_level(PyObject *self, PyObject *args)
+{
+ unsigned level;
+ if (!PyArg_ParseTuple(args, "I", &level))
+ return NULL;
+ (DEBUGLEVEL) = level;
+ Py_RETURN_NONE;
+}
+
static PyObject *py_ldb_set_credentials(PyObject *self, PyObject *args)
{
PyObject *py_creds, *py_ldb;
@@ -483,6 +492,8 @@ static PyMethodDef py_misc_methods[] = {
NULL },
{ "dom_sid_to_rid", (PyCFunction)py_dom_sid_to_rid, METH_VARARGS,
NULL },
+ { "set_debug_level", (PyCFunction)py_set_debug_level, METH_VARARGS,
+ "set debug level" },
{ NULL }
};
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index cbffa22f33..7b3ef4b577 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -1298,12 +1298,14 @@ def provision_become_dc(setup_dir=None,
policyguid=None, invocationid=None, machinepass=None,
dnspass=None, root=None, nobody=None, users=None,
wheel=None, backup=None, serverrole=None,
- ldap_backend=None, ldap_backend_type=None, sitename=None):
+ ldap_backend=None, ldap_backend_type=None, sitename=None, debuglevel=1):
def message(text):
"""print a message if quiet is not set."""
print text
+ glue.set_debug_level(debuglevel)
+
return provision(setup_dir, message, system_session(), None,
smbconf=smbconf, targetdir=targetdir, samdb_fill=FILL_DRS, realm=realm,
rootdn=rootdn, domaindn=domaindn, schemadn=schemadn, configdn=configdn, serverdn=serverdn,