Fix Hacking 0.6 warnings

This patch fixes missing License headers, License header mismatches
and locals() being used in string formatting operations.

Change-Id: I721700fda746e78d36d29d0ed64bfeab61755fb3
This commit is contained in:
Julien Danjou 2013-07-20 00:09:32 +02:00
parent dbb8ca35fc
commit 132ea1362b
12 changed files with 68 additions and 19 deletions

View File

@ -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,

View File

@ -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',

View File

@ -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):

View File

@ -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))

View File

@ -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

View File

@ -6,14 +6,14 @@
# Author: Mehdi Abaakouk <mehdi.abaakouk@enovance.com>
# Angus Salkeld <asalkeld@redhat.com>
#
# 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.

View File

@ -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

View File

@ -1,3 +1,7 @@
pep8==1.4.5
pyflakes==0.7.2
flake8==2.0
hacking>=0.5.6,<0.7
coverage
discover
httplib2

View File

@ -5,14 +5,14 @@
# Author: Mehdi Abaakouk <mehdi.abaakouk@enovance.com>
# Angus Salkeld <asalkeld@redhat.com>
#
# 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')

View File

@ -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

View File

@ -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

View File

@ -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