2 commits - pykolab/cli pykolab/plugins

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Wed Jan 23 14:07:18 CET 2013


 pykolab/cli/sieve/cmd_refresh.py      |   25 ++++++++++++++-----------
 pykolab/plugins/sievemgmt/__init__.py |   24 +++++++++++++-----------
 2 files changed, 27 insertions(+), 22 deletions(-)

New commits:
commit 5eb47567db404d424f8012ade2b5e07a468d99c2
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Wed Jan 23 13:07:03 2013 +0000

    Suppress print statements and replace them with better log statements

diff --git a/pykolab/cli/sieve/cmd_refresh.py b/pykolab/cli/sieve/cmd_refresh.py
index 91e19cb..f672410 100644
--- a/pykolab/cli/sieve/cmd_refresh.py
+++ b/pykolab/cli/sieve/cmd_refresh.py
@@ -96,9 +96,8 @@ def execute(*args, **kw):
     else:
         active, scripts = result
 
-
-    print "Found the following scripts: %s" % (','.join(scripts))
-    print "And the following script is active: %s" % (active)
+    log.debug(_("Found the following scripts for user %s: %s") % (address, ','.join(scripts)), level=8)
+    log.deubg(_("And the following script is active for user %s: %s") % (address, active), level=8)
 
     mgmt_required_extensions = []
 
@@ -354,14 +353,14 @@ def execute(*args, **kw):
 
     mgmt_script = mgmt_script.__str__()
 
-    log.debug(_("MANAGEMENT Script contents: %r") % (mgmt_script), level=9)
+    log.debug(_("MANAGEMENT script for user %s contents: %r") % (address,mgmt_script), level=9)
 
     result = sieveclient.putscript("MANAGEMENT", mgmt_script)
 
     if not result:
-        print "Putting in script MANAGEMENT failed...?"
+        log.error(_("Uploading script MANAGEMENT failed for user %s") % (address))
     else:
-        print "Putting in script MANAGEMENT succeeded"
+        log.debug(_("Uploading script MANAGEMENT for user %s succeeded") % (address), level=8)
 
     user_script = """#
 # User
@@ -372,17 +371,18 @@ require ["include"];
 
     for script in scripts:
         if not script in [ "MASTER", "MANAGEMENT", "USER" ]:
-            print "Including script %s in USER" % (script)
+            log.debug(_("Including script %s in USER (for user %s)") % (script,address) ,level=8)
             user_script = """%s
 
 include :personal "%s";
 """ % (user_script, script)
 
     result = sieveclient.putscript("USER", user_script)
+
     if not result:
-        print "Putting in script USER failed...?"
+        log.error(_("Uploading script USER failed for user %s") % (address))
     else:
-        print "Putting in script USER succeeded"
+        log.debug(_("Uploading script USER for user %s succeeded") % (address), level=8)
 
     result = sieveclient.putscript("MASTER", """#
 # MASTER
@@ -410,8 +410,8 @@ include :personal "USER";
 """)
 
     if not result:
-        print "Putting in script MASTER failed...?"
+        log.error(_("Uploading script MASTER failed for user %s") % (address))
     else:
-        print "Putting in script MASTER succeeded"
+        log.debug(_("Uploading script MASTER for user %s succeeded") % (address), level=8)
 
     sieveclient.setactive("MASTER")
diff --git a/pykolab/plugins/sievemgmt/__init__.py b/pykolab/plugins/sievemgmt/__init__.py
index 9a47423..df4720c 100644
--- a/pykolab/plugins/sievemgmt/__init__.py
+++ b/pykolab/plugins/sievemgmt/__init__.py
@@ -58,7 +58,6 @@ class KolabSievemgmt(object):
 
         user = auth.find_recipient(address)
 
-        print user, address
         log.info("User for address %r: %r" % (address, user))
 
         # Get the main, default backend
@@ -109,9 +108,8 @@ class KolabSievemgmt(object):
         else:
             active, scripts = result
 
-
-        print "Found the following scripts: %s" % (','.join(scripts))
-        print "And the following script is active: %s" % (active)
+        log.debug(_("Found the following scripts for user %s: %s") % (address, ','.join(scripts)), level=8)
+        log.deubg(_("And the following script is active for user %s: %s") % (address, active), level=8)
 
         mgmt_required_extensions = []
 
@@ -370,9 +368,9 @@ class KolabSievemgmt(object):
         result = sieveclient.putscript("MANAGEMENT", mgmt_script)
 
         if not result:
-            print "Putting in script MANAGEMENT failed...?"
-        #else:
-            #print "Putting in script MANAGEMENT succeeded"
+            log.error(_("Uploading script MANAGEMENT failed for user %s") % (address))
+        else:
+            log.debug(_("Uploading script MANAGEMENT for user %s succeeded") % (address), level=8)
 
         user_script = """#
 # User
