Author: jelmer Date: 2007-11-19 12:57:38 +0000 (Mon, 19 Nov 2007) New Revision: 26028
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=26028 Log: Some documentation improvements. Added: branches/4.0-python/source/scripting/python/samba/credentials.py branches/4.0-python/source/scripting/python/tests/uuid.py Removed: branches/4.0-python/source/scripting/ejs/ branches/4.0-python/source/scripting/libjs/ branches/4.0-python/source/scripting/python/credentials.py Modified: branches/4.0-python/ branches/4.0-python/source/BRANCH.TODO branches/4.0-python/source/scripting/python/samba/__init__.py branches/4.0-python/source/scripting/python/samba/provision.py branches/4.0-python/source/scripting/swig/README Changeset: Property changes on: branches/4.0-python ___________________________________________________________________ Name: bzr:revision-info ...skipped... Name: bzr:file-ids ...skipped... Name: bzr:revision-id:v3-trunk0 ...skipped... Modified: branches/4.0-python/source/BRANCH.TODO =================================================================== --- branches/4.0-python/source/BRANCH.TODO 2007-11-19 12:12:13 UTC (rev 26027) +++ branches/4.0-python/source/BRANCH.TODO 2007-11-19 12:57:38 UTC (rev 26028) @@ -1,4 +1,5 @@ - support kwargs (especially for constructors with a lot of arguments) - make sure exceptions are properly thrown everywhere + - use LdbError rather than RuntimeError - fix provisioning of registry - fix web server Deleted: branches/4.0-python/source/scripting/python/credentials.py =================================================================== --- branches/4.0-python/source/scripting/python/credentials.py 2007-11-19 12:12:13 UTC (rev 26027) +++ branches/4.0-python/source/scripting/python/credentials.py 2007-11-19 12:57:38 UTC (rev 26028) @@ -1,3 +0,0 @@ -credentials = "" -def system_session(): - pass Modified: branches/4.0-python/source/scripting/python/samba/__init__.py =================================================================== --- branches/4.0-python/source/scripting/python/samba/__init__.py 2007-11-19 12:12:13 UTC (rev 26027) +++ branches/4.0-python/source/scripting/python/samba/__init__.py 2007-11-19 12:57:38 UTC (rev 26028) @@ -21,6 +21,12 @@ import os def Ldb(url, session_info=None, credentials=None, modules_dir=None): + """Open a Samba Ldb file. + + This is different from a regular Ldb file in that the Samba-specific + modules-dir is used by default and that credentials and session_info + can be passed through (required by some modules). + """ import ldb ret = ldb.Ldb() if modules_dir is None: @@ -29,11 +35,15 @@ ret.connect(url) return ret -# -# substitute strings of the form ${NAME} in str, replacing -# with substitutions from subobj -# + def substitute_var(text, values): + """substitute strings of the form ${NAME} in str, replacing + with substitutions from subobj. + + :param text: Text in which to subsitute. + :param values: Dictionary with keys and values. + """ + for (name, value) in values.items(): text = text.replace("${%s}" % name, value) Copied: branches/4.0-python/source/scripting/python/samba/credentials.py (from rev 26023, branches/4.0-python/source/scripting/python/credentials.py) =================================================================== --- branches/4.0-python/source/scripting/python/credentials.py 2007-11-17 23:37:05 UTC (rev 26023) +++ branches/4.0-python/source/scripting/python/samba/credentials.py 2007-11-19 12:57:38 UTC (rev 26028) @@ -0,0 +1,3 @@ +credentials = "" +def system_session(): + pass Modified: branches/4.0-python/source/scripting/python/samba/provision.py =================================================================== --- branches/4.0-python/source/scripting/python/samba/provision.py 2007-11-19 12:12:13 UTC (rev 26027) +++ branches/4.0-python/source/scripting/python/samba/provision.py 2007-11-19 12:57:38 UTC (rev 26028) @@ -127,6 +127,7 @@ self.ldap_schema_basedn_ldif = None self.s4_ldapi_path = None + def install_ok(lp, session_info, credentials): """Check whether the current install seems ok.""" if lp.get("realm") == "": @@ -137,6 +138,7 @@ return False return True + def findnss(nssfn, *names): """Find a user or group from a list of possibilities.""" for name in names: @@ -181,16 +183,20 @@ """return first part of hostname.""" return gethostname().split(".")[0] -# the ldb is in bad shape, possibly due to being built from an -# incompatible previous version of the code, so delete it -# completely def ldb_delete(ldb): + """Delete a LDB file. + + This may be necessary if the ldb is in bad shape, possibly due to being + built from an incompatible previous version of the code, so delete it + completely. + """ print "Deleting %s\n" % ldb.filename os.unlink(ldb.filename) ldb.transaction_cancel() ldb.connect(ldb.filename) ldb.transaction_start() + def ldb_erase(ldb): """Erase an ldb, removing all records.""" # delete the specials @@ -219,10 +225,9 @@ return assert len(res) == 0 -# -# erase an ldb, removing all records -# + def ldb_erase_partitions(subobj, message, ldb, ldapbackend): + """Erase an ldb, removing all records.""" assert ldb is not None res = ldb.search(Dn(ldb, ""), SCOPE_BASE, "(objectClass=*)", ["namingContexts"]) @@ -709,6 +714,7 @@ subobj.aci = "# no aci for local ldb" return subobj + def searchone(ldb, basedn, expression, attribute): """search for one attribute as a string.""" res = ldb.search(basedn, SCOPE_SUBTREE, expression, [attribute]) Added: branches/4.0-python/source/scripting/python/tests/uuid.py =================================================================== --- branches/4.0-python/source/scripting/python/tests/uuid.py 2007-11-19 12:12:13 UTC (rev 26027) +++ branches/4.0-python/source/scripting/python/tests/uuid.py 2007-11-19 12:57:38 UTC (rev 26028) @@ -0,0 +1,25 @@ +#!/usr/bin/python + +# Unix SMB/CIFS implementation. +# Copyright (C) Jelmer Vernooij <[EMAIL PROTECTED]> 2007 +# +# 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 unittest import TestCase +from uuid import random + +class TestUuid(TestCase): + def test_simple(self): + pass Modified: branches/4.0-python/source/scripting/swig/README =================================================================== --- branches/4.0-python/source/scripting/swig/README 2007-11-19 12:12:13 UTC (rev 26027) +++ branches/4.0-python/source/scripting/swig/README 2007-11-19 12:57:38 UTC (rev 26028) @@ -6,26 +6,9 @@ 1. Run configure with the --with-python option to enable python extensions. -2. Edit the script/build_idl.sh script to pass the --swig option to - pidl. Here's a patch: +2. Run 'make idl_full swig' to build extensions. -Index: script/build_idl.sh -=================================================================== ---- script/build_idl.sh (revision 2413) -+++ script/build_idl.sh (working copy) -@@ -4,7 +4,7 @@ - - [ -d librpc/gen_ndr ] || mkdir -p librpc/gen_ndr || exit 1 - --PIDL="$PERL ./build/pidl/pidl.pl --output librpc/gen_ndr/ndr_ --parse --header --parser --server" -+PIDL="$PERL ./build/pidl/pidl.pl --output librpc/gen_ndr/ndr_ --parse --header --parser --server --swig" - TABLES="$PERL ./build/pidl/tables.pl --output librpc/gen_ndr/tables" - - if [ x$FULLBUILD = xFULL ]; then - -3. Run 'make idl_full swig' to build extensions. - -4. At some stage there will be a proper system for installing the +3. At some stage there will be a proper system for installing the extensions, but right now it's easier to run them in place. Set your PYTHONPATH to include the modules. From the Samba source directory, run: @@ -34,4 +17,4 @@ Now you can go nuts and use the extensions. Check the scripting/swig/torture directory for a testsuite. There will -hopefully be a bunch of usage examples somewhere. \ No newline at end of file +hopefully be a bunch of usage examples somewhere.
