summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-11-21 14:43:59 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-11-21 14:43:59 +0100
commit6bf3cdc14e8b41e303f5204545c380c8813a30a5 (patch)
tree7daca2f650e0e1b5ae9e88ded89ad47dc18bc74c /pykolab
parent998804c66908f84e5e7b2da4685dd3043b8e8c1c (diff)
downloadpykolab-6bf3cdc14e8b41e303f5204545c380c8813a30a5.tar.gz
Add an option --dry-run to undelete-mailbox cmd
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/cli/cmd_undelete_mailbox.py8
-rw-r--r--pykolab/imap/cyrus.py13
2 files changed, 18 insertions, 3 deletions
diff --git a/pykolab/cli/cmd_undelete_mailbox.py b/pykolab/cli/cmd_undelete_mailbox.py
index 46eec85..8f9c791 100644
--- a/pykolab/cli/cmd_undelete_mailbox.py
+++ b/pykolab/cli/cmd_undelete_mailbox.py
@@ -30,6 +30,14 @@ conf = pykolab.getConf()
def __init__():
commands.register('undelete_mailbox', execute, description=description())
+def cli_options():
+ my_option_group = conf.add_cli_parser_option_group(_("CLI Options"))
+ my_option_group.add_option( '--dry-run',
+ dest = "dry_run",
+ action = "store_true",
+ default = False,
+ help = _("Do not actually execute, but state what would have been executed."))
+
def description(*args, **kw):
return _("Recover mailboxes previously deleted.")
diff --git a/pykolab/imap/cyrus.py b/pykolab/imap/cyrus.py
index 6034b48..ae90fd6 100644
--- a/pykolab/imap/cyrus.py
+++ b/pykolab/imap/cyrus.py
@@ -18,6 +18,7 @@
#
import cyruslib
+import sys
import time
from urlparse import urlparse
@@ -323,10 +324,16 @@ class Cyrus(cyruslib.CYRUS):
target_server = self.find_mailfolder_server(target_folder)
- if not target_server == self.server:
- self.xfer(undelete_folder,target_server)
+ if hasattr(conf,'dry_run') and not conf.dry_run:
+ if not target_server == self.server:
+ self.xfer(undelete_folder,target_server)
- self.rename(undelete_folder,target_folder)
+ self.rename(undelete_folder,target_folder)
+ else:
+ if not target_server == self.server:
+ print >> sys.stdout, _("Would have transfered %s from %s to %s") % (undelete_folder, self.server, target_server)
+
+ print >> sys.stdout, _("Would have renamed %s to %s") % (undelete_folder, target_folder)
def parse_mailfolder(self, mailfolder):
"""