summaryrefslogtreecommitdiff
path: root/source4/scripting/python
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-11-05 03:00:45 +0100
committerJelmer Vernooij <jelmer@samba.org>2010-11-05 02:48:21 +0000
commitcd172e77248968c48d2ff7f18a2366c35dd51697 (patch)
tree3aaf238aed64fb4a890aed61189e5133c1f0c932 /source4/scripting/python
parent4edabb3256734dcef4ad0d7a910f1729cd5c956e (diff)
downloadsamba-cd172e77248968c48d2ff7f18a2366c35dd51697.tar.gz
samba-cd172e77248968c48d2ff7f18a2366c35dd51697.tar.bz2
samba-cd172e77248968c48d2ff7f18a2366c35dd51697.zip
talloc: Add python talloc module, move convenience functions to it.
Autobuild-User: Jelmer Vernooij <jelmer@samba.org> Autobuild-Date: Fri Nov 5 02:48:21 UTC 2010 on sn-devel-104
Diffstat (limited to 'source4/scripting/python')
-rw-r--r--source4/scripting/python/pyglue.c50
-rw-r--r--source4/scripting/python/samba/__init__.py3
-rw-r--r--source4/scripting/python/samba/join.py3
-rwxr-xr-xsource4/scripting/python/samba/tests/dcerpc/rpc_talloc.py7
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/testrpc.py11
5 files changed, 12 insertions, 62 deletions
diff --git a/source4/scripting/python/pyglue.c b/source4/scripting/python/pyglue.c
index 627443dee5..b77ce2bda5 100644
--- a/source4/scripting/python/pyglue.c
+++ b/source4/scripting/python/pyglue.c
@@ -166,50 +166,6 @@ static PyObject *py_interface_ips(PyObject *self, PyObject *args)
return pylist;
}
-/* print a talloc tree report for a talloc python object */
-static PyObject *py_talloc_report_full(PyObject *self, PyObject *args)
-{
- PyObject *py_obj;
- PyTypeObject *type;
-
- if (!PyArg_ParseTuple(args, "O", &py_obj))
- return NULL;
-
- if (py_obj == Py_None) {
- talloc_report_full(NULL, stdout);
- } else {
- type = (PyTypeObject*)PyObject_Type(py_obj);
- talloc_report_full(py_talloc_get_mem_ctx(py_obj), stdout);
- }
- return Py_None;
-}
-
-/* enable null tracking */
-static PyObject *py_talloc_enable_null_tracking(PyObject *self, PyObject *args)
-{
- talloc_enable_null_tracking();
- return Py_None;
-}
-
-/* return the number of talloc blocks */
-static PyObject *py_talloc_total_blocks(PyObject *self, PyObject *args)
-{
- PyObject *py_obj;
- PyTypeObject *type;
-
- if (!PyArg_ParseTuple(args, "O", &py_obj))
- return NULL;
-
- if (py_obj == Py_None) {
- return PyLong_FromLong(talloc_total_blocks(NULL));
- }
-
- type = (PyTypeObject*)PyObject_Type(py_obj);
-
- return PyLong_FromLong(talloc_total_blocks(py_talloc_get_mem_ctx(py_obj)));
-}
-
-
static PyMethodDef py_misc_methods[] = {
{ "generate_random_str", (PyCFunction)py_generate_random_str, METH_VARARGS,
"generate_random_str(len) -> string\n"
@@ -227,12 +183,6 @@ static PyMethodDef py_misc_methods[] = {
"set debug level" },
{ "interface_ips", (PyCFunction)py_interface_ips, METH_VARARGS,
"get interface IP address list"},
- { "talloc_report_full", (PyCFunction)py_talloc_report_full, METH_VARARGS,
- "show a talloc tree for an object"},
- { "talloc_enable_null_tracking", (PyCFunction)py_talloc_enable_null_tracking, METH_VARARGS,
- "enable tracking of the NULL object"},
- { "talloc_total_blocks", (PyCFunction)py_talloc_total_blocks, METH_VARARGS,
- "return talloc block count"},
{ NULL }
};
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index 5a9df50627..079dad7351 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -327,6 +327,3 @@ interface_ips = _glue.interface_ips
set_debug_level = _glue.set_debug_level
unix2nttime = _glue.unix2nttime
generate_random_password = _glue.generate_random_password
-talloc_report_full = _glue.talloc_report_full
-talloc_enable_null_tracking = _glue.talloc_enable_null_tracking
-talloc_total_blocks = _glue.talloc_total_blocks
diff --git a/source4/scripting/python/samba/join.py b/source4/scripting/python/samba/join.py
index 2e6edca2a4..4fe0774f83 100644
--- a/source4/scripting/python/samba/join.py
+++ b/source4/scripting/python/samba/join.py
@@ -32,9 +32,10 @@ from samba.net import Net
import logging
from samba.drs_utils import drs_Replicate
from samba.dsdb import DS_DOMAIN_FUNCTION_2008_R2
+import talloc
# this makes debugging easier
-samba.talloc_enable_null_tracking()
+talloc.enable_null_tracking()
class join_ctx:
'''hold join context variables'''
diff --git a/source4/scripting/python/samba/tests/dcerpc/rpc_talloc.py b/source4/scripting/python/samba/tests/dcerpc/rpc_talloc.py
index 5058e08960..d561dde514 100755
--- a/source4/scripting/python/samba/tests/dcerpc/rpc_talloc.py
+++ b/source4/scripting/python/samba/tests/dcerpc/rpc_talloc.py
@@ -17,15 +17,16 @@ sys.path.insert(0, "bin/python")
import samba
import samba.tests
from samba.dcerpc import drsuapi
+import talloc
-samba.talloc_enable_null_tracking()
+talloc.enable_null_tracking()
class TallocTests(samba.tests.TestCase):
'''test talloc behaviour of pidl generated python code'''
def check_blocks(self, object, num_expected):
'''check that the number of allocated blocks is correct'''
- nblocks = samba.talloc_total_blocks(object)
+ nblocks = talloc.total_blocks(object)
if object is None:
nblocks -= self.initial_blocks
self.assertEquals(nblocks, num_expected)
@@ -61,7 +62,7 @@ class TallocTests(samba.tests.TestCase):
self.check_blocks(None, 6)
def test_run(self):
- self.initial_blocks = samba.talloc_total_blocks(None)
+ self.initial_blocks = talloc.total_blocks(None)
self.check_blocks(None, 0)
self.pas_test()
self.check_blocks(None, 0)
diff --git a/source4/scripting/python/samba/tests/dcerpc/testrpc.py b/source4/scripting/python/samba/tests/dcerpc/testrpc.py
index d432d5abe1..2f3a6a0aef 100644
--- a/source4/scripting/python/samba/tests/dcerpc/testrpc.py
+++ b/source4/scripting/python/samba/tests/dcerpc/testrpc.py
@@ -10,15 +10,16 @@ sys.path.insert(0, "bin/python")
import samba
import samba.tests
from samba.dcerpc import drsuapi
+import talloc
-samba.talloc_enable_null_tracking()
+talloc.enable_null_tracking()
class RpcTests(object):
'''test type behaviour of pidl generated python RPC code'''
def check_blocks(self, object, num_expected):
'''check that the number of allocated blocks is correct'''
- nblocks = samba.talloc_total_blocks(object)
+ nblocks = talloc.total_blocks(object)
if object is None:
nblocks -= self.initial_blocks
leaked_blocks = (nblocks - num_expected)
@@ -89,7 +90,7 @@ class RpcTests(object):
pass
elif isinstance(value, type):
try:
- initial_blocks = samba.talloc_total_blocks(None)
+ initial_blocks = talloc.total_blocks(None)
self.check_type(interface, n, value)
self.check_blocks(None, initial_blocks)
except Exception, e:
@@ -110,12 +111,12 @@ class RpcTests(object):
continue
print "Checking interface %s" % iname
iface = getattr(samba.dcerpc, iname)
- initial_blocks = samba.talloc_total_blocks(None)
+ initial_blocks = talloc.total_blocks(None)
self.check_interface(iface, iname)
self.check_blocks(None, initial_blocks)
def run(self):
- self.initial_blocks = samba.talloc_total_blocks(None)
+ self.initial_blocks = talloc.total_blocks(None)
self.errcount = 0
self.check_all_interfaces()
return self.errcount