diff --git a/ceilometer/api/controllers/v2.py b/ceilometer/api/controllers/v2.py index 43ed6db05..08af2de74 100644 --- a/ceilometer/api/controllers/v2.py +++ b/ceilometer/api/controllers/v2.py @@ -804,7 +804,7 @@ class AlarmsController(rest.RestController): @wsme.validate(Alarm) @wsme_pecan.wsexpose(Alarm, body=Alarm, status_code=201) def post(self, data): - """Create a new alarm""" + """Create a new alarm.""" conn = pecan.request.storage_conn data.user_id = pecan.request.headers.get('X-User-Id') @@ -832,7 +832,7 @@ class AlarmsController(rest.RestController): @wsme.validate(Alarm) @wsme_pecan.wsexpose(Alarm, wtypes.text, body=Alarm) def put(self, alarm_id, data): - """Modify an alarm""" + """Modify an alarm.""" conn = pecan.request.storage_conn data.state_timestamp = wsme.Unset data.alarm_id = alarm_id @@ -858,7 +858,7 @@ class AlarmsController(rest.RestController): @wsme_pecan.wsexpose(None, wtypes.text, status_code=204) def delete(self, alarm_id): - """Delete an alarm""" + """Delete an alarm.""" conn = pecan.request.storage_conn auth_project = acl.get_limited_to_project(pecan.request.headers) alarms = list(conn.get_alarms(alarm_id=alarm_id, @@ -870,7 +870,7 @@ class AlarmsController(rest.RestController): @wsme_pecan.wsexpose(Alarm, wtypes.text) def get_one(self, alarm_id): - """Return one alarm""" + """Return one alarm.""" conn = pecan.request.storage_conn auth_project = acl.get_limited_to_project(pecan.request.headers) alarms = list(conn.get_alarms(alarm_id=alarm_id, diff --git a/ceilometer/collector/service.py b/ceilometer/collector/service.py index b2cd4c783..9092be625 100644 --- a/ceilometer/collector/service.py +++ b/ceilometer/collector/service.py @@ -91,7 +91,7 @@ class UDPCollectorService(os_service.Service): data, source = udp.recvfrom(64 * 1024) try: counter = msgpack.loads(data) - except: + except Exception: LOG.warn(_("UDP: Cannot decode data sent by %s"), str(source)) else: try: diff --git a/ceilometer/storage/impl_hbase.py b/ceilometer/storage/impl_hbase.py index a06f16f74..0d9795f01 100644 --- a/ceilometer/storage/impl_hbase.py +++ b/ceilometer/storage/impl_hbase.py @@ -31,7 +31,8 @@ from collections import defaultdict from oslo.config import cfg -from ceilometer.openstack.common import log, timeutils +from ceilometer.openstack.common import log +from ceilometer.openstack.common import timeutils from ceilometer.storage import base from ceilometer.storage import models @@ -134,11 +135,11 @@ class Connection(base.Connection): self.METER_TABLE]: try: self.conn.disable_table(table) - except: + except Exception: LOG.debug('Cannot disable table but ignoring error') try: self.conn.delete_table(table) - except: + except Exception: LOG.debug('Cannot delete table but ignoring error') @staticmethod @@ -292,8 +293,7 @@ class Connection(base.Connection): :param metaquery: Optional dict with metadata to match on. """ def make_resource(data): - """ transform HBase fields to Resource model - """ + """Transform HBase fields to Resource model.""" # convert HBase metadata e.g. f:r_display_name to display_name data['f:metadata'] = dict((k[4:], v) for k, v in data.iteritems() @@ -397,8 +397,7 @@ class Connection(base.Connection): """Return an iterable of models.Sample instances """ def make_sample(data): - """ transform HBase fields to Sample model - """ + """Transform HBase fields to Sample model.""" data = json.loads(data['f:message']) data['timestamp'] = timeutils.parse_strtime(data['timestamp']) return models.Sample(**data) @@ -410,7 +409,7 @@ class Connection(base.Connection): gen = self.meter.scan(filter=q, row_start=start, row_stop=stop) for ignored, meter in gen: - # TODO (shengjie) put this implementation here because it's failing + # TODO(shengjie) put this implementation here because it's failing # the test. bp hbase-meter-table-enhancement will address this # properly. # handle metaquery @@ -593,8 +592,8 @@ class MTable(object): ret[row] = data rows = ret elif filter: - # TODO: we should really parse this properly, but at the moment we - # are only going to support AND here + # TODO(jdanjou): we should really parse this properly, + # but at the moment we are only going to support AND here filters = filter.split('AND') for f in filters: # Extract filter name and its arguments @@ -763,7 +762,7 @@ def make_query_from_filter(sample_filter, require_meter=True): def _make_rowkey_scan(meter, rts_start=None, rts_end=None): - """ if it's meter filter without start and end, + """If it's meter filter without start and end, start_row = meter while end_row = meter + MAX_BYTE """ if not rts_start: diff --git a/ceilometer/storage/impl_sqlalchemy.py b/ceilometer/storage/impl_sqlalchemy.py index 3481dd760..a5a2c6a29 100644 --- a/ceilometer/storage/impl_sqlalchemy.py +++ b/ceilometer/storage/impl_sqlalchemy.py @@ -30,9 +30,16 @@ import ceilometer.openstack.common.db.sqlalchemy.session as sqlalchemy_session from ceilometer.storage import base from ceilometer.storage import models as api_models from ceilometer.storage.sqlalchemy import migration -from ceilometer.storage.sqlalchemy.models import Meter, Project, Resource -from ceilometer.storage.sqlalchemy.models import Source, User, Base, Alarm -from ceilometer.storage.sqlalchemy.models import UniqueName, Event, Trait +from ceilometer.storage.sqlalchemy.models import Alarm +from ceilometer.storage.sqlalchemy.models import Base +from ceilometer.storage.sqlalchemy.models import Event +from ceilometer.storage.sqlalchemy.models import Meter +from ceilometer.storage.sqlalchemy.models import Project +from ceilometer.storage.sqlalchemy.models import Resource +from ceilometer.storage.sqlalchemy.models import Source +from ceilometer.storage.sqlalchemy.models import Trait +from ceilometer.storage.sqlalchemy.models import UniqueName +from ceilometer.storage.sqlalchemy.models import User from ceilometer import utils diff --git a/ceilometer/storage/sqlalchemy/models.py b/ceilometer/storage/sqlalchemy/models.py index 6334b2256..7b830088c 100644 --- a/ceilometer/storage/sqlalchemy/models.py +++ b/ceilometer/storage/sqlalchemy/models.py @@ -78,8 +78,7 @@ class CeilometerBase(object): return getattr(self, key) def update(self, values): - """ Make the model object behave like a dict - """ + """Make the model object behave like a dict.""" for k, v in values.iteritems(): setattr(self, k, v) @@ -151,7 +150,7 @@ class Resource(Base): class Alarm(Base): - """Alarm data""" + """Define Alarm data.""" __tablename__ = 'alarm' id = Column(String(255), primary_key=True) enabled = Column(Boolean) diff --git a/tests/agentbase.py b/tests/agentbase.py index 3fbe4cb26..a8ff0df1d 100644 --- a/tests/agentbase.py +++ b/tests/agentbase.py @@ -148,7 +148,7 @@ class BaseAgentManagerTestCase(base.TestCase): @abc.abstractmethod def setup_manager(self): - """Setup subclass specific managers""" + """Setup subclass specific managers.""" @mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock()) def setUp(self): diff --git a/tests/compute/test_pollsters.py b/tests/compute/test_pollsters.py index 1aa5543c8..df78014ba 100644 --- a/tests/compute/test_pollsters.py +++ b/tests/compute/test_pollsters.py @@ -23,8 +23,8 @@ import mock import time -from ceilometer.compute import pollsters from ceilometer.compute import manager +from ceilometer.compute import pollsters from ceilometer.compute.virt import inspector as virt_inspector from ceilometer.tests import base as test_base diff --git a/tests/network/test_floatingip.py b/tests/network/test_floatingip.py index 3c1f5098c..bcabb02a6 100644 --- a/tests/network/test_floatingip.py +++ b/tests/network/test_floatingip.py @@ -22,9 +22,9 @@ import mock -from ceilometer import nova_client -from ceilometer.network import floatingip from ceilometer.central import manager +from ceilometer.network import floatingip +from ceilometer import nova_client from ceilometer.openstack.common import context from ceilometer.tests import base diff --git a/tox.ini b/tox.ini index fb9c55b76..2e109f61e 100644 --- a/tox.ini +++ b/tox.ini @@ -39,7 +39,7 @@ deps = -r{toxinidir}/requirements.txt commands = {posargs} [flake8] -ignore = E125,F401,F403,H +ignore = E125,F401,F403,H301,H302,H304,H306,H401,H402,H403,H404,H703 builtins = _ exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools,nova_tests show-source = True