summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorChristoph Erhardt <kolab@sicherha.de>2021-06-04 16:53:52 +0200
committerChristoph Erhardt <kolab@sicherha.de>2022-01-10 20:46:43 +0100
commit991255eaa314b51e2dd586460311d4633a56eb86 (patch)
treee3e711046511d69fabdac2c67e66df4834a1e763 /pykolab
parentd0579b7e5da331576b80b9d35eb62994075bc939 (diff)
downloadpykolab-991255eaa314b51e2dd586460311d4633a56eb86.tar.gz
[Python 3] Use new exception syntax
Summary: The new syntax was introduced in Python 2.6; the old syntax was deprecated in Python 3.0. Reviewers: machniak, mollekopf Reviewed By: mollekopf Differential Revision: https://git.kolab.org/D3232
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/cli/cmd_add_domain.py2
-rw-r--r--pykolab/cli/cmd_add_user_subscription.py4
-rw-r--r--pykolab/cli/cmd_create_mailbox.py2
-rw-r--r--pykolab/cli/cmd_delete_domain.py2
-rw-r--r--pykolab/cli/cmd_delete_mailbox.py2
-rw-r--r--pykolab/cli/cmd_delete_mailbox_acl.py4
-rw-r--r--pykolab/cli/cmd_find_domain.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.py2
-rw-r--r--pykolab/cli/cmd_list_user_subscriptions.py4
-rw-r--r--pykolab/cli/cmd_remove_mailaddress.py2
-rw-r--r--pykolab/cli/cmd_remove_user_subscription.py4
-rw-r--r--pykolab/cli/cmd_rename_mailbox.py6
-rw-r--r--pykolab/cli/cmd_set_mailbox_acl.py6
-rw-r--r--pykolab/cli/cmd_set_mailbox_metadata.py6
-rw-r--r--pykolab/cli/cmd_set_quota.py4
-rw-r--r--pykolab/cli/cmd_sync_mailhost_attrs.py4
-rw-r--r--pykolab/cli/cmd_user_info.py2
-rw-r--r--pykolab/cli/commands.py6
-rw-r--r--pykolab/conf/entitlement.py32
-rw-r--r--pykolab/imap/cyrus.py8
-rw-r--r--pykolab/imap_utf7.py2
-rw-r--r--pykolab/plugins/__init__.py20
-rw-r--r--pykolab/plugins/defaultfolders/__init__.py2
-rw-r--r--pykolab/plugins/recipientpolicy/__init__.py10
-rw-r--r--pykolab/setup/components.py4
-rw-r--r--pykolab/telemetry.py2
-rw-r--r--pykolab/wap_client/__init__.py2
-rw-r--r--pykolab/xml/attendee.py14
-rw-r--r--pykolab/xml/contact.py2
-rw-r--r--pykolab/xml/event.py36
-rw-r--r--pykolab/xml/note.py4
-rw-r--r--pykolab/xml/todo.py4
34 files changed, 105 insertions, 105 deletions
diff --git a/pykolab/cli/cmd_add_domain.py b/pykolab/cli/cmd_add_domain.py
index a95373e..fecd82a 100644
--- a/pykolab/cli/cmd_add_domain.py
+++ b/pykolab/cli/cmd_add_domain.py
@@ -63,7 +63,7 @@ def execute(*args, **kw):
try:
domain = conf.cli_args.pop(0)
- except IndexError, errmsg:
+ except IndexError:
domain = utils.ask_question(_("Domain name"))
wap_client.domain_add(domain, conf.domains)
diff --git a/pykolab/cli/cmd_add_user_subscription.py b/pykolab/cli/cmd_add_user_subscription.py
index eb0ec40..06ac0e2 100644
--- a/pykolab/cli/cmd_add_user_subscription.py
+++ b/pykolab/cli/cmd_add_user_subscription.py
@@ -50,10 +50,10 @@ def execute(*args, **kw):
user = conf.cli_args.pop(0)
try:
folder_pattern = conf.cli_args.pop(0)
- except IndexError, errmsg:
+ except IndexError:
folder_pattern = utils.ask_question(_("Folder pattern"))
- except IndexError, errmsg:
+ except IndexError:
user = utils.ask_question(_("User ID"))
folder_pattern = utils.ask_question(_("Folder pattern"))
diff --git a/pykolab/cli/cmd_create_mailbox.py b/pykolab/cli/cmd_create_mailbox.py
index 385cbd1..9e91800 100644
--- a/pykolab/cli/cmd_create_mailbox.py
+++ b/pykolab/cli/cmd_create_mailbox.py
@@ -56,7 +56,7 @@ def description():
def execute(*args, **kw):
try:
mailbox = conf.cli_args.pop(0)
- except IndexError, errmsg:
+ except IndexError:
log.error(_("Invalid argument"))
sys.exit(1)
diff --git a/pykolab/cli/cmd_delete_domain.py b/pykolab/cli/cmd_delete_domain.py
index 94418c1..60ca55b 100644
--- a/pykolab/cli/cmd_delete_domain.py
+++ b/pykolab/cli/cmd_delete_domain.py
@@ -63,7 +63,7 @@ def execute(*args, **kw):
try:
domain = conf.cli_args.pop(0)
- except IndexError, errmsg:
+ except IndexError:
domain = utils.ask_question(_("Domain name"))
if wap_client.domain_delete(domain, conf.force):
diff --git a/pykolab/cli/cmd_delete_mailbox.py b/pykolab/cli/cmd_delete_mailbox.py
index f6ff254..40f8b44 100644
--- a/pykolab/cli/cmd_delete_mailbox.py
+++ b/pykolab/cli/cmd_delete_mailbox.py
@@ -67,6 +67,6 @@ def execute(*args, **kw):
for delete_folder in delete_folders:
try:
imap.delete_mailfolder(delete_folder)
- except Exception, errmsg:
+ except Exception:
log.error(_("Could not delete mailbox '%s'") % (delete_folder))
diff --git a/pykolab/cli/cmd_delete_mailbox_acl.py b/pykolab/cli/cmd_delete_mailbox_acl.py
index ebfc2ec..d146aac 100644
--- a/pykolab/cli/cmd_delete_mailbox_acl.py
+++ b/pykolab/cli/cmd_delete_mailbox_acl.py
@@ -43,10 +43,10 @@ def execute(*args, **kw):
folder = conf.cli_args.pop(0)
try:
identifier = conf.cli_args.pop(0)
- except IndexError, errmsg:
+ except IndexError:
identifier = utils.ask_question(_("ACI Subject"))
- except IndexError, errmsg:
+ except IndexError:
folder = utils.ask_question(_("Folder name"))
quota = utils.ask_question(_("ACI Subject"))
diff --git a/pykolab/cli/cmd_find_domain.py b/pykolab/cli/cmd_find_domain.py
index a573634..f65af3f 100644
--- a/pykolab/cli/cmd_find_domain.py
+++ b/pykolab/cli/cmd_find_domain.py
@@ -52,7 +52,7 @@ def execute(*args, **kw):
try:
domain = conf.cli_args.pop(0)
- except IndexError, errmsg:
+ except IndexError:
domain = utils.ask_question(_("Domain name"))
wap_client.domain_find(domain)
diff --git a/pykolab/cli/cmd_list_mailbox_acls.py b/pykolab/cli/cmd_list_mailbox_acls.py
index bf93429..8f14ee6 100644
--- a/pykolab/cli/cmd_list_mailbox_acls.py
+++ b/pykolab/cli/cmd_list_mailbox_acls.py
@@ -41,7 +41,7 @@ def description():
def execute(*args, **kw):
try:
folder = conf.cli_args.pop(0)
- except IndexError, errmsg:
+ except IndexError:
folder = utils.ask_question(_("Folder name"))
if len(folder.split('@')) > 1:
diff --git a/pykolab/cli/cmd_list_mailbox_metadata.py b/pykolab/cli/cmd_list_mailbox_metadata.py
index 718c376..7121723 100644
--- a/pykolab/cli/cmd_list_mailbox_metadata.py
+++ b/pykolab/cli/cmd_list_mailbox_metadata.py
@@ -52,7 +52,7 @@ def description():
def execute(*args, **kw):
try:
folder = conf.cli_args.pop(0)
- except IndexError, errmsg:
+ except IndexError:
folder = utils.ask_question(_("Folder name"))
if len(folder.split('@')) > 1:
diff --git a/pykolab/cli/cmd_list_quota.py b/pykolab/cli/cmd_list_quota.py
index 28b0cd5..d956168 100644
--- a/pykolab/cli/cmd_list_quota.py
+++ b/pykolab/cli/cmd_list_quota.py
@@ -53,7 +53,7 @@ def execute(*args, **kw):
try:
quota_folder = conf.cli_args.pop(0)
- except IndexError, e:
+ except IndexError:
quota_folder = '*'
imap = IMAP()
diff --git a/pykolab/cli/cmd_list_user_subscriptions.py b/pykolab/cli/cmd_list_user_subscriptions.py
index 2d8e4f3..ad6e549 100644
--- a/pykolab/cli/cmd_list_user_subscriptions.py
+++ b/pykolab/cli/cmd_list_user_subscriptions.py
@@ -56,10 +56,10 @@ def execute(*args, **kw):
user = conf.cli_args.pop(0)
try:
folder_pattern = conf.cli_args.pop(0)
- except IndexError, errmsg:
+ except IndexError:
pass
- except IndexError, errmsg:
+ except IndexError:
user = utils.ask_question(_("User ID"))
if len(user.split('@')) > 1:
diff --git a/pykolab/cli/cmd_remove_mailaddress.py b/pykolab/cli/cmd_remove_mailaddress.py
index bc94bb1..c3e5669 100644
--- a/pykolab/cli/cmd_remove_mailaddress.py
+++ b/pykolab/cli/cmd_remove_mailaddress.py
@@ -41,7 +41,7 @@ def description():
def execute(*args, **kw):
try:
email_address = conf.cli_args.pop(0)
- except IndexError, errmsg:
+ except IndexError:
email_address = utils.ask_question("Email address to remove")
# Get the domain from the email address
diff --git a/pykolab/cli/cmd_remove_user_subscription.py b/pykolab/cli/cmd_remove_user_subscription.py
index 343ee68..b16249c 100644
--- a/pykolab/cli/cmd_remove_user_subscription.py
+++ b/pykolab/cli/cmd_remove_user_subscription.py
@@ -50,10 +50,10 @@ def execute(*args, **kw):
user = conf.cli_args.pop(0)
try:
folder_pattern = conf.cli_args.pop(0)
- except IndexError, errmsg:
+ except IndexError:
folder_pattern = utils.ask_question(_("Folder pattern"))
- except IndexError, errmsg:
+ except IndexError:
user = utils.ask_question(_("User ID"))
folder_pattern = utils.ask_question(_("Folder pattern"))
diff --git a/pykolab/cli/cmd_rename_mailbox.py b/pykolab/cli/cmd_rename_mailbox.py
index c693211..4373acf 100644
--- a/pykolab/cli/cmd_rename_mailbox.py
+++ b/pykolab/cli/cmd_rename_mailbox.py
@@ -48,11 +48,11 @@ def execute(*args, **kw):
target_folder = conf.cli_args.pop(0)
try:
partition = conf.cli_args.pop(0)
- except IndexError, errmsg:
+ except IndexError:
partition = None
- except IndexError, errmsg:
+ except IndexError:
print(_("No target mailbox name specified"), file=sys.stderr)
- except IndexError, errmsg:
+ except IndexError:
print(_("No source mailbox name specified"), file=sys.stderr)
sys.exit(1)
diff --git a/pykolab/cli/cmd_set_mailbox_acl.py b/pykolab/cli/cmd_set_mailbox_acl.py
index 249c1ee..63b5c2d 100644
--- a/pykolab/cli/cmd_set_mailbox_acl.py
+++ b/pykolab/cli/cmd_set_mailbox_acl.py
@@ -45,14 +45,14 @@ def execute(*args, **kw):
identifier = conf.cli_args.pop(0)
try:
acl = conf.cli_args.pop(0)
- except IndexError, errmsg:
+ except IndexError:
acl = utils.ask_question(_("ACI Permissions"))
- except IndexError, errmsg:
+ except IndexError:
identifier = utils.ask_question(_("ACI Subject"))
acl = utils.ask_question(_("ACI Permissions"))
- except IndexError, errmsg:
+ except IndexError:
folder = utils.ask_question(_("Folder name"))
identifier = utils.ask_question(_("ACI Subject"))
acl = utils.ask_question(_("ACI Permissions"))
diff --git a/pykolab/cli/cmd_set_mailbox_metadata.py b/pykolab/cli/cmd_set_mailbox_metadata.py
index d63e6a6..91aec50 100644
--- a/pykolab/cli/cmd_set_mailbox_metadata.py
+++ b/pykolab/cli/cmd_set_mailbox_metadata.py
@@ -57,14 +57,14 @@ def execute(*args, **kw):
metadata_path = conf.cli_args.pop(0)
try:
metadata_value = conf.cli_args.pop(0)
- except IndexError, errmsg:
+ except IndexError:
metadata_value = utils.ask_question(_("Metadata value"))
- except IndexError, errmsg:
+ except IndexError:
metadata_path = utils.ask_question(_("Metadata path"))
metadata_value = utils.ask_question(_("Metadata value"))
- except IndexError, errmsg:
+ except IndexError:
folder = utils.ask_question(_("Folder name"))
metadata_path = utils.ask_question(_("Metadata path"))
metadata_value = utils.ask_question(_("Metadata value"))
diff --git a/pykolab/cli/cmd_set_quota.py b/pykolab/cli/cmd_set_quota.py
index 5b7b249..b6c89c1 100644
--- a/pykolab/cli/cmd_set_quota.py
+++ b/pykolab/cli/cmd_set_quota.py
@@ -43,10 +43,10 @@ def execute(*args, **kw):
folder = conf.cli_args.pop(0)
try:
quota = conf.cli_args.pop(0)
- except IndexError, errmsg:
+ except IndexError:
quota = utils.ask_question(_("New quota"))
- except IndexError, errmsg:
+ except IndexError:
folder = utils.ask_question(_("Folder name"))
quota = utils.ask_question(_("New quota"))
diff --git a/pykolab/cli/cmd_sync_mailhost_attrs.py b/pykolab/cli/cmd_sync_mailhost_attrs.py
index 512265b..7b70a77 100644
--- a/pykolab/cli/cmd_sync_mailhost_attrs.py
+++ b/pykolab/cli/cmd_sync_mailhost_attrs.py
@@ -113,7 +113,7 @@ def execute(*args, **kw):
log.info(_("Deleting mailbox '%s' because it has no recipients") % (folder))
try:
imap.dm(folder)
- except Exception, errmsg:
+ except Exception as errmsg:
log.error(_("An error occurred removing mailbox %r: %r") % (folder, errmsg))
else:
log.info(_("Not automatically deleting shared folder '%s'") % (folder))
@@ -161,7 +161,7 @@ def execute(*args, **kw):
log.info(_("Deleting mailbox '%s' because it has no recipients") % (folder))
try:
imap.dm(folder)
- except Exception, errmsg:
+ except Exception as errmsg:
log.error(_("An error occurred removing mailbox %r: %r") % (folder, errmsg))
else:
log.info(_("Not automatically deleting shared folder '%s'") % (folder))
diff --git a/pykolab/cli/cmd_user_info.py b/pykolab/cli/cmd_user_info.py
index a7879d1..e8a5766 100644
--- a/pykolab/cli/cmd_user_info.py
+++ b/pykolab/cli/cmd_user_info.py
@@ -39,7 +39,7 @@ def execute(*args, **kw):
try:
user = conf.cli_args.pop(0)
- except IndexError, errmsg:
+ except IndexError:
user = utils.ask_question(_("Email address"))
result = wap_client.authenticate(username=conf.get("ldap", "bind_dn"), password=conf.get("ldap", "bind_pw"))
diff --git a/pykolab/cli/commands.py b/pykolab/cli/commands.py
index 2f05bb6..196fa93 100644
--- a/pykolab/cli/commands.py
+++ b/pykolab/cli/commands.py
@@ -45,7 +45,7 @@ def __init__():
#print "exec(\"from %s import __init__ as %s_register\"" % (module_name,cmd_name)
try:
exec("from %s import __init__ as %s_register" % (module_name,cmd_name))
- except ImportError, errmsg:
+ except ImportError:
pass
exec("%s_register()" % (cmd_name))
@@ -123,7 +123,7 @@ def execute(cmd_name, *args, **kw):
try:
exec("from %s.cmd_%s import cli_options as %s_%s_cli_options" % (group,command_name,group,command_name))
exec("%s_%s_cli_options()" % (group,command_name))
- except ImportError, e:
+ except ImportError:
pass
else:
@@ -131,7 +131,7 @@ def execute(cmd_name, *args, **kw):
try:
exec("from cmd_%s import cli_options as %s_cli_options" % (command_name,command_name))
exec("%s_cli_options()" % (command_name))
- except ImportError, errmsg:
+ except ImportError:
pass
conf.finalize_conf()
diff --git a/pykolab/conf/entitlement.py b/pykolab/conf/entitlement.py
index 5dda82c..4ed79ec 100644
--- a/pykolab/conf/entitlement.py
+++ b/pykolab/conf/entitlement.py
@@ -54,8 +54,8 @@ class Entitlement(object):
)
if (bool)(ca_cert.has_expired()):
- raise Exception, _("Invalid entitlement verification " + \
- "certificate at %s" % (ca_cert_file))
+ raise Exception(_("Invalid entitlement verification " + \
+ "certificate at %s" % (ca_cert_file)))
# TODO: Check validity and warn ~1-2 months in advance.
@@ -77,8 +77,8 @@ class Entitlement(object):
ca_cert_issuer_hash_digest = hashlib.sha224(ca_cert_issuer_hash).hexdigest()
if not ca_cert_issuer_hash_digest in self.entitlement_verification:
- raise Exception, _("Invalid entitlement verification " + \
- "certificate at %s") % (ca_cert_file)
+ raise Exception(_("Invalid entitlement verification " + \
+ "certificate at %s") % (ca_cert_file))
ca_cert_subject_hash = subprocess.Popen(
[
@@ -95,8 +95,8 @@ class Entitlement(object):
ca_cert_subject_hash_digest = hashlib.sha224(ca_cert_subject_hash).hexdigest()
if not ca_cert_subject_hash_digest in self.entitlement_verification:
- raise Exception, _("Invalid entitlement verification " + \
- "certificate at %s") % (ca_cert_file)
+ raise Exception(_("Invalid entitlement verification " + \
+ "certificate at %s") % (ca_cert_file))
customer_cert_issuer_hash = subprocess.Popen(
[
@@ -113,14 +113,14 @@ class Entitlement(object):
customer_cert_issuer_hash_digest = hashlib.sha224(customer_cert_issuer_hash).hexdigest()
if not customer_cert_issuer_hash_digest in self.entitlement_verification:
- raise Exception, _("Invalid entitlement verification " + \
- "certificate at %s") % (customer_cert_file)
+ raise Exception(_("Invalid entitlement verification " + \
+ "certificate at %s") % (customer_cert_file))
if not ca_cert_issuer.countryName == ca_cert_subject.countryName:
- raise Exception, _("Invalid entitlement certificate")
+ raise Exception(_("Invalid entitlement certificate"))
if not ca_cert_issuer.organizationName == ca_cert_subject.organizationName:
- raise Exception, _("Invalid entitlement certificate")
+ raise Exception(_("Invalid entitlement certificate"))
if os.path.isdir('/etc/kolab/entitlement.d/') and \
os.access('/etc/kolab/entitlement.d/', os.R_OK):
@@ -227,8 +227,8 @@ class License(object):
).communicate()[0].strip().split('=')[1]
if not customer_cert_serial == cert_serial:
- raise Exception, _("Invalid entitlement verification " + \
- "certificate at %s") % (customer_cert_file)
+ raise Exception(_("Invalid entitlement verification " + \
+ "certificate at %s") % (customer_cert_file))
customer_cert_issuer_hash = subprocess.Popen(
[
@@ -243,8 +243,8 @@ class License(object):
).communicate()[0].strip()
if not customer_cert_issuer_hash == cert_issuer_hash:
- raise Exception, _("Invalid entitlement verification " + \
- "certificate at %s") % (customer_cert_file)
+ raise Exception(_("Invalid entitlement verification " + \
+ "certificate at %s") % (customer_cert_file))
customer_cert_subject_hash = subprocess.Popen(
[
@@ -259,8 +259,8 @@ class License(object):
).communicate()[0].strip()
if not customer_cert_subject_hash == cert_subject_hash:
- raise Exception, _("Invalid entitlement verification " + \
- "certificate at %s") % (customer_cert_file)
+ raise Exception(_("Invalid entitlement verification " + \
+ "certificate at %s") % (customer_cert_file))
def get(self):
return self.entitlement
diff --git a/pykolab/imap/cyrus.py b/pykolab/imap/cyrus.py
index 3f4c338..26e8f98 100644
--- a/pykolab/imap/cyrus.py
+++ b/pykolab/imap/cyrus.py
@@ -148,15 +148,15 @@ class Cyrus(cyruslib.CYRUS):
"""
try:
cyruslib.CYRUS.login(self, *args, **kw)
- except cyruslib.CYRUSError, errmsg:
+ except cyruslib.CYRUSError as errmsg:
log.error("Login to Cyrus IMAP server failed: %r", errmsg)
- except Exception, errmsg:
+ except Exception as errmsg:
log.exception(errmsg)
self.separator = self.SEP
try:
self._id()
- except Exception, errmsg:
+ except Exception:
pass
log.debug(
@@ -382,7 +382,7 @@ class Cyrus(cyruslib.CYRUS):
try:
self.setannotation(mailfolder, annotation, value, shared)
- except cyruslib.CYRUSError, errmsg:
+ except cyruslib.CYRUSError as errmsg:
log.error(
_("Could not set annotation %r on mail folder %r: %r") % (
annotation,
diff --git a/pykolab/imap_utf7.py b/pykolab/imap_utf7.py
index 038623b..0ecb83c 100644
--- a/pykolab/imap_utf7.py
+++ b/pykolab/imap_utf7.py
@@ -31,7 +31,7 @@ def encode(s):
if isinstance(s, str) and sum(n for n in (ord(c) for c in s) if n > 127):
try:
s = unicode(s, "UTF-8")
- except Exception, errmsg:
+ except Exception:
raise FolderNameError("%r contains characters not valid in a str folder name. "
"Convert to unicode first?" % s)
diff --git a/pykolab/plugins/__init__.py b/pykolab/plugins/__init__.py
index 82bf525..96e0044 100644
--- a/pykolab/plugins/__init__.py
+++ b/pykolab/plugins/__init__.py
@@ -67,15 +67,15 @@ class KolabPlugins(object):
exec("from pykolab.plugins import %s" % (plugin))
self.plugins[plugin] = True
self.load_plugins(plugins=[plugin])
- except ImportError, e:
+ except ImportError as e:
log.error(_("ImportError for plugin %s: %s") % (plugin, e))
traceback.print_exc()
self.plugins[plugin] = False
- except RuntimeError, e:
+ except RuntimeError as e:
log.error( _("RuntimeError for plugin %s: %s") % (plugin, e))
traceback.print_exc()
self.plugins[plugin] = False
- except Exception, e:
+ except Exception as e:
log.error(_("Plugin %s failed to load (%s: %s)") % (plugin, e.__class__, e))
traceback.print_exc()
except:
@@ -113,9 +113,9 @@ class KolabPlugins(object):
if hasattr(getattr(self, plugin), "set_defaults"):
try:
getattr(self, plugin).set_defaults(defaults)
- except TypeError, e:
+ except TypeError as e:
log.error(_("Cannot set defaults for plugin %s: %s") % (plugin, e))
- except RuntimeError, e:
+ except RuntimeError as e:
log.error(_("Cannot set defaults for plugin %s: %s") % (plugin, e))
except:
log.error(_("Cannot set defaults for plugin %s: Unknown Error") % (plugin))
@@ -139,7 +139,7 @@ class KolabPlugins(object):
if hasattr(getattr(self, plugin), "set_runtime"):
try:
getattr(self, plugin).set_runtime(runtime)
- except RuntimeError, e:
+ except RuntimeError as e:
log.error(_("Cannot set runtime for plugin %s: %s") % (plugin, e))
else:
log.debug(_("Not setting runtime for plugin %s: No function 'set_runtime()'") % (plugin), level=5)
@@ -160,9 +160,9 @@ class KolabPlugins(object):
if hasattr(getattr(self, plugin), "add_options"):
try:
exec("self.%s.add_options(parser)" % plugin)
- except RuntimeError, e:
+ except RuntimeError as e:
log.error(_("Cannot add options for plugin %s: %s") % (plugin, e))
- except TypeError, e:
+ except TypeError as e:
log.error(_("Cannot add options for plugin %s: %s") % (plugin, e))
else:
log.debug(_("Not adding options for plugin %s: No function 'add_options()'") % plugin, level=5)
@@ -184,7 +184,7 @@ class KolabPlugins(object):
if hasattr(getattr(self, plugin), "check_options"):
try:
exec("self.%s.check_options()" % plugin)
- except AttributeError, e:
+ except AttributeError as e:
log.error(_("Cannot check options for plugin %s: %s") % (plugin, e))
else:
log.debug(_("Not checking options for plugin %s: No function 'check_options()'") % (plugin), level=5)
@@ -262,7 +262,7 @@ class KolabPlugins(object):
if hasattr(getattr(self, plugin), bool):
try:
exec("boolval = self.%s.%s" % (plugin, bool))
- except AttributeError, e:
+ except AttributeError:
pass
else:
boolval = None
diff --git a/pykolab/plugins/defaultfolders/__init__.py b/pykolab/plugins/defaultfolders/__init__.py
index e098ec2..0b6ee10 100644
--- a/pykolab/plugins/defaultfolders/__init__.py
+++ b/pykolab/plugins/defaultfolders/__init__.py
@@ -49,7 +49,7 @@ class KolabDefaultfolders(object):
try:
exec("additional_folders = %s" % (kw['additional_folders']))
- except Exception, e:
+ except Exception:
log.error(_("Could not parse additional_folders"))
return {}
diff --git a/pykolab/plugins/recipientpolicy/__init__.py b/pykolab/plugins/recipientpolicy/__init__.py
index 23ba863..aab2a5e 100644
--- a/pykolab/plugins/recipientpolicy/__init__.py
+++ b/pykolab/plugins/recipientpolicy/__init__.py
@@ -75,7 +75,7 @@ class KolabRecipientpolicy(object):
mail = utils.translate(mail, user_attrs['preferredlanguage'])
mail = mail.lower()
return mail
- except KeyError, e:
+ except KeyError:
log.warning(_("Attribute substitution for 'mail' failed in Recipient Policy"))
if user_attrs.has_key('mail'):
return user_attrs['mail']
@@ -112,7 +112,7 @@ class KolabRecipientpolicy(object):
try:
exec("alternative_mail_routines = %s" % kw['secondary_mail'])
- except Exception, e:
+ except Exception:
log.error(_("Could not parse the alternative mail routines"))
alternative_mail = []
@@ -123,7 +123,7 @@ class KolabRecipientpolicy(object):
for attr in [ 'givenname', 'sn', 'surname' ]:
try:
user_attrs[attr] = utils.translate(user_attrs[attr], user_attrs['preferredlanguage'])
- except Exception, errmsg:
+ except Exception:
log.error(_("An error occurred in composing the secondary mail attribute for entry %r") % (user_attrs['id']))
if conf.debuglevel > 8:
import traceback
@@ -138,7 +138,7 @@ class KolabRecipientpolicy(object):
log.debug(_("Appending additional mail address: %s") % (retval), level=8)
alternative_mail.append(retval)
- except Exception, errmsg:
+ except Exception as errmsg:
log.error(_("Policy for secondary email address failed: %r") % (errmsg))
if conf.debuglevel > 8:
import traceback
@@ -153,7 +153,7 @@ class KolabRecipientpolicy(object):
log.debug(_("Appending additional mail address: %s") % (retval), level=8)
alternative_mail.append(retval)
- except KeyError, e:
+ except KeyError:
log.warning(_("Attribute substitution for 'alternative_mail' failed in Recipient Policy"))
alternative_mail = utils.normalize(alternative_mail)
diff --git a/pykolab/setup/components.py b/pykolab/setup/components.py
index 8e9f346..5cc7b58 100644
--- a/pykolab/setup/components.py
+++ b/pykolab/setup/components.py
@@ -130,14 +130,14 @@ def cli_options_from_component(component_name, *args, **kw):
try:
exec("from %s.setup_%s import cli_options as %s_%s_cli_options" % (group,component_name,group,component_name))
exec("%s_%s_cli_options()" % (group,component_name))
- except ImportError, e:
+ except ImportError:
pass
else:
try:
exec("from setup_%s import cli_options as %s_cli_options" % (component_name,component_name))
exec("%s_cli_options()" % (component_name))
- except ImportError, e:
+ except ImportError:
pass
components_included_in_cli.append(component_name)
diff --git a/pykolab/telemetry.py b/pykolab/telemetry.py
index 28b60f9..adeadd7 100644
--- a/pykolab/telemetry.py
+++ b/pykolab/telemetry.py
@@ -642,7 +642,7 @@ def init_db():
try:
metadata.create_all(engine)
- except sqlalchemy.exc.OperationalError, e:
+ except sqlalchemy.exc.OperationalError as e:
log.error(_("Operational Error in telemetry database: %s" % (e)))
Session = sessionmaker(bind=engine)
diff --git a/pykolab/wap_client/__init__.py b/pykolab/wap_client/__init__.py
index 82f7ebb..956fbf5 100644
--- a/pykolab/wap_client/__init__.py
+++ b/pykolab/wap_client/__init__.py
@@ -436,7 +436,7 @@ def request_raw(method, api_uri, get=None, post=None, headers={}, isretry=False)
try:
response_data = json.loads(data)
- except ValueError, e:
+ except ValueError:
# Some data is not JSON
log.error(_("Response data is not JSON"))
diff --git a/pykolab/xml/attendee.py b/pykolab/xml/attendee.py
index 41447db..099e21a 100644
--- a/pykolab/xml/attendee.py
+++ b/pykolab/xml/attendee.py
@@ -132,14 +132,14 @@ class Attendee(kolabformat.Attendee):
for delegator in delegators:
if not isinstance(delegator, Attendee):
- raise ValueError, _("Not a valid attendee")
+ raise ValueError(_("Not a valid attendee"))
else:
self.set_role(delegator.get_role())
self.set_cutype(delegator.get_cutype())
crefs.append(delegator.contactreference)
if len(crefs) == 0:
- raise ValueError, _("No valid delegator references found")
+ raise ValueError(_("No valid delegator references found"))
else:
crefs += self.get_delegated_from()
@@ -154,12 +154,12 @@ class Attendee(kolabformat.Attendee):
for delegatee in delegatees:
if not isinstance(delegatee, Attendee):
- raise ValueError, _("Not a valid attendee")
+ raise ValueError(_("Not a valid attendee"))
else:
crefs.append(delegatee.contactreference)
if len(crefs) == 0:
- raise ValueError, _("No valid delegatee references found")
+ raise ValueError(_("No valid delegatee references found"))
else:
crefs += self.get_delegated_to()
@@ -219,7 +219,7 @@ class Attendee(kolabformat.Attendee):
elif cutype in self.cutype_map.values():
self.setCutype(cutype)
else:
- raise InvalidAttendeeCutypeError, _("Invalid cutype %r") % (cutype)
+ raise InvalidAttendeeCutypeError(_("Invalid cutype %r") % (cutype))
def set_name(self, name):
self.contactreference.set_name(name)
@@ -231,7 +231,7 @@ class Attendee(kolabformat.Attendee):
elif participant_status in self.participant_status_map.values():
self.setPartStat(participant_status)
else:
- raise InvalidAttendeeParticipantStatusError, _("Invalid participant status %r") % (participant_status)
+ raise InvalidAttendeeParticipantStatusError(_("Invalid participant status %r") % (participant_status))
def set_role(self, role):
if role in self.role_map.keys():
@@ -239,7 +239,7 @@ class Attendee(kolabformat.Attendee):
elif role in self.role_map.values():
self.setRole(role)
else:
- raise InvalidAttendeeRoleError, _("Invalid role %r") % (role)
+ raise InvalidAttendeeRoleError(_("Invalid role %r") % (role))
def set_rsvp(self, rsvp):
self.setRSVP(rsvp)
diff --git a/pykolab/xml/contact.py b/pykolab/xml/contact.py
index 2b08f9a..f4fd9a5 100644
--- a/pykolab/xml/contact.py
+++ b/pykolab/xml/contact.py
@@ -328,7 +328,7 @@ class Contact(kolabformat.Contact):
if error == None or not error:
return xml
else:
- raise ContactIntegrityError, kolabformat.errorMessage()
+ raise ContactIntegrityError(kolabformat.errorMessage())
class ContactIntegrityError(Exception):
diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py
index a668f77..3fa5cdc 100644
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -166,7 +166,7 @@ class Event(object):
valid_datetime = True
if not valid_datetime:
- raise InvalidEventDateError, _("Rdate needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime))
+ raise InvalidEventDateError(_("Rdate needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime)))
self.event.addRecurrenceDate(xmlutils.to_cdatetime(_datetime, True))
@@ -183,14 +183,14 @@ class Event(object):
valid_datetime = True
if not valid_datetime:
- raise InvalidEventDateError, _("Exdate needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime))
+ raise InvalidEventDateError(_("Exdate needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime)))
self.event.addExceptionDate(xmlutils.to_cdatetime(_datetime, True))
def add_exception(self, exception):
recurrence_id = exception.get_recurrence_id()
if recurrence_id is None:
- raise EventIntegrityError, "Recurrence exceptions require a Recurrence-ID property"
+ raise EventIntegrityError("Recurrence exceptions require a Recurrence-ID property")
# check if an exception with the given recurrence-id already exists
append = True
@@ -218,7 +218,7 @@ class Event(object):
def del_exception(self, exception):
recurrence_id = exception.get_recurrence_id()
if recurrence_id is None:
- raise EventIntegrityError, "Recurrence exceptions require a Recurrence-ID property"
+ raise EventIntegrityError("Recurrence exceptions require a Recurrence-ID property")
updated = False
vexceptions = self.event.exceptions()
@@ -402,7 +402,7 @@ class Event(object):
attendee = self.get_attendee_by_name(attendee)
else:
- raise ValueError, _("No attendee with email or name %r") %(attendee)
+ raise ValueError(_("No attendee with email or name %r") %(attendee))
return attendee
@@ -410,7 +410,7 @@ class Event(object):
return attendee
else:
- raise ValueError, _("Invalid argument value attendee %r, must be basestring or Attendee") % (attendee)
+ raise ValueError(_("Invalid argument value attendee %r, must be basestring or Attendee") % (attendee))
def find_attendee(self, attendee):
try:
@@ -422,13 +422,13 @@ class Event(object):
if email in [x.get_email() for x in self.get_attendees()]:
return [x for x in self.get_attendees() if x.get_email() == email][0]
- raise ValueError, _("No attendee with email %r") %(email)
+ raise ValueError(_("No attendee with email %r") %(email))
def get_attendee_by_name(self, name):
if name in [x.get_name() for x in self.get_attendees()]:
return [x for x in self.get_attendees() if x.get_name() == name][0]
- raise ValueError, _("No attendee with name %r") %(name)
+ raise ValueError(_("No attendee with name %r") %(name))
def get_attendees(self):
return self._attendees
@@ -613,7 +613,7 @@ class Event(object):
elif attendee.get_participant_status() in attendee.participant_status_map.values():
return [k for k, v in attendee.participant_status_map.iteritems() if v == attendee.get_participant_status()][0]
else:
- raise ValueError, _("Invalid participant status")
+ raise ValueError(_("Invalid participant status"))
def get_ical_created(self):
return self.get_created()
@@ -819,7 +819,7 @@ class Event(object):
elif classification in self.classification_map.values():
self.event.setClassification(classification)
else:
- raise ValueError, _("Invalid classification %r") % (classification)
+ raise ValueError(_("Invalid classification %r") % (classification))
def set_created(self, _datetime=None):
if _datetime is None or isinstance(_datetime, datetime.time):
@@ -850,7 +850,7 @@ class Event(object):
valid_datetime = True
if not valid_datetime:
- raise InvalidEventDateError, _("Event end needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime))
+ raise InvalidEventDateError(_("Event end needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime)))
self.event.setEnd(xmlutils.to_cdatetime(_datetime, True))
@@ -864,7 +864,7 @@ class Event(object):
def add_custom_property(self, name, value):
if not name.upper().startswith('X-'):
- raise ValueError, _("Invalid custom property name %r") % (name)
+ raise ValueError(_("Invalid custom property name %r") % (name))
props = self.event.customProperties()
props.append(kolabformat.CustomProperty(name.upper(), value))
@@ -1001,7 +1001,7 @@ class Event(object):
try:
self.thisandfuture = params.get('RANGE', '') == 'THISANDFUTURE'
self.set_recurrence_id(value, self.thisandfuture)
- except InvalidEventDateError, e:
+ except InvalidEventDateError:
pass
def set_lastmodified(self, _datetime=None):
@@ -1017,7 +1017,7 @@ class Event(object):
_datetime = datetime.datetime.utcnow()
if not valid_datetime:
- raise InvalidEventDateError, _("Event last-modified needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime))
+ raise InvalidEventDateError(_("Event last-modified needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime)))
self.event.setLastModified(xmlutils.to_cdatetime(_datetime, False, True))
@@ -1060,7 +1060,7 @@ class Event(object):
valid_datetime = True
if not valid_datetime:
- raise InvalidEventDateError, _("Event start needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime))
+ raise InvalidEventDateError(_("Event start needs datetime.date or datetime.datetime instance, got %r") % (type(_datetime)))
self.event.setStart(xmlutils.to_cdatetime(_datetime, True))
@@ -1070,7 +1070,7 @@ class Event(object):
elif status in self.status_map.values():
self.event.setStatus(status)
elif not status == kolabformat.StatusUndefined:
- raise InvalidEventStatusError, _("Invalid status set: %r") % (status)
+ raise InvalidEventStatusError(_("Invalid status set: %r") % (status))
def set_summary(self, summary):
self.event.setSummary(summary)
@@ -1093,7 +1093,7 @@ class Event(object):
valid_datetime = True
if not valid_datetime:
- raise InvalidEventDateError, _("Event recurrence-id needs datetime.datetime instance")
+ raise InvalidEventDateError(_("Event recurrence-id needs datetime.datetime instance"))
if _thisandfuture is None:
_thisandfuture = self.thisandfuture
@@ -1111,7 +1111,7 @@ class Event(object):
if error == None or not error:
return event_xml
else:
- raise EventIntegrityError, kolabformat.errorMessage()
+ raise EventIntegrityError(kolabformat.errorMessage())
def to_dict(self):
data = dict()
diff --git a/pykolab/xml/note.py b/pykolab/xml/note.py
index 0fc7c24..5784ebb 100644
--- a/pykolab/xml/note.py
+++ b/pykolab/xml/note.py
@@ -91,7 +91,7 @@ class Note(kolabformat.Note):
elif classification in self.classification_map.values():
self.setClassification(status)
else:
- raise ValueError, _("Invalid classification %r") % (classification)
+ raise ValueError(_("Invalid classification %r") % (classification))
def add_category(self, category):
_categories = self.categories()
@@ -131,7 +131,7 @@ class Note(kolabformat.Note):
if error == None or not error:
return xml
else:
- raise NoteIntegrityError, kolabformat.errorMessage()
+ raise NoteIntegrityError(kolabformat.errorMessage())
class NoteIntegrityError(Exception):
def __init__(self, message):
diff --git a/pykolab/xml/todo.py b/pykolab/xml/todo.py
index ccd798f..1c711b5 100644
--- a/pykolab/xml/todo.py
+++ b/pykolab/xml/todo.py
@@ -162,7 +162,7 @@ class Todo(Event):
valid_datetime = True
if not valid_datetime:
- raise InvalidEventDateError, _("Todo due needs datetime.date or datetime.datetime instance")
+ raise InvalidEventDateError(_("Todo due needs datetime.date or datetime.datetime instance"))
self.event.setDue(xmlutils.to_cdatetime(_datetime, True))
@@ -259,7 +259,7 @@ class Todo(Event):
if error == None or not error:
return xml
else:
- raise TodoIntegrityError, kolabformat.errorMessage()
+ raise TodoIntegrityError(kolabformat.errorMessage())
class TodoIntegrityError(Exception):