Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117921776
D3232.1775432640.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
49 KB
Referenced Files
None
Subscribers
None
D3232.1775432640.diff
View Options
diff --git a/conf.py b/conf.py
--- a/conf.py
+++ b/conf.py
@@ -34,7 +34,7 @@
try:
import pykolab.logger
-except ImportError, e:
+except ImportError as e:
print(_("Cannot load pykolab/logger.py:"), file=sys.stderr)
print("%s" % e, file=sys.stderr)
sys.exit(1)
diff --git a/cyruslib.py b/cyruslib.py
--- a/cyruslib.py
+++ b/cyruslib.py
@@ -384,7 +384,7 @@
res, msg = wrapped(*args)
if ok(res):
return res, msg
- except Exception, info:
+ except Exception as info:
error = str(info).split(':').pop().strip()
if error.upper().startswith('BAD'):
error = error.split('BAD', 1).pop().strip()
@@ -415,7 +415,7 @@
self.AUTH = True
self.id()
admin = self.m.isadmin()
- except Exception, info:
+ except Exception as info:
self.AUTH = False
error = str(info).split(':').pop().strip()
self.__doexception("LOGIN", error)
@@ -448,7 +448,7 @@
def logout(self):
try:
res, msg = self.m.logout()
- except Exception, info:
+ except Exception as info:
error = str(info).split(':').pop().strip()
self.__doexception("LOGOUT", error)
self.AUTH = False
@@ -577,7 +577,7 @@
try:
userid = self.encode(aclList[i])
rights = aclList[i + 1]
- except Exception, info:
+ except Exception as info:
self.__verbose( '[GETACL %s] BAD: %s' % (mailbox, info.args[0]) )
raise self.__doraise("GETACL")
self.__verbose( '[GETACL %s] %s %s' % (mailbox, userid, rights) )
@@ -637,7 +637,7 @@
self.__prepare('SETQUOTA', mailbox)
try:
limit = int(limit)
- except ValueError, e:
+ except ValueError:
self.__verbose( '[SETQUOTA %s] BAD: %s %s' % (mailbox, self.ERROR.get("SETQUOTA")[1], limit) )
raise self.__doraise("SETQUOTA")
res, msg = self.__docommand("setquota", self.decode(mailbox), limit)
@@ -694,16 +694,16 @@
try:
value_priv = _annot[(_annot.index('"value.priv"')+len('"value.priv"')):_annot.index('"size.priv"')].strip()
- except ValueError, errmsg:
+ except ValueError:
value_priv = None
try:
size_priv = _annot[(_annot.index('"size.priv"')+len('"size.priv"')):].strip().split('"')[1].strip()
try:
value_priv = value_priv[value_priv.index('{%s}' % (size_priv))+len('{%s}' % (size_priv)):].strip()
- except Exception, errmsg:
+ except Exception:
pass
- except Exception, errmsg:
+ except Exception:
pass
if value_priv in empty_values:
@@ -730,16 +730,16 @@
try:
value_shared = _annot[(_annot.index('"value.shared"')+len('"value.shared"')):_annot.index('"size.shared"')].strip()
- except ValueError, errmsg:
+ except ValueError:
value_shared = None
try:
size_shared = _annot[(_annot.index('"size.shared"')+len('"size.shared"')):].strip().split('"')[1].strip()
try:
value_shared = value_shared[value_shared.index('{%s}' % (size_shared))+len('{%s}' % (size_shared)):].strip()
- except Exception, errmsg:
+ except Exception:
pass
- except Exception, errmsg:
+ except Exception:
pass
if value_shared in empty_values:
diff --git a/ext/python/Tools/freeze/checkextensions_win32.py b/ext/python/Tools/freeze/checkextensions_win32.py
--- a/ext/python/Tools/freeze/checkextensions_win32.py
+++ b/ext/python/Tools/freeze/checkextensions_win32.py
@@ -131,7 +131,7 @@
dsp_path, dsp_name = os.path.split(dsp)
try:
lines = open(dsp, "r").readlines()
- except IOError, msg:
+ except IOError as msg:
sys.stderr.write("%s: %s\n" % (dsp, msg))
return None
for line in lines:
diff --git a/ext/python/Tools/freeze/freeze.py b/ext/python/Tools/freeze/freeze.py
--- a/ext/python/Tools/freeze/freeze.py
+++ b/ext/python/Tools/freeze/freeze.py
@@ -145,7 +145,7 @@
if sys.argv[pos] == '-i':
try:
options = open(sys.argv[pos+1]).read().split()
- except IOError, why:
+ except IOError as why:
usage("File name '%s' specified with the -i option "
"can not be read - %s" % (sys.argv[pos+1], why) )
# Replace the '-i' and the filename with the read params.
@@ -156,7 +156,7 @@
# Now parse the command line with the extras inserted.
try:
opts, args = getopt.getopt(sys.argv[1:], 'r:a:dEe:hmo:p:P:b:qs:wX:x:l:')
- except getopt.error, msg:
+ except getopt.error as msg:
usage('getopt error: ' + str(msg))
# process option arguments
@@ -339,7 +339,7 @@
try:
custom_entry_point, python_entry_is_main = \
winmakemakefile.get_custom_entry_point(subsystem)
- except ValueError, why:
+ except ValueError as why:
usage(why)
diff --git a/ext/python/Tools/freeze/winmakemakefile.py b/ext/python/Tools/freeze/winmakemakefile.py
--- a/ext/python/Tools/freeze/winmakemakefile.py
+++ b/ext/python/Tools/freeze/winmakemakefile.py
@@ -39,7 +39,7 @@
try:
return subsystem_details[subsystem][:2]
except KeyError:
- raise ValueError, "The subsystem %s is not known" % subsystem
+ raise ValueError("The subsystem %s is not known" % subsystem)
def makemakefile(outfp, vars, files, target):
diff --git a/kolab-cli.py b/kolab-cli.py
--- a/kolab-cli.py
+++ b/kolab-cli.py
@@ -32,7 +32,7 @@
try:
import pykolab.logger
-except ImportError, e:
+except ImportError as e:
print(_("Cannot load pykolab/logger.py:"), file=sys.stderr)
print("%s" % e, file=sys.stderr)
sys.exit(1)
diff --git a/pykolab/cli/cmd_add_domain.py b/pykolab/cli/cmd_add_domain.py
--- a/pykolab/cli/cmd_add_domain.py
+++ b/pykolab/cli/cmd_add_domain.py
@@ -63,7 +63,7 @@
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
--- a/pykolab/cli/cmd_add_user_subscription.py
+++ b/pykolab/cli/cmd_add_user_subscription.py
@@ -50,10 +50,10 @@
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
--- a/pykolab/cli/cmd_create_mailbox.py
+++ b/pykolab/cli/cmd_create_mailbox.py
@@ -56,7 +56,7 @@
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
--- a/pykolab/cli/cmd_delete_domain.py
+++ b/pykolab/cli/cmd_delete_domain.py
@@ -63,7 +63,7 @@
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
--- a/pykolab/cli/cmd_delete_mailbox.py
+++ b/pykolab/cli/cmd_delete_mailbox.py
@@ -67,6 +67,6 @@
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
--- a/pykolab/cli/cmd_delete_mailbox_acl.py
+++ b/pykolab/cli/cmd_delete_mailbox_acl.py
@@ -43,10 +43,10 @@
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
--- a/pykolab/cli/cmd_find_domain.py
+++ b/pykolab/cli/cmd_find_domain.py
@@ -52,7 +52,7 @@
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
--- a/pykolab/cli/cmd_list_mailbox_acls.py
+++ b/pykolab/cli/cmd_list_mailbox_acls.py
@@ -41,7 +41,7 @@
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
--- a/pykolab/cli/cmd_list_mailbox_metadata.py
+++ b/pykolab/cli/cmd_list_mailbox_metadata.py
@@ -52,7 +52,7 @@
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
--- a/pykolab/cli/cmd_list_quota.py
+++ b/pykolab/cli/cmd_list_quota.py
@@ -53,7 +53,7 @@
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
--- a/pykolab/cli/cmd_list_user_subscriptions.py
+++ b/pykolab/cli/cmd_list_user_subscriptions.py
@@ -56,10 +56,10 @@
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
--- a/pykolab/cli/cmd_remove_mailaddress.py
+++ b/pykolab/cli/cmd_remove_mailaddress.py
@@ -41,7 +41,7 @@
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
--- a/pykolab/cli/cmd_remove_user_subscription.py
+++ b/pykolab/cli/cmd_remove_user_subscription.py
@@ -50,10 +50,10 @@
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
--- a/pykolab/cli/cmd_rename_mailbox.py
+++ b/pykolab/cli/cmd_rename_mailbox.py
@@ -48,11 +48,11 @@
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
--- a/pykolab/cli/cmd_set_mailbox_acl.py
+++ b/pykolab/cli/cmd_set_mailbox_acl.py
@@ -45,14 +45,14 @@
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
--- a/pykolab/cli/cmd_set_mailbox_metadata.py
+++ b/pykolab/cli/cmd_set_mailbox_metadata.py
@@ -57,14 +57,14 @@
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
--- a/pykolab/cli/cmd_set_quota.py
+++ b/pykolab/cli/cmd_set_quota.py
@@ -43,10 +43,10 @@
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
--- a/pykolab/cli/cmd_sync_mailhost_attrs.py
+++ b/pykolab/cli/cmd_sync_mailhost_attrs.py
@@ -113,7 +113,7 @@
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 @@
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
--- a/pykolab/cli/cmd_user_info.py
+++ b/pykolab/cli/cmd_user_info.py
@@ -39,7 +39,7 @@
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
--- a/pykolab/cli/commands.py
+++ b/pykolab/cli/commands.py
@@ -45,7 +45,7 @@
#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 @@
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 @@
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
--- a/pykolab/conf/entitlement.py
+++ b/pykolab/conf/entitlement.py
@@ -54,8 +54,8 @@
)
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 @@
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 @@
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 @@
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 @@
).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 @@
).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 @@
).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
--- a/pykolab/imap/cyrus.py
+++ b/pykolab/imap/cyrus.py
@@ -148,15 +148,15 @@
"""
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 @@
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
--- a/pykolab/imap_utf7.py
+++ b/pykolab/imap_utf7.py
@@ -31,7 +31,7 @@
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
--- a/pykolab/plugins/__init__.py
+++ b/pykolab/plugins/__init__.py
@@ -67,15 +67,15 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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
--- a/pykolab/plugins/defaultfolders/__init__.py
+++ b/pykolab/plugins/defaultfolders/__init__.py
@@ -49,7 +49,7 @@
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
--- a/pykolab/plugins/recipientpolicy/__init__.py
+++ b/pykolab/plugins/recipientpolicy/__init__.py
@@ -75,7 +75,7 @@
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 @@
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 @@
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 @@
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 @@
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
--- a/pykolab/setup/components.py
+++ b/pykolab/setup/components.py
@@ -130,14 +130,14 @@
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
--- a/pykolab/telemetry.py
+++ b/pykolab/telemetry.py
@@ -642,7 +642,7 @@
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
--- a/pykolab/wap_client/__init__.py
+++ b/pykolab/wap_client/__init__.py
@@ -436,7 +436,7 @@
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
--- a/pykolab/xml/attendee.py
+++ b/pykolab/xml/attendee.py
@@ -132,14 +132,14 @@
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 @@
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 @@
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 @@
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 @@
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
--- a/pykolab/xml/contact.py
+++ b/pykolab/xml/contact.py
@@ -328,7 +328,7 @@
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
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -166,7 +166,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
_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 @@
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 @@
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 @@
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 @@
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
--- a/pykolab/xml/note.py
+++ b/pykolab/xml/note.py
@@ -91,7 +91,7 @@
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 @@
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
--- a/pykolab/xml/todo.py
+++ b/pykolab/xml/todo.py
@@ -162,7 +162,7 @@
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 @@
if error == None or not error:
return xml
else:
- raise TodoIntegrityError, kolabformat.errorMessage()
+ raise TodoIntegrityError(kolabformat.errorMessage())
class TodoIntegrityError(Exception):
diff --git a/saslauthd/__init__.py b/saslauthd/__init__.py
--- a/saslauthd/__init__.py
+++ b/saslauthd/__init__.py
@@ -106,7 +106,7 @@
conf.process_username,
conf.process_groupname
)
- except Exception, errmsg:
+ except Exception as errmsg:
log.error(_("Could not create %r: %r") % (os.path.dirname(conf.pidfile), errmsg))
sys.exit(1)
@@ -162,18 +162,18 @@
self.write_pid()
self.do_saslauthd()
- except SystemExit, e:
+ except SystemExit as e:
exitcode = e
except KeyboardInterrupt:
exitcode = 1
log.info(_("Interrupted by user"))
- except AttributeError, e:
+ except AttributeError:
exitcode = 1
traceback.print_exc()
print(_("Traceback occurred, please report a " +
"bug at https://issues.kolab.org"),
file=sys.stderr)
- except TypeError, e:
+ except TypeError as e:
exitcode = 1
traceback.print_exc()
log.error(_("Type Error: %s") % e)
@@ -220,7 +220,7 @@
try:
(clientsocket, address) = s.accept()
bound = True
- except Exception, errmsg:
+ except Exception as errmsg:
log.error(
_("kolab-saslauthd could not accept " +
"connections on socket: %r") % (errmsg)
@@ -312,7 +312,7 @@
try:
(ruid, euid, suid) = os.getresuid()
(rgid, egid, sgid) = os.getresgid()
- except AttributeError, errmsg:
+ except AttributeError:
ruid = os.getuid()
rgid = os.getgid()
diff --git a/setup-kolab.py b/setup-kolab.py
--- a/setup-kolab.py
+++ b/setup-kolab.py
@@ -35,7 +35,7 @@
try:
from pykolab.constants import *
-except ImportError, e:
+except ImportError as e:
print(_("Cannot load pykolab/constants.py:"), file=sys.stderr)
print("%s" % e, file=sys.stderr)
sys.exit(1)
diff --git a/wallace.py b/wallace.py
--- a/wallace.py
+++ b/wallace.py
@@ -29,7 +29,7 @@
try:
from pykolab.constants import *
-except ImportError, e:
+except ImportError as e:
print(_("Cannot load pykolab/constants.py:"), file=sys.stderr)
print("%s" % e, file=sys.stderr)
sys.exit(1)
diff --git a/wallace/module_gpgencrypt.py b/wallace/module_gpgencrypt.py
--- a/wallace/module_gpgencrypt.py
+++ b/wallace/module_gpgencrypt.py
@@ -286,7 +286,7 @@
os.unlink(filepath)
exec('modules.cb_action_%s(%r, %r)' % ('ACCEPT','gpgencrypt', new_filepath))
- except Exception, errmsg:
+ except Exception as errmsg:
log.error(_("An error occurred: %r") % (errmsg))
if conf.debuglevel > 8:
import traceback
diff --git a/wallace/module_invitationpolicy.py b/wallace/module_invitationpolicy.py
--- a/wallace/module_invitationpolicy.py
+++ b/wallace/module_invitationpolicy.py
@@ -280,7 +280,7 @@
# is an iTip message by checking the length of this list.
try:
itip_events = objects_from_message(message, ['VEVENT','VTODO'], ['REQUEST', 'REPLY', 'CANCEL'])
- except Exception, errmsg:
+ except Exception as errmsg:
log.error(_("Failed to parse iTip objects from message: %r" % (errmsg)))
itip_events = []
@@ -413,7 +413,7 @@
try:
receiving_attendee = itip_event['xml'].get_attendee_by_email(recipient_email)
log.debug(_("Receiving attendee: %r") % (receiving_attendee.to_dict()), level=8)
- except Exception, errmsg:
+ except Exception as errmsg:
log.error("Could not find envelope attendee: %r" % (errmsg))
return MESSAGE_FORWARD
@@ -542,7 +542,7 @@
try:
sender_attendee = itip_event['xml'].get_attendee_by_email(sender_email)
log.debug(_("Sender Attendee: %r") % (sender_attendee), level=8)
- except Exception, errmsg:
+ except Exception as errmsg:
log.error("Could not find envelope sender attendee: %r" % (errmsg))
return MESSAGE_FORWARD
@@ -565,7 +565,7 @@
existing.set_attendee_participant_status(sender_email, sender_attendee.get_participant_status(), rsvp=False)
existing_attendee = existing.get_attendee(sender_email)
updated_attendees.append(existing_attendee)
- except Exception, errmsg:
+ except Exception as errmsg:
log.error("Could not find corresponding attende in organizer's copy: %r" % (errmsg))
# append delegated-from attendee ?
@@ -598,7 +598,7 @@
existing.update_attendees([existing_attendee])
log.debug(_("Update delegator: %r") % (existing_attendee.to_dict()), level=8)
- except Exception, errmsg:
+ except Exception as errmsg:
log.error("Could not find delegated-to attendee: %r" % (errmsg))
# update the organizer's copy of the object
@@ -780,7 +780,7 @@
imap.disconnect()
imap.connect(login=False)
imap.login_plain(admin_login, admin_password, user_rec[mail_attribute])
- except Exception, errmsg:
+ except Exception as errmsg:
log.error(_("IMAP proxy authentication failed: %r") % (errmsg))
return False
@@ -910,7 +910,7 @@
try:
msguid = re.search(r"\WUID (\d+)", data[0][0]).group(1)
- except Exception, errmsg:
+ except Exception:
log.error(_("No UID found in IMAP response: %r") % (data[0][0]))
continue
@@ -936,7 +936,7 @@
setattr(event, '_lock_key', lock_key)
setattr(event, '_msguid', msguid)
- except Exception, errmsg:
+ except Exception:
log.error(_("Failed to parse %s from message %s/%s: %s") % (type, folder, num, traceback.format_exc()))
event = None
master = None
@@ -977,7 +977,7 @@
try:
event = event_from_message(message_from_string(data[0][1]))
- except Exception, errmsg:
+ except Exception as errmsg:
log.error(_("Failed to parse event from message %s/%s: %r") % (folder, num, errmsg))
continue
@@ -1122,7 +1122,7 @@
)
return result
- except Exception, errmsg:
+ except Exception as errmsg:
log.error(_("Failed to save %s to user folder at %r: %r") % (
saveobj.type, targetfolder, errmsg
))
@@ -1160,7 +1160,7 @@
imap.imap.m.expunge()
return True
- except Exception, errmsg:
+ except Exception as errmsg:
log.error(_("Failed to delete %s from folder %r: %r") % (
existing.type, targetfolder, errmsg
))
diff --git a/wallace/module_optout.py b/wallace/module_optout.py
--- a/wallace/module_optout.py
+++ b/wallace/module_optout.py
@@ -177,7 +177,7 @@
try:
f = urllib.urlopen(optout_url, params)
- except Exception, e:
+ except Exception:
log.error(_("Could not send request to optout_url %s") % (optout_url))
return "DEFER"
@@ -185,7 +185,7 @@
try:
response_data = json.loads(response)
- except ValueError, e:
+ except ValueError:
# Some data is not JSON
print("Response data is not JSON")
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 5, 11:44 PM (19 h, 8 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18834966
Default Alt Text
D3232.1775432640.diff (49 KB)
Attached To
Mode
D3232: [Python 3] Use new exception syntax
Attached
Detach File
Event Timeline