summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2015-04-21 21:33:51 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2015-05-14 09:58:04 +0200
commitdac4ed9786b7418885cc764b10438462cdac9138 (patch)
treea038d52d1c3ef2c75a60f6082cacc87e0ce14816
parent897f964f90696061060b002f6e097b1790b4eb10 (diff)
downloadpykolab-dac4ed9786b7418885cc764b10438462cdac9138.tar.gz
Add a --user and --server parameter to list-messages
-rw-r--r--pykolab/cli/cmd_list_messages.py41
1 files changed, 38 insertions, 3 deletions
diff --git a/pykolab/cli/cmd_list_messages.py b/pykolab/cli/cmd_list_messages.py
index 0ebc1af..db59a48 100644
--- a/pykolab/cli/cmd_list_messages.py
+++ b/pykolab/cli/cmd_list_messages.py
@@ -43,6 +43,24 @@ def cli_options():
help = _("Include messages flagged as \Deleted")
)
+ my_option_group.add_option(
+ '--server',
+ dest = "connect_server",
+ action = "store",
+ default = None,
+ metavar = "SERVER",
+ help = _("List mailboxes on server SERVER only.")
+ )
+
+ my_option_group.add_option(
+ '--user',
+ dest = "user",
+ action = "store",
+ default = None,
+ metavar = "USER",
+ help = _("List messages as user USER")
+ )
+
def description():
return _("List messages in a folder")
@@ -58,8 +76,23 @@ def execute(*args, **kw):
log.error(_("Specify a folder"))
sys.exit(1)
+ domain = None
+
imap = IMAP()
- imap.connect()
+
+ if not conf.user == None:
+ imap.connect(domain=domain, login=False, server=conf.connect_server)
+
+ backend = conf.get(domain, 'imap_backend')
+ if backend == None:
+ backend = conf.get('kolab', 'imap_backend')
+
+ admin_login = conf.get(backend, 'admin_login')
+ admin_password = conf.get(backend, 'admin_password')
+
+ imap.login_plain(admin_login, admin_password, conf.user)
+ else:
+ imap.connect(domain=domain, server=conf.connect_server)
_folder = imap.lm(imap_utf7.encode(folder))
@@ -67,7 +100,8 @@ def execute(*args, **kw):
log.error(_("No such folder"))
sys.exit(1)
- imap.set_acl(folder, 'cyrus-admin', 'lrs')
+ if conf.user == None:
+ imap.set_acl(folder, 'cyrus-admin', 'lrs')
imap.select(imap_utf7.encode(folder))
@@ -96,4 +130,5 @@ def execute(*args, **kw):
else:
print num
- imap.set_acl(folder, 'cyrus-admin', '')
+ if conf.user == None:
+ imap.set_acl(folder, 'cyrus-admin', '')