python: Fix python code for winreg, add test.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 14 Jan 2008 13:48:59 +0000 (14:48 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 14 Jan 2008 18:53:07 +0000 (19:53 +0100)
source/foo.py [deleted file]
source/librpc/config.mk
source/pidl/lib/Parse/Pidl/Samba4/Python.pm
source/scripting/python/STATUS
source/scripting/python/samba/tests/dcerpc/registry.py [new file with mode: 0644]
source/selftest/samba4_tests.sh

diff --git a/source/foo.py b/source/foo.py
deleted file mode 100644 (file)
index 21a422c..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/python
-
-# Unix SMB/CIFS implementation.
-# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
-#   
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#   
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#   
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-from echo import rpcecho
-from param import LoadParm
-
-lp = LoadParm()
-lp.load("st/client/client.conf")
-
-x = rpcecho("ncalrpc:", lp)
-print x.AddOne(41)
index 55991f4953a8effbdfa805eff3a4b88d21729b9e..ab94770d4661029558f951711637f1f120336944 100644 (file)
@@ -605,3 +605,7 @@ PRIVATE_DEPENDENCIES = RPC_NDR_WINREG python_misc
 
 [PYTHON::python_dcerpc_misc]
 OBJ_FILES = gen_ndr/py_misc.o
 
 [PYTHON::python_dcerpc_misc]
 OBJ_FILES = gen_ndr/py_misc.o
+
+[PYTHON::python_dcerpc_initshutdown]
+OBJ_FILES = gen_ndr/py_initshutdown.o
+PRIVATE_DEPENDENCIES = RPC_NDR_INITSHUTDOWN
index e53877162420b5a69430dd79fb06b9e3bfa86427..c8505e9904f81b00cef02c75c7a0fb04ec42121d 100644 (file)
@@ -665,6 +665,7 @@ sub ConvertObjectFromPythonLevel($$$$$$$$)
                        $self->pidl("} else {");
                        $self->indent;
                }
                        $self->pidl("} else {");
                        $self->indent;
                }
