2 commits - pykolab/auth pykolab/cli wallace/__init__.py

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Sat Oct 11 21:31:04 CEST 2014


 pykolab/auth/ldap/__init__.py |   15 ++++++++++++++-
 pykolab/cli/cmd_sync.py       |    8 ++++++++
 wallace/__init__.py           |   12 +++++++++++-
 3 files changed, 33 insertions(+), 2 deletions(-)

New commits:
commit 9a2d4304627900d5d692189870ff96b5d6ce5174
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Sat Oct 11 21:29:49 2014 +0200

    Fall back to accept a message if no module has anything to say about it

diff --git a/wallace/__init__.py b/wallace/__init__.py
index 1108ead..41db60a 100644
--- a/wallace/__init__.py
+++ b/wallace/__init__.py
@@ -40,6 +40,8 @@ from pykolab.translate import _
 log = pykolab.getLogger('pykolab.wallace')
 conf = pykolab.getConf()
 
+from modules import cb_action_ACCEPT
+
 #conf.finalize_conf()
 #if conf.debuglevel > 8:
 #    max_threads = 1
@@ -62,6 +64,10 @@ def pickup_message(filepath, *args, **kw):
         else:
             modules.execute(kw['module'], filepath)
 
+    # After all modules are executed, continue with a call to
+    # accept the message and re-inject in to Postfix.
+    continue_with_accept = True
+
     for module in wallace_modules:
         try:
             result_filepath = modules.execute(module, filepath)
@@ -72,7 +78,11 @@ def pickup_message(filepath, *args, **kw):
         if not result_filepath == None and not result_filepath == False:
             filepath = result_filepath
         else:
-            break
+            # A module has returned False or None
+            continue_with_accept = False
+
+    if continue_with_accept:
+        cb_action_ACCEPT('wallace', filepath)
 
 def worker_process(*args, **kw):
     log.debug(_("Worker process %s initializing") % (multiprocessing.current_process().name), level=1)


commit 75f998a71169fb0cf8e95633614316c8a455fe32
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Sat Oct 11 14:59:11 2014 +0200

    Add a command-line option --resync to the sync command, to ignore the latest timestamp

diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 1b0c941..c240405 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -984,7 +984,20 @@ class LDAP(pykolab.base.Base):
 
         _filter = self._kolab_filter()
 
-        modified_after = self.get_latest_sync_timestamp()
+        modified_after = None
+
+        if hasattr(conf, 'resync'):
+            if not conf.resync:
+                modified_after = self.get_latest_sync_timestamp()
+            else:
+                modifytimestamp_format = conf.get_raw('ldap', 'modifytimestamp_format')
+                if modifytimestamp_format == None:
+                    modifytimestamp_format = "%Y%m%d%H%M%SZ"
+
+                modified_after = datetime.datetime(1900, 01, 01, 00, 00, 00).strftime(modifytimestamp_format)
+        else:
+            modified_after = self.get_latest_sync_timestamp()
+
         _filter = "(&%s(modifytimestamp>=%s))" % (_filter,modified_after)
 
         log.debug(_("Using filter %r") % (_filter), level=8)
diff --git a/pykolab/cli/cmd_sync.py b/pykolab/cli/cmd_sync.py
index d60fd31..e4f4bdf 100644
--- a/pykolab/cli/cmd_sync.py
+++ b/pykolab/cli/cmd_sync.py
@@ -31,6 +31,14 @@ conf = pykolab.getConf()
 def __init__():
     commands.register('sync', execute, description="Synchronize Kolab Users with IMAP.")
 
+def cli_options():
+    my_option_group = conf.add_cli_parser_option_group(_("CLI Options"))
+    my_option_group.add_option( '--resync',
+                                dest    = "resync",
+                                action  = "store_true",
+                                default = False,
+                                help    = _("Resync from the beginning"))
+
 def execute(*args, **kw):
     auth = Auth()
     log.debug(_("Listing domains..."), level=5)




More information about the commits mailing list