svn commit: samba r26042 - in branches/4.0-python: . source/lib/ldb source/lib/ldb/tests/python source/scripting/python/samba

jelmer at samba.org jelmer at samba.org
Mon Nov 19 19:28:25 GMT 2007


Author: jelmer
Date: 2007-11-19 19:28:24 +0000 (Mon, 19 Nov 2007)
New Revision: 26042

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=26042

Log:
Wrap time string functions.
Modified:
   branches/4.0-python/
   branches/4.0-python/source/lib/ldb/ldb.i
   branches/4.0-python/source/lib/ldb/tests/python/api.py
   branches/4.0-python/source/scripting/python/samba/__init__.py
   branches/4.0-python/source/scripting/python/samba/provision.py


Changeset:

Property changes on: branches/4.0-python
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/4.0-python/source/lib/ldb/ldb.i
===================================================================
--- branches/4.0-python/source/lib/ldb/ldb.i	2007-11-19 19:28:19 UTC (rev 26041)
+++ branches/4.0-python/source/lib/ldb/ldb.i	2007-11-19 19:28:24 UTC (rev 26042)
@@ -405,9 +405,12 @@
 }
 %}
 
-%typemap(in) (void (*debug)(void *context, enum ldb_debug_level level, const char *fmt, va_list ap),
+%typemap(in,numinputs=1) (void (*debug)(void *context, enum ldb_debug_level level, const char *fmt, va_list ap),
                             void *context) {
     $1 = py_ldb_debug;
+    /* FIXME: Should be decreased somewhere as well. Perhaps register a destructor and 
+       tie it to the ldb context ? */
+    Py_INCREF($input);
     $2 = $input;
 }
 #endif
@@ -518,3 +521,18 @@
 %rename(valid_attr_name) ldb_valid_attr_name;
 int ldb_valid_attr_name(const char *s);
 
+typedef unsigned long time_t;
+
+%{
+char *timestring(time_t t)
+{
+    char *tresult = ldb_timestring(NULL, t);
+    char *result = strdup(tresult);
+    talloc_free(tresult);
+    return result; 
+}
+%}
+char *timestring(time_t t);
+
+%rename(string_to_time) ldb_string_to_time;
+time_t ldb_string_to_time(const char *s);

Modified: branches/4.0-python/source/lib/ldb/tests/python/api.py
===================================================================
--- branches/4.0-python/source/lib/ldb/tests/python/api.py	2007-11-19 19:28:19 UTC (rev 26041)
+++ branches/4.0-python/source/lib/ldb/tests/python/api.py	2007-11-19 19:28:24 UTC (rev 26042)
@@ -13,7 +13,15 @@
         self.assertTrue(ldb.valid_attr_name("foo"))
         self.assertFalse(ldb.valid_attr_name("24foo"))
 
+    def test_timestring(self):
+        self.assertEquals("19700101000000.0Z", ldb.timestring(0))
+        self.assertEquals("20071119191012.0Z", ldb.timestring(1195499412))
 
+    def test_string_to_time(self):
+        self.assertEquals(0, ldb.string_to_time("19700101000000.0Z"))
+        self.assertEquals(1195499412, ldb.string_to_time("20071119191012.0Z"))
+
+
 class SimpleLdb(unittest.TestCase):
     def test_connect(self):
         ldb.Ldb("foo.tdb")

Modified: branches/4.0-python/source/scripting/python/samba/__init__.py
===================================================================
--- branches/4.0-python/source/scripting/python/samba/__init__.py	2007-11-19 19:28:19 UTC (rev 26041)
+++ branches/4.0-python/source/scripting/python/samba/__init__.py	2007-11-19 19:28:24 UTC (rev 26042)
@@ -33,7 +33,7 @@
         modules_dir = os.path.join(os.getcwd(), "bin", "modules", "ldb")
     ret.set_modules_dir(modules_dir)
     def samba_debug(level,text):
-        print "%d %s\n" % (level, text)
+        print "%d %s" % (level, text)
     ret.set_debug(samba_debug)
     ret.connect(url)
     return ret

Modified: branches/4.0-python/source/scripting/python/samba/provision.py
===================================================================
--- branches/4.0-python/source/scripting/python/samba/provision.py	2007-11-19 19:28:19 UTC (rev 26041)
+++ branches/4.0-python/source/scripting/python/samba/provision.py	2007-11-19 19:28:24 UTC (rev 26042)
@@ -286,7 +286,12 @@
     data = substitute_var(data, subobj.subst_vars())
 
     for msg in ldb.parse_ldif(data):
-        ldb.add(msg[1])
+        try:
+            ldb.add(msg[1])
+        except:
+            import pdb
+            pdb.set_trace()
+            raise
 
 
 def setup_modify_ldif(setup_dir, ldif, subobj, ldb):
@@ -625,6 +630,7 @@
 
     message("Please install the zone located in %s into your DNS server" % paths.dns)
 
+
 def provision_ldapbase(setup_dir, subobj, message, paths):
     """Write out a DNS zone file, from the info in the current database."""
     message("Setting up LDAP base entry: %s" % subobj.domaindn)
@@ -648,10 +654,6 @@
     message("Please install the LDIF located in " + paths.ldap_basedn_ldif + ", " + paths.ldap_config_basedn_ldif + " and " + paths.ldap_schema_basedn_ldif + " into your LDAP server, and re-run with --ldap-backend=ldap://my.ldap.server")
 
 
-def ldaptime(timestamp=None):
-    return time.strftime("%Y%m%d%H%m%s.0Z", timestamp)
-
-
 def provision_guess(lp):
     """guess reasonably default options for provisioning."""
     subobj = ProvisionSettings(realm=lp.get("realm").upper(),



More information about the samba-cvs mailing list