+               $self->pidl("$var_name = talloc_ptrtype($mem_ctx, $var_name);");
                $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, GetNextLevel($e, $l), get_value_of($var_name), $fail);
                if ($l->{POINTER_TYPE} ne "ref") {
                        $self->deindent;
                $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, GetNextLevel($e, $l), get_value_of($var_name), $fail);
                if ($l->{POINTER_TYPE} ne "ref") {
                        $self->deindent;
@@ -686,7 +687,9 @@ sub ConvertObjectFromPythonLevel($$$$$$$$)
                        $self->pidl("{");
                        $self->indent;
                        $self->pidl("int $counter;");
                        $self->pidl("{");
                        $self->indent;
                        $self->pidl("int $counter;");
-                       $self->pidl("$var_name = talloc_array_ptrtype($mem_ctx, $var_name, PyList_Size($py_var));");
+                       if (!$l->{IS_FIXED}) {
+                               $self->pidl("$var_name = talloc_array_ptrtype($mem_ctx, $var_name, PyList_Size($py_var));");
+                       }
                        $self->pidl("for ($counter = 0; $counter < PyList_Size($py_var); $counter++) {");
                        $self->indent;
                        $self->ConvertObjectFromPythonLevel($env, $var_name, "PyList_GetItem($py_var, $counter)", $e, GetNextLevel($e, $l), $var_name."[$counter]", $fail);
                        $self->pidl("for ($counter = 0; $counter < PyList_Size($py_var); $counter++) {");
                        $self->indent;
                        $self->ConvertObjectFromPythonLevel($env, $var_name, "PyList_GetItem($py_var, $counter)", $e, GetNextLevel($e, $l), $var_name."[$counter]", $fail);
@@ -697,8 +700,7 @@ sub ConvertObjectFromPythonLevel($$$$$$$$)
                }
        } elsif ($l->{TYPE} eq "DATA") {
 
                }
        } elsif ($l->{TYPE} eq "DATA") {
 
-               if (not Parse::Pidl::Typelist::is_scalar($l->{DATA_TYPE}) or 
-                       Parse::Pidl::Typelist::scalar_is_reference($l->{DATA_TYPE})) {
+               if (not Parse::Pidl::Typelist::is_scalar($l->{DATA_TYPE})) {
                        $var_name = get_pointer_to($var_name);
                }
                $self->ConvertObjectFromPythonData($mem_ctx, $py_var, $l->{DATA_TYPE}, $var_name, $fail);
                        $var_name = get_pointer_to($var_name);
                }
                $self->ConvertObjectFromPythonData($mem_ctx, $py_var, $l->{DATA_TYPE}, $var_name, $fail);
@@ -841,8 +843,7 @@ sub ConvertObjectToPythonLevel($$$$$)
                my $switch = ParseExpr($l->{SWITCH_IS}, $env, $e);
                $self->pidl("$py_var = py_import_" . GetNextLevel($e, $l)->{DATA_TYPE} . "($mem_ctx, $switch, $var_name);");
        } elsif ($l->{TYPE} eq "DATA") {
                my $switch = ParseExpr($l->{SWITCH_IS}, $env, $e);
                $self->pidl("$py_var = py_import_" . GetNextLevel($e, $l)->{DATA_TYPE} . "($mem_ctx, $switch, $var_name);");
        } elsif ($l->{TYPE} eq "DATA") {
-               if (not Parse::Pidl::Typelist::is_scalar($l->{DATA_TYPE}) or 
-                       Parse::Pidl::Typelist::scalar_is_reference($l->{DATA_TYPE})) {
+               if (not Parse::Pidl::Typelist::is_scalar($l->{DATA_TYPE})) {
                        $var_name = get_pointer_to($var_name);
                }
                my $conv = $self->ConvertObjectToPythonData($mem_ctx, $l->{DATA_TYPE}, $var_name);
                        $var_name = get_pointer_to($var_name);
                }
                my $conv = $self->ConvertObjectToPythonData($mem_ctx, $l->{DATA_TYPE}, $var_name);
index 9a1c5b1b6461a2dab6b9b5063fb9e19c029a2a58..0e88b4041c14eae6006cd56a76a0aa71aeb7df45 100644 (file)
@@ -10,7 +10,6 @@ DCE/RPC bindings
         - wrap struct/bitmap/enum/union types
          - __ndr_pack__/__ndr_unpack__ members
  - scripting/bin/smbstatus.py
         - wrap struct/bitmap/enum/union types
          - __ndr_pack__/__ndr_unpack__ members
  - scripting/bin/smbstatus.py
- - scripting/bin/winreg.py
 
 not important before making Python the default:
 - scripting/python/samba/upgrade.py
 
 not important before making Python the default:
 - scripting/python/samba/upgrade.py
diff --git a/source/scripting/python/samba/tests/dcerpc/registry.py b/source/scripting/python/samba/tests/dcerpc/registry.py
new file mode 100644 (file)
index 0000000..7979592
--- /dev/null
@@ -0,0 +1,53 @@
+#!/usr/bin/python
+
+# Unix SMB/CIFS implementation.
+# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+#   
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#   
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#   
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+
+#!/usr/bin/python
+
+# Unix SMB/CIFS implementation.
+# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+#   
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#   
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#   
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+import winreg
+from param import LoadParm
+import unittest
+
+class WinregTests(unittest.TestCase):
+    def setUp(self):
+        lp_ctx = LoadParm()
+        lp_ctx.load("st/client/client.conf")
+        self.conn = winreg.winreg("ncalrpc:", lp_ctx)
+
+    def test_hklm(self):
+        (handle, _) = self.conn.OpenHKLM(None, 
+                 winreg.KEY_QUERY_VALUE | winreg.KEY_ENUMERATE_SUB_KEYS)
+        self.conn.CloseKey(handle)
index c1dac21614d86608245e9d402cb6b5dc00d7b69e..fdf535e003723962112798e92bbd85e24cf1b91e 100755 (executable)
@@ -323,6 +323,7 @@ then
        plantest "events.python" none PYTHONPATH="$PYTHONPATH:lib/events" $SUBUNITRUN tests
        plantest "samba3sam.python" none PYTHONPATH="$PYTHONPATH:dsdb/samdb/ldb_modules/tests" $SUBUNITRUN samba3sam
        plantest "rpcecho.python" dc $SUBUNITRUN samba.tests.dcerpc.rpcecho
        plantest "events.python" none PYTHONPATH="$PYTHONPATH:lib/events" $SUBUNITRUN tests
        plantest "samba3sam.python" none PYTHONPATH="$PYTHONPATH:dsdb/samdb/ldb_modules/tests" $SUBUNITRUN samba3sam
        plantest "rpcecho.python" dc $SUBUNITRUN samba.tests.dcerpc.rpcecho
+       plantest "winreg.python" dc $SUBUNITRUN samba.tests.dcerpc.registry
        plantest "ldap.python" dc $PYTHON $samba4srcdir/lib/ldb/tests/python/ldap.py $CONFIGURATION \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN
        plantest "blackbox.samba3dump" none $PYTHON scripting/bin/samba3dump $samba4srcdir/../testdata/samba3
        rm -rf $PREFIX/upgrade
        plantest "ldap.python" dc $PYTHON $samba4srcdir/lib/ldb/tests/python/ldap.py $CONFIGURATION \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN
        plantest "blackbox.samba3dump" none $PYTHON scripting/bin/samba3dump $samba4srcdir/../testdata/samba3
        rm -rf $PREFIX/upgrade