diff options
-rw-r--r-- | openstack/common/cfgfilter.py | 6 | ||||
-rw-r--r-- | openstack/common/db/sqlalchemy/session.py | 12 | ||||
-rw-r--r-- | openstack/common/exception.py | 2 | ||||
-rw-r--r-- | openstack/common/lockutils.py | 2 | ||||
-rw-r--r-- | openstack/common/log.py | 2 | ||||
-rw-r--r-- | openstack/common/loopingcall.py | 4 | ||||
-rw-r--r-- | openstack/common/plugin/pluginmanager.py | 2 | ||||
-rwxr-xr-x | openstack/common/rootwrap/cmd.py | 2 | ||||
-rw-r--r-- | openstack/common/rpc/common.py | 4 | ||||
-rw-r--r-- | openstack/common/rpc/impl_kombu.py | 8 | ||||
-rw-r--r-- | openstack/common/rpc/impl_qpid.py | 2 | ||||
-rw-r--r-- | openstack/common/rpc/impl_zmq.py | 2 | ||||
-rw-r--r-- | openstack/common/wsgi.py | 2 | ||||
-rw-r--r-- | tests/unit/rpc/test_common.py | 4 | ||||
-rw-r--r-- | tests/unit/test_excutils.py | 4 | ||||
-rw-r--r-- | tests/unit/test_processutils.py | 2 | ||||
-rw-r--r-- | tests/unit/test_service.py | 2 |
17 files changed, 31 insertions, 31 deletions
diff --git a/openstack/common/cfgfilter.py b/openstack/common/cfgfilter.py index f7b978b..29aeac2 100644 --- a/openstack/common/cfgfilter.py +++ b/openstack/common/cfgfilter.py @@ -24,7 +24,7 @@ For example, if module 'foo' registers the 'blaa' option and the module import foo - print CONF.blaa + print(CONF.blaa) However, it's completely non-obvious why foo is being imported (is it unused, can we remove the import) and where the 'blaa' option comes from. @@ -33,7 +33,7 @@ The CONF.import_opt() method allows such a dependency to be explicitly declared: CONF.import_opt('blaa', 'foo') - print CONF.blaa + print(CONF.blaa) However, import_opt() has a weakness - if 'bar' imports 'foo' using the import builtin and doesn't use import_opt() to import 'blaa', then 'blaa' @@ -47,7 +47,7 @@ import_opt() e.g. with: CONF = ConfigFilter(cfg.CONF) CONF.import_opt('blaa', 'foo') - print CONF.blaa + print(CONF.blaa) no other options other than 'blaa' are available via CONF. """ diff --git a/openstack/common/db/sqlalchemy/session.py b/openstack/common/db/sqlalchemy/session.py index 77a1dc8..c719063 100644 --- a/openstack/common/db/sqlalchemy/session.py +++ b/openstack/common/db/sqlalchemy/session.py @@ -419,12 +419,12 @@ def _wrap_db_error(f): # note(boris-42): We should catch unique constraint violation and # wrap it by our own DBDuplicateEntry exception. Unique constraint # violation is wrapped by IntegrityError. - except sqla_exc.OperationalError, e: + except sqla_exc.OperationalError as e: _raise_if_deadlock_error(e, get_engine().name) # NOTE(comstud): A lot of code is checking for OperationalError # so let's not wrap it for now. raise - except sqla_exc.IntegrityError, e: + except sqla_exc.IntegrityError as e: # note(boris-42): SqlAlchemy doesn't unify errors from different # DBs so we must do this. Also in some tables (for example # instance_types) there are more than one unique constraint. This @@ -432,7 +432,7 @@ def _wrap_db_error(f): # unique constraint, from error message. _raise_if_duplicate_entry_error(e, get_engine().name) raise exception.DBError(e) - except Exception, e: + except Exception as e: LOG.exception(_('DB exception wrapped.')) raise exception.DBError(e) _wrap.func_name = f.func_name @@ -481,7 +481,7 @@ def _ping_listener(dbapi_conn, connection_rec, connection_proxy): """ try: dbapi_conn.cursor().execute('select 1') - except dbapi_conn.OperationalError, ex: + except dbapi_conn.OperationalError as ex: if ex.args[0] in (2006, 2013, 2014, 2045, 2055): LOG.warn(_('Got mysql server has gone away: %s'), ex) raise sqla_exc.DisconnectionError("Database server went away") @@ -545,7 +545,7 @@ def create_engine(sql_connection): try: engine.connect() - except sqla_exc.OperationalError, e: + except sqla_exc.OperationalError as e: if not _is_db_connection_error(e.args[0]): raise @@ -561,7 +561,7 @@ def create_engine(sql_connection): try: engine.connect() break - except sqla_exc.OperationalError, e: + except sqla_exc.OperationalError as e: if (remaining != 'infinite' and remaining == 0) or \ not _is_db_connection_error(e.args[0]): raise diff --git a/openstack/common/exception.py b/openstack/common/exception.py index 5d0998c..a645588 100644 --- a/openstack/common/exception.py +++ b/openstack/common/exception.py @@ -98,7 +98,7 @@ def wrap_exception(f): def _wrap(*args, **kw): try: return f(*args, **kw) - except Exception, e: + except Exception as e: if not isinstance(e, Error): #exc_type, exc_value, exc_traceback = sys.exc_info() logging.exception(_('Uncaught exception')) diff --git a/openstack/common/lockutils.py b/openstack/common/lockutils.py index ef42b9b..892d821 100644 --- a/openstack/common/lockutils.py +++ b/openstack/common/lockutils.py @@ -82,7 +82,7 @@ class _InterProcessLock(object): # to have a laughable 10 attempts "blocking" mechanism. self.trylock() return self - except IOError, e: + except IOError as e: if e.errno in (errno.EACCES, errno.EAGAIN): # external locks synchronise things like iptables # updates - give it some time to prevent busy spinning diff --git a/openstack/common/log.py b/openstack/common/log.py index be30e9f..fe25c76 100644 --- a/openstack/common/log.py +++ b/openstack/common/log.py @@ -340,7 +340,7 @@ class LogConfigError(Exception): def _load_log_config(log_config): try: logging.config.fileConfig(log_config) - except ConfigParser.Error, exc: + except ConfigParser.Error as exc: raise LogConfigError(log_config, str(exc)) diff --git a/openstack/common/loopingcall.py b/openstack/common/loopingcall.py index 3704e8e..1688432 100644 --- a/openstack/common/loopingcall.py +++ b/openstack/common/loopingcall.py @@ -84,7 +84,7 @@ class FixedIntervalLoopingCall(LoopingCallBase): LOG.warn(_('task run outlasted interval by %s sec') % -delay) greenthread.sleep(delay if delay > 0 else 0) - except LoopingCallDone, e: + except LoopingCallDone as e: self.stop() done.send(e.retvalue) except Exception: @@ -131,7 +131,7 @@ class DynamicLoopingCall(LoopingCallBase): LOG.debug(_('Dynamic looping call sleeping for %.02f ' 'seconds'), idle) greenthread.sleep(idle) - except LoopingCallDone, e: + except LoopingCallDone as e: self.stop() done.send(e.retvalue) except Exception: diff --git a/openstack/common/plugin/pluginmanager.py b/openstack/common/plugin/pluginmanager.py index c958204..56064dd 100644 --- a/openstack/common/plugin/pluginmanager.py +++ b/openstack/common/plugin/pluginmanager.py @@ -62,7 +62,7 @@ class PluginManager(object): pluginclass = entrypoint.load() plugin = pluginclass(self._service_name) self.plugins.append(plugin) - except Exception, exc: + except Exception as exc: LOG.error(_("Failed to load plugin %(plug)s: %(exc)s") % {'plug': entrypoint, 'exc': exc}) diff --git a/openstack/common/rootwrap/cmd.py b/openstack/common/rootwrap/cmd.py index 23986ac..f17f50a 100755 --- a/openstack/common/rootwrap/cmd.py +++ b/openstack/common/rootwrap/cmd.py @@ -58,7 +58,7 @@ def _subprocess_setup(): def _exit_error(execname, message, errorcode, log=True): - print "%s: %s" % (execname, message) + print("%s: %s" % (execname, message)) if log: LOG.error(message) sys.exit(errorcode) diff --git a/openstack/common/rpc/common.py b/openstack/common/rpc/common.py index 6fb39e1..2bc7c61 100644 --- a/openstack/common/rpc/common.py +++ b/openstack/common/rpc/common.py @@ -276,7 +276,7 @@ def _safe_log(log_func, msg, msg_data): for elem in arg[:-1]: d = d[elem] d[arg[-1]] = '<SANITIZED>' - except KeyError, e: + except KeyError as e: LOG.info(_('Failed to sanitize %(item)s. Key error %(err)s'), {'item': arg, 'err': e}) @@ -419,7 +419,7 @@ class ClientException(Exception): def catch_client_exception(exceptions, func, *args, **kwargs): try: return func(*args, **kwargs) - except Exception, e: + except Exception as e: if type(e) in exceptions: raise ClientException() else: diff --git a/openstack/common/rpc/impl_kombu.py b/openstack/common/rpc/impl_kombu.py index 18cb0d0..0648e4b 100644 --- a/openstack/common/rpc/impl_kombu.py +++ b/openstack/common/rpc/impl_kombu.py @@ -176,7 +176,7 @@ class ConsumerBase(object): """Cancel the consuming from the queue, if it has started""" try: self.queue.cancel(self.tag) - except KeyError, e: + except KeyError as e: # NOTE(comstud): Kludge to get around a amqplib bug if str(e) != "u'%s'" % self.tag: raise @@ -520,7 +520,7 @@ class Connection(object): return except (IOError, self.connection_errors) as e: pass - except Exception, e: + except Exception as e: # NOTE(comstud): Unfortunately it's possible for amqplib # to return an error not covered by its transport # connection_errors in the case of a timeout waiting for @@ -561,10 +561,10 @@ class Connection(object): while True: try: return method(*args, **kwargs) - except (self.connection_errors, socket.timeout, IOError), e: + except (self.connection_errors, socket.timeout, IOError) as e: if error_callback: error_callback(e) - except Exception, e: + except Exception as e: # NOTE(comstud): Unfortunately it's possible for amqplib # to return an error not covered by its transport # connection_errors in the case of a timeout waiting for diff --git a/openstack/common/rpc/impl_qpid.py b/openstack/common/rpc/impl_qpid.py index f49451f..8e1e450 100644 --- a/openstack/common/rpc/impl_qpid.py +++ b/openstack/common/rpc/impl_qpid.py @@ -346,7 +346,7 @@ class Connection(object): try: self.connection_create(broker) self.connection.open() - except qpid_exceptions.ConnectionError, e: + except qpid_exceptions.ConnectionError as e: msg_dict = dict(e=e, delay=delay) msg = _("Unable to connect to AMQP server: %(e)s. " "Sleeping %(delay)s seconds") % msg_dict diff --git a/openstack/common/rpc/impl_zmq.py b/openstack/common/rpc/impl_zmq.py index fe880c0..7a5d814 100644 --- a/openstack/common/rpc/impl_zmq.py +++ b/openstack/common/rpc/impl_zmq.py @@ -282,7 +282,7 @@ class InternalContext(object): except greenlet.GreenletExit: # ignore these since they are just from shutdowns pass - except rpc_common.ClientException, e: + except rpc_common.ClientException as e: LOG.debug(_("Expected exception during message handling (%s)") % e._exc_info[1]) return {'exc': diff --git a/openstack/common/wsgi.py b/openstack/common/wsgi.py index 47f97a2..43e55be 100644 --- a/openstack/common/wsgi.py +++ b/openstack/common/wsgi.py @@ -102,7 +102,7 @@ class Service(service.Service): if sslutils.is_enabled(): sock = sslutils.wrap(sock) - except socket.error, err: + except socket.error as err: if err.args[0] != errno.EADDRINUSE: raise eventlet.sleep(0.1) diff --git a/tests/unit/rpc/test_common.py b/tests/unit/rpc/test_common.py index 755e2a4..2248a8f 100644 --- a/tests/unit/rpc/test_common.py +++ b/tests/unit/rpc/test_common.py @@ -213,7 +213,7 @@ class RpcCommonTestCase(test_utils.BaseTestCase): raise ValueError() except Exception: raise rpc_common.ClientException() - except rpc_common.ClientException, e: + except rpc_common.ClientException as e: pass self.assertTrue(isinstance(e, rpc_common.ClientException)) @@ -226,7 +226,7 @@ class RpcCommonTestCase(test_utils.BaseTestCase): e = None try: rpc_common.catch_client_exception([ValueError], naughty, 'a') - except rpc_common.ClientException, e: + except rpc_common.ClientException as e: pass self.assertTrue(isinstance(e, rpc_common.ClientException)) diff --git a/tests/unit/test_excutils.py b/tests/unit/test_excutils.py index d3eeb8c..9d9050e 100644 --- a/tests/unit/test_excutils.py +++ b/tests/unit/test_excutils.py @@ -29,7 +29,7 @@ class SaveAndReraiseTest(utils.BaseTestCase): except: with excutils.save_and_reraise_exception(): pass - except Exception, _e: + except Exception as _e: e = _e self.assertEqual(str(e), msg) @@ -43,7 +43,7 @@ class SaveAndReraiseTest(utils.BaseTestCase): except: with excutils.save_and_reraise_exception(): raise Exception(msg) - except Exception, _e: + except Exception as _e: e = _e self.assertEqual(str(e), msg) diff --git a/tests/unit/test_processutils.py b/tests/unit/test_processutils.py index 689bad0..f096cf7 100644 --- a/tests/unit/test_processutils.py +++ b/tests/unit/test_processutils.py @@ -72,7 +72,7 @@ class ProcessExecutionErrorTest(utils.BaseTestCase): the Wielder of Wonder, with world's renown. """.strip() err = processutils.ProcessExecutionError(stdout=stdout) - print err.message + print(err.message) self.assertTrue('people-kings' in err.message) def test_with_stderr(self): diff --git a/tests/unit/test_service.py b/tests/unit/test_service.py index af6c303..53b7eb4 100644 --- a/tests/unit/test_service.py +++ b/tests/unit/test_service.py @@ -87,7 +87,7 @@ class ServiceLauncherTest(utils.BaseTestCase): try: traceback.print_exc() except BaseException: - print "Couldn't print traceback" + print("Couldn't print traceback") status = 2 # Really exit |