Merge "Fix Hacking 0.6 warnings"

This commit is contained in:
Jenkins 2013-07-31 23:34:50 +00:00 committed by Gerrit Code Review
commit 5311b9d0fa
12 changed files with 68 additions and 19 deletions

View File

@ -92,7 +92,8 @@ class Evaluator(object):
window = (alarm.period * window = (alarm.period *
(alarm.evaluation_periods + cls.look_back)) (alarm.evaluation_periods + cls.look_back))
start = now - datetime.timedelta(seconds=window) 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()) after = dict(field='timestamp', op='ge', value=start.isoformat())
before = dict(field='timestamp', op='le', value=now.isoformat()) before = dict(field='timestamp', op='le', value=now.isoformat())
constraints.extend([before, after]) constraints.extend([before, after])
@ -124,11 +125,11 @@ class Evaluator(object):
def _update(self, alarm, state, reason): def _update(self, alarm, state, reason):
"""Refresh alarm state.""" """Refresh alarm state."""
id = alarm.alarm_id LOG.info(_('alarm %(id)s transitioning to %(state)s because '
LOG.info(_('alarm %(id)s transitioning to %(state)s' '%(reason)s') % {'id': alarm.alarm_id, 'state': state,
' because %(reason)s') % locals()) 'reason': reason})
try: try:
self._client.alarms.update(id, **dict(state=state)) self._client.alarms.update(alarm.alarm_id, **dict(state=state))
alarm.state = state alarm.state = state
if self.notifier: if self.notifier:
self.notifier.notify(alarm, state, reason) self.notifier.notify(alarm, state, reason)
@ -155,7 +156,8 @@ class Evaluator(object):
last = getattr(statistics[-1], alarm.statistic) last = getattr(statistics[-1], alarm.statistic)
return (_('Transition to %(state)s due to %(count)d samples' return (_('Transition to %(state)s due to %(count)d samples'
' %(disposition)s threshold, most recent: %(last)s') % ' %(disposition)s threshold, most recent: %(last)s') %
locals()) {'state': state, 'count': count, 'disposition': disposition,
'last': last})
def _transition(self, alarm, statistics, compared): def _transition(self, alarm, statistics, compared):
"""Transition alarm state if necessary. """Transition alarm state if necessary.
@ -212,7 +214,8 @@ class Evaluator(object):
value = getattr(stat, alarm.statistic) value = getattr(stat, alarm.statistic)
limit = alarm.threshold limit = alarm.threshold
LOG.debug(_('comparing value %(value)s against threshold' LOG.debug(_('comparing value %(value)s against threshold'
' %(limit)s') % locals()) ' %(limit)s') %
{'value': value, 'limit': limit})
return op(value, limit) return op(value, limit)
self._transition(alarm, 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 Specific Configurations
server = { server = {
'port': '8777', 'port': '8777',

View File

@ -83,7 +83,10 @@ class LibvirtInspector(virt_inspector.Inspector):
except Exception as ex: except Exception as ex:
error_code = ex.get_error_code() if libvirt else 'unknown' error_code = ex.get_error_code() if libvirt else 'unknown'
msg = ("Error from libvirt while looking up %(instance_name)s: " 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) raise virt_inspector.InstanceNotFoundException(msg)
def inspect_instances(self): def inspect_instances(self):

View File

@ -54,8 +54,9 @@ class UDPPublisher(publisher.PublisherBase):
msg['source'] = source msg['source'] = source
host = self.host host = self.host
port = self.port port = self.port
LOG.debug(_("Publishing counter %(msg)s over " LOG.debug(_("Publishing counter %(msg)s over UDP to "
"UDP to %(host)s:%(port)d") % locals()) "%(host)s:%(port)d") % {'msg': msg, 'host': host,
'port': port})
try: try:
self.socket.sendto(msgpack.dumps(msg), self.socket.sendto(msgpack.dumps(msg),
(self.host, self.port)) (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 __future__ import with_statement
from alembic import context from alembic import context
from logging.config import fileConfig from logging.config import fileConfig

View File

@ -6,14 +6,14 @@
# Author: Mehdi Abaakouk <mehdi.abaakouk@enovance.com> # Author: Mehdi Abaakouk <mehdi.abaakouk@enovance.com>
# Angus Salkeld <asalkeld@redhat.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 # not use this file except in compliance with the License. You may obtain
# a copy of the License at # a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # 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 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.

View File

@ -64,7 +64,9 @@ class ScalingTransformer(transformer.TransformerBase):
self.source = source self.source = source
self.target = target self.target = target
LOG.debug(_('scaling conversion transformer with source:' 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) super(ScalingTransformer, self).__init__(**kwargs)
@staticmethod @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 coverage
discover discover
httplib2 httplib2

View File

@ -5,14 +5,14 @@
# Author: Mehdi Abaakouk <mehdi.abaakouk@enovance.com> # Author: Mehdi Abaakouk <mehdi.abaakouk@enovance.com>
# Angus Salkeld <asalkeld@redhat.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 # not use this file except in compliance with the License. You may obtain
# a copy of the License at # a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # 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 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
@ -86,7 +86,7 @@ class TestAlarms(FunctionalTest,
'value': 'name1', 'value': 'name1',
}]) }])
for a in alarms: 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]['name'], 'name1')
self.assertEquals(alarms[0]['counter_name'], 'meter.test') self.assertEquals(alarms[0]['counter_name'], 'meter.test')

View File

@ -44,7 +44,7 @@ class ConnectionTest(HBaseEngineTestBase):
class TestConn(object): class TestConn(object):
def __init__(self, host, port): def __init__(self, host, port):
self.netloc = '%(host)s:%(port)s' % locals() self.netloc = '%s:%s' % (host, port)
def open(self): def open(self):
pass 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.volume import notifications
from ceilometer.tests import base from ceilometer.tests import base

View File

@ -22,7 +22,7 @@ commands = bash -x {toxinidir}/run-tests.sh --coverage
deps = pep8==1.4.5 deps = pep8==1.4.5
pyflakes==0.7.2 pyflakes==0.7.2
flake8==2.0 flake8==2.0
hacking>=0.5.3,<0.6 hacking>=0.5.6,<0.7
commands = commands =
flake8 flake8
flake8 --filename=ceilometer-* bin flake8 --filename=ceilometer-* bin
@ -40,7 +40,7 @@ deps = -r{toxinidir}/requirements.txt
commands = {posargs} commands = {posargs}
[flake8] [flake8]
ignore = H301,H306 ignore = H301,H306,H506
builtins = _ builtins = _
exclude=.venv,.git,.tox,dist,doc,./ceilometer/openstack/common,*lib/python*,*egg,tools,nova_tests,build exclude=.venv,.git,.tox,dist,doc,./ceilometer/openstack/common,*lib/python*,*egg,tools,nova_tests,build
show-source = True show-source = True