diff options
46 files changed, 145 insertions, 145 deletions
@@ -34,7 +34,7 @@ from pykolab.translate import _ 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 index 0edbfdb..5c2ff1f 100644 --- a/cyruslib.py +++ b/cyruslib.py @@ -384,7 +384,7 @@ class CYRUS: 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 @@ class CYRUS: 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 @@ class CYRUS: 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 @@ class CYRUS: 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 @@ class CYRUS: 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 @@ class CYRUS: 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 @@ class CYRUS: 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 index a198ecf..ba3853c 100644 --- a/ext/python/Tools/freeze/checkextensions_win32.py +++ b/ext/python/Tools/freeze/checkextensions_win32.py @@ -131,7 +131,7 @@ def parse_dsp(dsp): 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 index daa345b..a7906b1 100755 --- a/ext/python/Tools/freeze/freeze.py +++ b/ext/python/Tools/freeze/freeze.py @@ -145,7 +145,7 @@ def main(): 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 @@ def main(): # 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 @@ def main(): 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 index e473fed..7d198c1 100644 --- a/ext/python/Tools/freeze/winmakemakefile.py +++ b/ext/python/Tools/freeze/winmakemakefile.py @@ -39,7 +39,7 @@ def get_custom_entry_point(subsystem): 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 index d97d715..37ea08e 100755 --- a/kolab-cli.py +++ b/kolab-cli.py @@ -32,7 +32,7 @@ from pykolab.cli import Cli 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 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): diff --git a/saslauthd/__init__.py b/saslauthd/__init__.py index 6d89929..d2459ad 100644 --- a/saslauthd/__init__.py +++ b/saslauthd/__init__.py @@ -106,7 +106,7 @@ class SASLAuthDaemon(object): 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 @@ class SASLAuthDaemon(object): 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 @@ class SASLAuthDaemon(object): 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 @@ class SASLAuthDaemon(object): 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 index ef6fcb7..12b5d1c 100755 --- a/setup-kolab.py +++ b/setup-kolab.py @@ -35,7 +35,7 @@ from pykolab.translate import _ 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) @@ -29,7 +29,7 @@ from pykolab.translate import _ 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 index e623fe1..100d1d1 100644 --- a/wallace/module_gpgencrypt.py +++ b/wallace/module_gpgencrypt.py @@ -286,7 +286,7 @@ def execute(*args, **kw): 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 index 46e506d..72295a7 100644 --- a/wallace/module_invitationpolicy.py +++ b/wallace/module_invitationpolicy.py @@ -280,7 +280,7 @@ def execute(*args, **kw): # 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 @@ def process_itip_request(itip_event, policy, recipient_email, sender_email, rece 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 @@ def process_itip_reply(itip_event, policy, recipient_email, sender_email, receiv 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 @@ def process_itip_reply(itip_event, policy, recipient_email, sender_email, receiv 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 @@ def process_itip_reply(itip_event, policy, recipient_email, sender_email, receiv 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 @@ def imap_proxy_auth(user_rec): 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 @@ def find_existing_object(uid, type, recurrence_id, user_rec, lock=False): 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 @@ def find_existing_object(uid, type, recurrence_id, user_rec, lock=False): 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 @@ def check_availability(itip_event, receiving_user): 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 @@ def store_object(object, user_rec, targetfolder=None, master=None): ) 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 @@ def delete_object(existing): 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 index 2b9d4b2..4fd199f 100644 --- a/wallace/module_optout.py +++ b/wallace/module_optout.py @@ -177,7 +177,7 @@ def request(params=None): 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 @@ def request(params=None): try: response_data = json.loads(response) - except ValueError, e: + except ValueError: # Some data is not JSON print("Response data is not JSON") |