summaryrefslogtreecommitdiffstats
path: root/pykolab/cli
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2016-05-18 09:40:17 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2016-05-18 09:40:17 +0200
commit67e65cd5271658bd106a42f427904cf0374c8cd2 (patch)
treec1fc2bdfbfebc5c6ba2b3401d130a2c7af525140 /pykolab/cli
parente7bbf664076622b2a4dc51d492298cd5d984f8fb (diff)
downloadpykolab-67e65cd5271658bd106a42f427904cf0374c8cd2.tar.gz
Determine shared folder resource using kolabTargetFolder attribute (#5337)
Summary: It's supposed to fix #5337. WARNING: Untested!!!!!!!! Reviewers: #pykolab_developers, vanmeeuwen Reviewed By: #pykolab_developers, vanmeeuwen Subscribers: vanmeeuwen Differential Revision: https://git.kolab.org/D130
Diffstat (limited to 'pykolab/cli')
-rw-r--r--pykolab/cli/cmd_sync_mailhost_attrs.py37
1 files changed, 26 insertions, 11 deletions
diff --git a/pykolab/cli/cmd_sync_mailhost_attrs.py b/pykolab/cli/cmd_sync_mailhost_attrs.py
index 131157e..fe7f6b2 100644
--- a/pykolab/cli/cmd_sync_mailhost_attrs.py
+++ b/pykolab/cli/cmd_sync_mailhost_attrs.py
@@ -95,14 +95,18 @@ def execute(*args, **kw):
folders.extend(imap.lm('user/%%@%s' % (domain)))
for folder in folders:
+ r_folder = folder
+ if not folder.startswith('shared/'):
+ r_folder = '/'.join(folder.split('/')[1:])
+
if conf.delete:
if conf.dry_run:
- if not folder.split('/')[0] == 'shared':
- log.warning(_("No recipients for '%s' (would have deleted the mailbox if not for --dry-run)!") % ('/'.join(folder.split('/')[1:])))
+ if not folder.startswith('shared/'):
+ log.warning(_("No recipients for '%s' (would have deleted the mailbox if not for --dry-run)!") % (r_folder))
else:
continue
else:
- if not '/'.join(folder.split('/')[0]) == 'shared':
+ if not folder.startswith('shared/'):
log.info(_("Deleting mailbox '%s' because it has no recipients") % (folder))
try:
imap.dm(folder)
@@ -111,7 +115,7 @@ def execute(*args, **kw):
else:
log.info(_("Not automatically deleting shared folder '%s'") % (folder))
else:
- log.warning(_("No recipients for '%s' (use --delete to delete)!") % ('/'.join(folder.split('/')[1:])))
+ log.warning(_("No recipients for '%s' (use --delete to delete)!") % (r_folder))
for primary in list(set(domains.values())):
secondaries = [x for x in domains.keys() if domains[x] == primary]
@@ -130,20 +134,27 @@ def execute(*args, **kw):
for folder in folders:
server = imap.user_mailbox_server(folder)
- recipient = auth.find_recipient('/'.join(folder.split('/')[1:]))
+ r_folder = folder
+
+ if folder.startswith('shared/'):
+ recipient = auth.find_folder_resource(folder)
+ else:
+ r_folder = '/'.join(folder.split('/')[1:])
+ recipient = auth.find_recipient(r_folder)
+
if (isinstance(recipient, list)):
if len(recipient) > 1:
- log.warning(_("Multiple recipients for '%s'!") % ('/'.join(folder.split('/')[1:])))
+ log.warning(_("Multiple recipients for '%s'!") % (r_folder))
continue
elif len(recipient) == 0:
if conf.delete:
if conf.dry_run:
- if not folder.split('/')[0] == 'shared':
- log.warning(_("No recipients for '%s' (would have deleted the mailbox if not for --dry-run)!") % ('/'.join(folder.split('/')[1:])))
+ if not folder.startswith('shared/'):
+ log.warning(_("No recipients for '%s' (would have deleted the mailbox if not for --dry-run)!") % (r_folder))
else:
continue
else:
- if not '/'.join(folder.split('/')[0]) == 'shared':
+ if not folder.startswith('shared/'):
log.info(_("Deleting mailbox '%s' because it has no recipients") % (folder))
try:
imap.dm(folder)
@@ -152,7 +163,7 @@ def execute(*args, **kw):
else:
log.info(_("Not automatically deleting shared folder '%s'") % (folder))
else:
- log.warning(_("No recipients for '%s' (use --delete to delete)!") % ('/'.join(folder.split('/')[1:])))
+ log.warning(_("No recipients for '%s' (use --delete to delete)!") % (r_folder))
continue
else:
@@ -173,6 +184,10 @@ def execute(*args, **kw):
for folder in folders:
server = imap.user_mailbox_server(folder)
- recipient = auth.find_recipient('/'.join(folder.split('/')[1:]))
+
+ if folder.startswith('shared/'):
+ recipient = auth.find_folder_resource(folder)
+ else:
+ recipient = auth.find_recipient('/'.join(folder.split('/')[1:]))
print folder, server, recipient