summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-07-05 19:22:33 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-07-05 19:22:33 (GMT)
commit3491b74df4ef6010f2f3df223ca2c3d421cb3d51 (patch)
tree1a74edaa80de75b134dc63ab49e2a7fcf2976a99
parent6ffd3d291d73e778338525c48ba2572d5b4f969a (diff)
downloadpykolab-3491b74df4ef6010f2f3df223ca2c3d421cb3d51.tar.gz
Fix the utf7 backend versus preferred utf8 display
-rw-r--r--pykolab/cli/cmd_delete_mailbox.py2
-rw-r--r--pykolab/cli/cmd_list_mailbox_acls.py2
-rw-r--r--pykolab/cli/cmd_list_mailbox_metadata.py2
-rw-r--r--pykolab/cli/cmd_list_quota.py12
-rw-r--r--pykolab/cli/cmd_set_mailbox_acl.py2
-rw-r--r--pykolab/imap/__init__.py16
6 files changed, 24 insertions, 12 deletions
diff --git a/pykolab/cli/cmd_delete_mailbox.py b/pykolab/cli/cmd_delete_mailbox.py
index 51cbe69..47352d2 100644
--- a/pykolab/cli/cmd_delete_mailbox.py
+++ b/pykolab/cli/cmd_delete_mailbox.py
@@ -53,5 +53,5 @@ def execute(*args, **kw):
delete_folders = imap.list_folders(delete_folder)
for delete_folder in delete_folders:
- imap.delete_mailfolder(imap.folder_utf8(delete_folder))
+ imap.delete_mailfolder(delete_folder)
diff --git a/pykolab/cli/cmd_list_mailbox_acls.py b/pykolab/cli/cmd_list_mailbox_acls.py
index 62bac4f..5d7e04e 100644
--- a/pykolab/cli/cmd_list_mailbox_acls.py
+++ b/pykolab/cli/cmd_list_mailbox_acls.py
@@ -55,7 +55,7 @@ def execute(*args, **kw):
else:
acls = []
- folders = imap.lm(folder)
+ folders = imap.list_folders(folder)
for folder in folders:
print "Folder", folder
acls = imap.list_acls(folder)
diff --git a/pykolab/cli/cmd_list_mailbox_metadata.py b/pykolab/cli/cmd_list_mailbox_metadata.py
index b430896..17b8c02 100644
--- a/pykolab/cli/cmd_list_mailbox_metadata.py
+++ b/pykolab/cli/cmd_list_mailbox_metadata.py
@@ -81,7 +81,7 @@ def execute(*args, **kw):
else:
metadata = []
- folders = imap.lm(folder)
+ folders = imap.list_folders(folder)
for folder in folders:
print "Folder", folder
diff --git a/pykolab/cli/cmd_list_quota.py b/pykolab/cli/cmd_list_quota.py
index c81725a..1916631 100644
--- a/pykolab/cli/cmd_list_quota.py
+++ b/pykolab/cli/cmd_list_quota.py
@@ -50,7 +50,7 @@ def execute(*args, **kw):
folders = []
- quota_folders = imap.lm(quota_folder)
+ quota_folders = imap.list_folders(quota_folder)
for quota_folder in quota_folders:
try:
(used, quota) = imap.get_quota(quota_folder)
@@ -62,7 +62,10 @@ def execute(*args, **kw):
percentage = round(((float)(used)/(float)(quota)) * 100.0, 1)
print "%d (Used: %d, Percentage: %d)" % (quota, used, percentage)
else:
- print "No quota"
+ if used == None:
+ print "%d (Used: %d, Percentage: %d)" % (quota, 0, 0)
+ else:
+ print "No quota"
except:
try:
(quota_root, used, quota) = imap.get_quota_root(quota_folder)
@@ -74,7 +77,10 @@ def execute(*args, **kw):
percentage = round(((float)(used)/(float)(quota)) * 100.0, 1)
print "%d (Root: %s, Used: %d, Percentage: %d)" % (quota, quota_root, used, percentage)
else:
- print "No quota"
+ if used == None and not quota_root == None:
+ print "%d (Root: %s, Used: %d, Percentage: %d)" % (quota, quota_root, 0, 0)
+ else:
+ print "No quota"
except:
print "No quota root"
diff --git a/pykolab/cli/cmd_set_mailbox_acl.py b/pykolab/cli/cmd_set_mailbox_acl.py
index 8ba4567..0c76667 100644
--- a/pykolab/cli/cmd_set_mailbox_acl.py
+++ b/pykolab/cli/cmd_set_mailbox_acl.py
@@ -67,6 +67,6 @@ def execute(*args, **kw):
print >> sys.stderr, _("No such folder %r") % (folder)
else:
- folders = imap.lm(folder)
+ folders = imap.list_folders(folder)
for folder in folders:
imap.set_acl(folder, identifier, acl)
diff --git a/pykolab/imap/__init__.py b/pykolab/imap/__init__.py
index a9ab38d..15eca90 100644
--- a/pykolab/imap/__init__.py
+++ b/pykolab/imap/__init__.py
@@ -225,8 +225,14 @@ class IMAP(object):
"""
Obtain all metadata entries on a folder
"""
+ metadata = {}
- return self.imap.getannotation(folder, '*')
+ _metadata = self.imap.getannotation(self.folder_utf7(folder), '*')
+
+ for (k,v) in _metadata.items():
+ metadata[self.folder_utf8(k)] = v
+
+ return metadata
def namespaces(self):
"""
@@ -269,7 +275,7 @@ class IMAP(object):
Set an ACL entry on a folder.
"""
- self.imap.sam(folder, identifier, acl)
+ self.imap.sam(self.folder_utf7(folder), identifier, acl)
def set_metadata(self, folder, metadata_path, metadata_value, shared=True):
"""
@@ -541,7 +547,7 @@ class IMAP(object):
Check if the environment has a folder named folder.
"""
folders = self.imap.lm(self.folder_utf7(folder))
- log.debug(_("Looking for folder '%s', we found folders: %r") % (folder,folders), level=8)
+ log.debug(_("Looking for folder '%s', we found folders: %r") % (folder,[self.folder_utf8(x) for x in folders]), level=8)
# Greater then one, this folder may have subfolders.
if len(folders) > 0:
return True
@@ -811,10 +817,10 @@ class IMAP(object):
"""
List the ACL entries on a folder
"""
- return self.imap.lam(folder)
+ return self.imap.lam(self.folder_utf7(folder))
def list_folders(self, pattern):
- return self.lm(self.folder_utf7(pattern))
+ return [self.folder_utf8(x) for x in self.lm(self.folder_utf7(pattern))]
def list_user_folders(self, primary_domain=None, secondary_domains=[]):
"""