summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2012-11-21 10:53:18 -0800
committerMark McLoughlin <markmc@redhat.com>2012-11-28 17:05:36 +0000
commitcf705c59615fb68cdbfe664e7827e4a275a4a282 (patch)
treef7d8a2f674acb0d4df9339f77f3511a123f7a525
parentf10b956dd5b88b048c582cadc3c22ec5360521c9 (diff)
downloadoslo-cf705c59615fb68cdbfe664e7827e4a275a4a282.tar.gz
oslo-cf705c59615fb68cdbfe664e7827e4a275a4a282.tar.xz
oslo-cf705c59615fb68cdbfe664e7827e4a275a4a282.zip
Make project pyflakes clean.
Added both a tox test-env for pyflakes and fixed the current pyflakes errors. This did actually fix a couple of bugs. The CI team has started using pyflakes on its projects and also has started using oslo for things, so ignoring pyflakes warnings on the oslo code was starting to get old. However, additionally, pyflakes is pretty solid, so we should maybe consider gating on it across the board. (% locals() is the biggest thing that we do that it doesn't like) Change-Id: Iac1ca62db301892b7863711162fcbc74807eb24f
-rw-r--r--openstack/common/eventlet_backdoor.py2
-rw-r--r--openstack/common/importutils.py2
-rw-r--r--openstack/common/jsonutils.py2
-rw-r--r--openstack/common/lockutils.py1
-rw-r--r--openstack/common/notifier/api.py7
-rw-r--r--openstack/common/notifier/rpc_notifier.py2
-rw-r--r--openstack/common/periodic_task.py12
-rw-r--r--openstack/common/plugin/pluginmanager.py1
-rw-r--r--openstack/common/rpc/amqp.py7
-rw-r--r--openstack/common/rpc/common.py4
-rw-r--r--openstack/common/rpc/matchmaker.py2
-rw-r--r--openstack/common/service.py7
-rw-r--r--openstack/common/threadgroup.py1
-rw-r--r--openstack/common/utils.py9
-rw-r--r--tox.ini4
-rw-r--r--update.py1
16 files changed, 34 insertions, 30 deletions
diff --git a/openstack/common/eventlet_backdoor.py b/openstack/common/eventlet_backdoor.py
index b28a2c6..035d282 100644
--- a/openstack/common/eventlet_backdoor.py
+++ b/openstack/common/eventlet_backdoor.py
@@ -46,7 +46,7 @@ def _find_objects(t):
def _print_greenthreads():
- for i, gt in enumerate(find_objects(greenlet.greenlet)):
+ for i, gt in enumerate(_find_objects(greenlet.greenlet)):
print i, gt
traceback.print_stack(gt.gr_frame)
print
diff --git a/openstack/common/importutils.py b/openstack/common/importutils.py
index f45372b..2a28b45 100644
--- a/openstack/common/importutils.py
+++ b/openstack/common/importutils.py
@@ -29,7 +29,7 @@ def import_class(import_str):
try:
__import__(mod_str)
return getattr(sys.modules[mod_str], class_str)
- except (ValueError, AttributeError), exc:
+ except (ValueError, AttributeError):
raise ImportError('Class %s cannot be found (%s)' %
(class_str,
traceback.format_exception(*sys.exc_info())))
diff --git a/openstack/common/jsonutils.py b/openstack/common/jsonutils.py
index f96e727..efc8324 100644
--- a/openstack/common/jsonutils.py
+++ b/openstack/common/jsonutils.py
@@ -120,7 +120,7 @@ def to_primitive(value, convert_instances=False, level=0):
level=level + 1)
else:
return value
- except TypeError, e:
+ except TypeError:
# Class objects are tricky since they may define something like
# __iter__ defined but it isn't callable as list().
return unicode(value)
diff --git a/openstack/common/lockutils.py b/openstack/common/lockutils.py
index d98ce8b..a342938 100644
--- a/openstack/common/lockutils.py
+++ b/openstack/common/lockutils.py
@@ -27,6 +27,7 @@ import weakref
from eventlet import semaphore
from openstack.common import cfg
+from openstack.common.gettextutils import _
from openstack.common import fileutils
from openstack.common import log as logging
diff --git a/openstack/common/notifier/api.py b/openstack/common/notifier/api.py
index 470eacb..5714306 100644
--- a/openstack/common/notifier/api.py
+++ b/openstack/common/notifier/api.py
@@ -137,10 +137,11 @@ def notify(context, publisher_id, event_type, priority, payload):
for driver in _get_drivers():
try:
driver.notify(context, msg)
- except Exception, e:
+ except Exception as e:
LOG.exception(_("Problem '%(e)s' attempting to "
"send to notification system. "
- "Payload=%(payload)s") % locals())
+ "Payload=%(payload)s")
+ % dict(e=e, payload=payload))
_drivers = None
@@ -166,7 +167,7 @@ def add_driver(notification_driver):
try:
driver = importutils.import_module(notification_driver)
_drivers[notification_driver] = driver
- except ImportError as e:
+ except ImportError:
LOG.exception(_("Failed to load notifier %s. "
"These notifications will not be sent.") %
notification_driver)
diff --git a/openstack/common/notifier/rpc_notifier.py b/openstack/common/notifier/rpc_notifier.py
index 604af86..7e25f47 100644
--- a/openstack/common/notifier/rpc_notifier.py
+++ b/openstack/common/notifier/rpc_notifier.py
@@ -41,6 +41,6 @@ def notify(context, message):
topic = '%s.%s' % (topic, priority)
try:
rpc.notify(context, topic, message)
- except Exception, e:
+ except Exception:
LOG.exception(_("Could not send notification to %(topic)s. "
"Payload=%(message)s"), locals())
diff --git a/openstack/common/periodic_task.py b/openstack/common/periodic_task.py
index 8a32162..28ab22e 100644
--- a/openstack/common/periodic_task.py
+++ b/openstack/common/periodic_task.py
@@ -95,17 +95,21 @@ class PeriodicTasks(object):
ticks_to_skip = self._ticks_to_skip[task_name]
if ticks_to_skip > 0:
LOG.debug(_("Skipping %(full_task_name)s, %(ticks_to_skip)s"
- " ticks left until next run"), locals())
+ " ticks left until next run"),
+ dict(full_task_name=full_task_name,
+ ticks_to_skip=ticks_to_skip))
self._ticks_to_skip[task_name] -= 1
continue
self._ticks_to_skip[task_name] = task._ticks_between_runs
- LOG.debug(_("Running periodic task %(full_task_name)s"), locals())
+ LOG.debug(_("Running periodic task %(full_task_name)s"),
+ dict(full_task_name=full_task_name))
try:
task(self, context)
except Exception as e:
if raise_on_error:
raise
- LOG.exception(_("Error during %(full_task_name)s: %(e)s"),
- locals())
+ LOG.exception(_("Error during %(full_task_name)s:"
+ " %(e)s"),
+ dict(e=e, full_task_name=full_task_name))
diff --git a/openstack/common/plugin/pluginmanager.py b/openstack/common/plugin/pluginmanager.py
index 38e05ae..f7891cd 100644
--- a/openstack/common/plugin/pluginmanager.py
+++ b/openstack/common/plugin/pluginmanager.py
@@ -16,6 +16,7 @@
import pkg_resources
from openstack.common import cfg
+from openstack.common.gettextutils import _
from openstack.common import log as logging
from openstack.common.notifier import api as notifier_api
diff --git a/openstack/common/rpc/amqp.py b/openstack/common/rpc/amqp.py
index a3e567f..2ea506a 100644
--- a/openstack/common/rpc/amqp.py
+++ b/openstack/common/rpc/amqp.py
@@ -282,7 +282,7 @@ class ProxyCallback(object):
ctxt.reply(rval, None, connection_pool=self.connection_pool)
# This final None tells multicall that it is done.
ctxt.reply(ending=True, connection_pool=self.connection_pool)
- except Exception as e:
+ except Exception:
LOG.exception('Exception during message handling')
ctxt.reply(None, sys.exc_info(),
connection_pool=self.connection_pool)
@@ -407,8 +407,9 @@ def fanout_cast_to_server(conf, context, server_params, topic, msg,
def notify(conf, context, topic, msg, connection_pool):
"""Sends a notification event on a topic."""
- event_type = msg.get('event_type')
- LOG.debug(_('Sending %(event_type)s on %(topic)s'), locals())
+ LOG.debug(_('Sending %(event_type)s on %(topic)s'),
+ dict(event_type=msg.get('event_type'),
+ topic=topic))
pack_context(msg, context)
with ConnectionContext(conf, connection_pool) as conn:
conn.notify_send(topic, msg)
diff --git a/openstack/common/rpc/common.py b/openstack/common/rpc/common.py
index a95fc66..c56c9a6 100644
--- a/openstack/common/rpc/common.py
+++ b/openstack/common/rpc/common.py
@@ -40,7 +40,7 @@ class RPCException(Exception):
try:
message = self.message % kwargs
- except Exception as e:
+ except Exception:
# kwargs doesn't match a variable in the message
# log the issue and the kwargs
LOG.exception(_('Exception in string format operation'))
@@ -258,7 +258,7 @@ def deserialize_remote_exception(conf, data):
# we cannot necessarily change an exception message so we must override
# the __str__ method.
failure.__class__ = new_ex_type
- except TypeError as e:
+ except TypeError:
# NOTE(ameade): If a core exception then just add the traceback to the
# first exception argument.
failure.args = (message,) + failure.args[1:]
diff --git a/openstack/common/rpc/matchmaker.py b/openstack/common/rpc/matchmaker.py
index 8ea78ba..c5cc64c 100644
--- a/openstack/common/rpc/matchmaker.py
+++ b/openstack/common/rpc/matchmaker.py
@@ -20,7 +20,7 @@ return keys for direct exchanges, per (approximate) AMQP parlance.
import contextlib
import itertools
-import logging
+import json
from openstack.common import cfg
from openstack.common import log as logging
diff --git a/openstack/common/service.py b/openstack/common/service.py
index 910a738..3186d56 100644
--- a/openstack/common/service.py
+++ b/openstack/common/service.py
@@ -36,6 +36,7 @@ from openstack.common.gettextutils import _
from openstack.common import log as logging
from openstack.common import threadgroup
+
rpc = extras.try_import('openstack.common.rpc')
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
@@ -250,10 +251,12 @@ class ProcessLauncher(object):
if os.WIFSIGNALED(status):
sig = os.WTERMSIG(status)
- LOG.info(_('Child %(pid)d killed by signal %(sig)d'), locals())
+ LOG.info(_('Child %(pid)d killed by signal %(sig)d'),
+ dict(pid=pid, sig=sig))
else:
code = os.WEXITSTATUS(status)
- LOG.info(_('Child %(pid)d exited with status %(code)d'), locals())
+ LOG.info(_('Child %(pid)s exited with status %(code)d'),
+ dict(pid=pid, code=code))
if pid not in self.children:
LOG.warning(_('pid %d not in child list'), pid)
diff --git a/openstack/common/threadgroup.py b/openstack/common/threadgroup.py
index 27b3c4c..1f80fef 100644
--- a/openstack/common/threadgroup.py
+++ b/openstack/common/threadgroup.py
@@ -18,7 +18,6 @@ from eventlet import greenlet
from eventlet import greenpool
from eventlet import greenthread
-from openstack.common.gettextutils import _
from openstack.common import log as logging
from openstack.common import loopingcall
diff --git a/openstack/common/utils.py b/openstack/common/utils.py
index e5e04ba..05f0e9f 100644
--- a/openstack/common/utils.py
+++ b/openstack/common/utils.py
@@ -20,15 +20,6 @@ System-level utilities and helper functions.
"""
import logging
-import random
-import shlex
-
-from eventlet.green import subprocess
-from eventlet import greenthread
-
-from openstack.common import exception
-from openstack.common.gettextutils import _
-
LOG = logging.getLogger(__name__)
diff --git a/tox.ini b/tox.ini
index 7f97a91..d7ecb96 100644
--- a/tox.ini
+++ b/tox.ini
@@ -27,3 +27,7 @@ commands = {posargs}
deps = -r{toxinidir}/tools/pip-requires
-r{toxinidir}/tools/test-requires
-r{toxinidir}/tools/test-options
+
+[testenv:pyflakes]
+deps = pyflakes
+commands = pyflakes openstack setup.py update.py
diff --git a/update.py b/update.py
index 849b9b7..d7b0c18 100644
--- a/update.py
+++ b/update.py
@@ -55,7 +55,6 @@ the modules to copy and the base destination module
Obviously, the first way is the easiest!
"""
-import imp
import os
import os.path
import re