summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2021-10-12 14:06:09 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2022-01-08 09:46:26 +0100
commit28c1caa4f436422456b50f89fb10b4dc59da0ac7 (patch)
treecd02943397aca6211a70fb39e9d149f7e046be76 /pykolab
parente151745ace2c939c419d25798ed0b340872c7ef2 (diff)
downloadpykolab-28c1caa4f436422456b50f89fb10b4dc59da0ac7.tar.gz
Syntax
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/auth/ldap/__init__.py7
-rw-r--r--pykolab/imap/__init__.py24
-rw-r--r--pykolab/logger.py2
3 files changed, 21 insertions, 12 deletions
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 046c30c..b174579 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -1723,13 +1723,18 @@ class LDAP(Base):
self.get_entry_attribute(entry, mailserver_attribute)
rcpt_addrs = self.recipient_policy(entry)
+
for key in rcpt_addrs:
entry[key] = rcpt_addrs[key]
if result_attribute not in entry:
+ entry[result_attribute] = self.get_entry_attribute(entry, result_attribute)
return
- if entry[result_attribute] is None:
+ if result_attribute not in entry:
+ return
+
+ if not entry[result_attribute]:
return
if entry[result_attribute] == '':
diff --git a/pykolab/imap/__init__.py b/pykolab/imap/__init__.py
index 813d722..1ac6896 100644
--- a/pykolab/imap/__init__.py
+++ b/pykolab/imap/__init__.py
@@ -89,7 +89,7 @@ class IMAP(object):
self.set_acl(folder, acl_entry, '')
- except Exception, errmsg:
+ except Exception as errmsg:
log.error(
_("Failed to read/set ACL on folder %s: %r") % (
folder,
@@ -240,14 +240,17 @@ class IMAP(object):
if server is None:
# No server specified, but make sure self.imap is None anyways
if hasattr(self, 'imap'):
+ self.imap.disconnect()
del self.imap
# Empty out self._imap as well
for key in self._imap.keys():
+ self._imap[key].disconnect()
del self._imap[key]
else:
if server in self._imap:
+ self._imap[server].disconnect()
del self._imap[server]
else:
log.warning(
@@ -263,27 +266,28 @@ class IMAP(object):
try:
self._imap[server].cm(folder_path, partition=partition)
return True
- except Exception:
- log.error(_("Could not create folder %r on server %r") % (folder_path, server))
+ except Exception as excpt:
+ log.error(
+ _("Could not create folder %r on server %r: %r") % (folder_path, server, excpt)
+ )
else:
try:
self.imap.cm(folder_path, partition=partition)
return True
- except Exception:
- log.error(_("Could not create folder %r") % (folder_path))
+ except Exception as excpt:
+ log.error(_("Could not create folder %r: %r") % (folder_path, excpt))
return False
def __getattr__(self, name):
if hasattr(self.imap, name):
return getattr(self.imap, name)
- elif hasattr(self.imap, 'm'):
+
+ if hasattr(self.imap, 'm'):
if hasattr(self.imap.m, name):
return getattr(self.imap.m, name)
- else:
- raise AttributeError(_("%r has no attribute %s") % (self, name))
- else:
- raise AttributeError(_("%r has no attribute %s") % (self, name))
+
+ raise AttributeError(_("%r has no attribute %s") % (self, name))
def append(self, folder, message):
return self.imap.m.append(self.folder_utf7(folder), None, None, message)
diff --git a/pykolab/logger.py b/pykolab/logger.py
index 2b857e2..c2237cb 100644
--- a/pykolab/logger.py
+++ b/pykolab/logger.py
@@ -213,7 +213,7 @@ class Logger(logging.Logger):
group_gid
)
- os.chmod(self.logfile, 0660)
+ os.chmod(self.logfile, '0660')
except Exception as errmsg:
self.error(