@@ -383,17 +381,18 @@ require ["include"];
 
         for script in scripts:
             if not script in [ "MASTER", "MANAGEMENT", "USER" ]:
-                #print "Including script %s in USER" % (script)
+                log.debug(_("Including script %s in USER (for user %s)") % (script,address) ,level=8)
                 user_script = """%s
 
 include :personal "%s";
     """ % (user_script, script)
 
         result = sieveclient.putscript("USER", user_script)
+
         if not result:
-            print "Putting in script USER failed...?"
-        #else:
-            #print "Putting in script USER succeeded"
+            log.error(_("Uploading script USER failed for user %s") % (address))
+        else:
+            log.debug(_("Uploading script USER for user %s succeeded") % (address), level=8)
 
         result = sieveclient.putscript("MASTER", """#
 # MASTER
@@ -421,9 +420,9 @@ include :personal "USER";
 """)
 
         if not result:
-            print "Putting in script MASTER failed...?"
-        #else:
-            #print "Putting in script MASTER succeeded"
+            log.error(_("Uploading script MASTER failed for user %s") % (address))
+        else:
+            log.debug(_("Uploading script MASTER for user %s succeeded") % (address), level=8)
 
         sieveclient.setactive("MASTER")
 


commit 20976669015cde7e31319a9e727a4d0750690cc8
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Tue Jan 22 17:29:07 2013 +0000

    Add delivery to folder sieve rule (#1519)

diff --git a/pykolab/cli/sieve/cmd_refresh.py b/pykolab/cli/sieve/cmd_refresh.py
index 8d5703f..91e19cb 100644
--- a/pykolab/cli/sieve/cmd_refresh.py
+++ b/pykolab/cli/sieve/cmd_refresh.py
@@ -349,6 +349,9 @@ def execute(*args, **kw):
     if sdf_filter:
         mgmt_script.addfilter('spam_delivery_folder', [("X-Spam-Status", ":matches", "Yes,*")], [("fileinto", "INBOX/Spam"), ("stop")])
 
+    if dtf_active:
+        mgmt_script.addfilter('delivery_to_folder', ['true'], [("fileinto", dtf_folder)])
+
     mgmt_script = mgmt_script.__str__()
 
     log.debug(_("MANAGEMENT Script contents: %r") % (mgmt_script), level=9)
diff --git a/pykolab/plugins/sievemgmt/__init__.py b/pykolab/plugins/sievemgmt/__init__.py
index e87381c..9a47423 100644
--- a/pykolab/plugins/sievemgmt/__init__.py
+++ b/pykolab/plugins/sievemgmt/__init__.py
@@ -362,14 +362,17 @@ class KolabSievemgmt(object):
         if sdf_filter:
             mgmt_script.addfilter('spam_delivery_folder', [("X-Spam-Status", ":matches", "Yes,*")], [("fileinto", "INBOX/Spam"), ("stop")])
 
+        if dtf_active:
+            mgmt_script.addfilter('delivery_to_folder', ['true'], [("fileinto", dtf_folder)])
+
         mgmt_script = mgmt_script.__str__()
 
         result = sieveclient.putscript("MANAGEMENT", mgmt_script)
 
         if not result:
             print "Putting in script MANAGEMENT failed...?"
-        else:
-            print "Putting in script MANAGEMENT succeeded"
+        #else:
+            #print "Putting in script MANAGEMENT succeeded"
 
         user_script = """#
 # User
@@ -380,7 +383,7 @@ require ["include"];
 
         for script in scripts:
             if not script in [ "MASTER", "MANAGEMENT", "USER" ]:
-                print "Including script %s in USER" % (script)
+                #print "Including script %s in USER" % (script)
                 user_script = """%s
 
 include :personal "%s";
@@ -389,8 +392,8 @@ include :personal "%s";
         result = sieveclient.putscript("USER", user_script)
         if not result:
             print "Putting in script USER failed...?"
-        else:
-            print "Putting in script USER succeeded"
+        #else:
+            #print "Putting in script USER succeeded"
 
         result = sieveclient.putscript("MASTER", """#
 # MASTER
@@ -419,8 +422,8 @@ include :personal "USER";
 
         if not result:
             print "Putting in script MASTER failed...?"
-        else:
-            print "Putting in script MASTER succeeded"
+        #else:
+            #print "Putting in script MASTER succeeded"
 
         sieveclient.setactive("MASTER")
 





More information about the commits mailing list