diff --git a/ceilometer/alarm/threshold_evaluation.py b/ceilometer/alarm/threshold_evaluation.py index 19dfe89e9..ab75815d3 100644 --- a/ceilometer/alarm/threshold_evaluation.py +++ b/ceilometer/alarm/threshold_evaluation.py @@ -92,7 +92,8 @@ class Evaluator(object): window = (alarm.period * (alarm.evaluation_periods + cls.look_back)) start = now - datetime.timedelta(seconds=window) - LOG.debug(_('query stats from %(start)s to %(now)s') % locals()) + LOG.debug(_('query stats from %(start)s to ' + '%(now)s') % {'start': start, 'now': now}) after = dict(field='timestamp', op='ge', value=start.isoformat()) before = dict(field='timestamp', op='le', value=now.isoformat()) constraints.extend([before, after]) @@ -124,11 +125,11 @@ class Evaluator(object): def _update(self, alarm, state, reason): """Refresh alarm state.""" - id = alarm.alarm_id - LOG.info(_('alarm %(id)s transitioning to %(state)s' - ' because %(reason)s') % locals()) + LOG.info(_('alarm %(id)s transitioning to %(state)s because ' + '%(reason)s') % {'id': alarm.alarm_id, 'state': state, + 'reason': reason}) try: - self._client.alarms.update(id, **dict(state=state)) + self._client.alarms.update(alarm.alarm_id, **dict(state=state)) alarm.state = state if self.notifier: self.notifier.notify(alarm, state, reason) @@ -155,7 +156,8 @@ class Evaluator(object): last = getattr(statistics[-1], alarm.statistic) return (_('Transition to %(state)s due to %(count)d samples' ' %(disposition)s threshold, most recent: %(last)s') % - locals()) + {'state': state, 'count': count, 'disposition': disposition, + 'last': last}) def _transition(self, alarm, statistics, compared): """Transition alarm state if necessary. @@ -212,7 +214,8 @@ class Evaluator(object): value = getattr(stat, alarm.statistic) limit = alarm.threshold LOG.debug(_('comparing value %(value)s against threshold' - ' %(limit)s') % locals()) + ' %(limit)s') % + {'value': value, 'limit': limit}) return op(value, limit) self._transition(alarm, diff --git a/ceilometer/api/config.py b/ceilometer/api/config.py index cec9d0123..ead2fd662 100644 --- a/ceilometer/api/config.py +++ b/ceilometer/api/config.py @@ -1,3 +1,15 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + # Server Specific Configurations server = { 'port': '8777', diff --git a/ceilometer/compute/virt/libvirt/inspector.py b/ceilometer/compute/virt/libvirt/inspector.py index 5b6d91164..9dfc5112c 100644 --- a/ceilometer/compute/virt/libvirt/inspector.py +++ b/ceilometer/compute/virt/libvirt/inspector.py @@ -83,7 +83,10 @@ class LibvirtInspector(virt_inspector.Inspector): except Exception as ex: error_code = ex.get_error_code() if libvirt else 'unknown' msg = ("Error from libvirt while looking up %(instance_name)s: " - "[Error Code %(error_code)s] %(ex)s" % locals()) + "[Error Code %(error_code)s] " + "%(ex)s" % {'instance_name': instance_name, + 'error_code': error_code, + 'ex': ex}) raise virt_inspector.InstanceNotFoundException(msg) def inspect_instances(self): diff --git a/ceilometer/publisher/udp.py b/ceilometer/publisher/udp.py index 0677c8c2b..a6b8806b4 100644 --- a/ceilometer/publisher/udp.py +++ b/ceilometer/publisher/udp.py @@ -54,8 +54,9 @@ class UDPPublisher(publisher.PublisherBase): msg['source'] = source host = self.host port = self.port - LOG.debug(_("Publishing counter %(msg)s over " - "UDP to %(host)s:%(port)d") % locals()) + LOG.debug(_("Publishing counter %(msg)s over UDP to " + "%(host)s:%(port)d") % {'msg': msg, 'host': host, + 'port': port}) try: self.socket.sendto(msgpack.dumps(msg), (self.host, self.port)) diff --git a/ceilometer/storage/sqlalchemy/alembic/env.py b/ceilometer/storage/sqlalchemy/alembic/env.py index 1ef4ab305..3c2490e39 100644 --- a/ceilometer/storage/sqlalchemy/alembic/env.py +++ b/ceilometer/storage/sqlalchemy/alembic/env.py @@ -1,3 +1,15 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + from __future__ import with_statement from alembic import context from logging.config import fileConfig diff --git a/ceilometer/storage/sqlalchemy/migrate_repo/versions/007_add_alarm_table.py b/ceilometer/storage/sqlalchemy/migrate_repo/versions/007_add_alarm_table.py index 8ec0d379b..0a9575fbd 100644 --- a/ceilometer/storage/sqlalchemy/migrate_repo/versions/007_add_alarm_table.py +++ b/ceilometer/storage/sqlalchemy/migrate_repo/versions/007_add_alarm_table.py @@ -6,14 +6,14 @@ # Author: Mehdi Abaakouk # Angus Salkeld # -# Licensed under the Apache License, Version 2.0 (the 'License'); you may +# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. diff --git a/ceilometer/transformer/conversions.py b/ceilometer/transformer/conversions.py index 3f21430eb..a4fef5496 100644 --- a/ceilometer/transformer/conversions.py +++ b/ceilometer/transformer/conversions.py @@ -64,7 +64,9 @@ class ScalingTransformer(transformer.TransformerBase): self.source = source self.target = target LOG.debug(_('scaling conversion transformer with source:' - ' %(source)s target: %(target)s:') % locals()) + ' %(source)s target: %(target)s:') + % {'source': source, + 'target': target}) super(ScalingTransformer, self).__init__(**kwargs) @staticmethod diff --git a/test-requirements.txt b/test-requirements.txt index b3c45203b..bb91f9889 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,3 +1,7 @@ +pep8==1.4.5 +pyflakes==0.7.2 +flake8==2.0 +hacking>=0.5.6,<0.7 coverage discover httplib2 diff --git a/tests/api/v2/test_alarm_scenarios.py b/tests/api/v2/test_alarm_scenarios.py index 9d4bfabda..92dedd2b1 100644 --- a/tests/api/v2/test_alarm_scenarios.py +++ b/tests/api/v2/test_alarm_scenarios.py @@ -5,14 +5,14 @@ # Author: Mehdi Abaakouk # Angus Salkeld # -# Licensed under the Apache License, Version 2.0 (the 'License'); you may +# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. @@ -86,7 +86,7 @@ class TestAlarms(FunctionalTest, 'value': 'name1', }]) for a in alarms: - print '%s: %s' % (a['name'], a['alarm_id']) + print('%s: %s' % (a['name'], a['alarm_id'])) self.assertEquals(alarms[0]['name'], 'name1') self.assertEquals(alarms[0]['counter_name'], 'meter.test') diff --git a/tests/storage/test_impl_hbase.py b/tests/storage/test_impl_hbase.py index 93703bd91..87e590382 100644 --- a/tests/storage/test_impl_hbase.py +++ b/tests/storage/test_impl_hbase.py @@ -44,7 +44,7 @@ class ConnectionTest(HBaseEngineTestBase): class TestConn(object): def __init__(self, host, port): - self.netloc = '%(host)s:%(port)s' % locals() + self.netloc = '%s:%s' % (host, port) def open(self): pass diff --git a/tests/volume/test_notifications.py b/tests/volume/test_notifications.py index aa52c4eb7..48f0313b1 100644 --- a/tests/volume/test_notifications.py +++ b/tests/volume/test_notifications.py @@ -1,3 +1,15 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + from ceilometer.volume import notifications from ceilometer.tests import base diff --git a/tox.ini b/tox.ini index a97ec29ff..25033c765 100644 --- a/tox.ini +++ b/tox.ini @@ -22,7 +22,7 @@ commands = bash -x {toxinidir}/run-tests.sh --coverage deps = pep8==1.4.5 pyflakes==0.7.2 flake8==2.0 - hacking>=0.5.3,<0.6 + hacking>=0.5.6,<0.7 commands = flake8 flake8 --filename=ceilometer-* bin @@ -40,7 +40,7 @@ deps = -r{toxinidir}/requirements.txt commands = {posargs} [flake8] -ignore = H301,H306 +ignore = H301,H306,H506 builtins = _ exclude=.venv,.git,.tox,dist,doc,./ceilometer/openstack/common,*lib/python*,*egg,tools,nova_tests,build show-source = True