Merge "Use flake8 instead pep8."

This commit is contained in:
Jenkins 2013-06-20 16:50:26 +00:00 committed by Gerrit Code Review
commit 07f4eddf7c
3 changed files with 34 additions and 50 deletions

View File

@ -58,7 +58,7 @@ import yaml
try:
import daemon.pidlockfile
pid_file_module = daemon.pidlockfile
except:
except Exception:
# as of python-daemon 1.6 it doesn't bundle pidlockfile anymore
# instead it depends on lockfile-0.9.1
import daemon.pidfile
@ -68,9 +68,8 @@ except:
class GerritBot(irc.bot.SingleServerIRCBot):
def __init__(self, channels, nickname, password, server, port=6667,
server_password=None):
irc.bot.SingleServerIRCBot.__init__(self,
[(server, port, server_password)],
nickname, nickname)
irc.bot.SingleServerIRCBot.__init__(
self, [(server, port, server_password)], nickname, nickname)
self.channel_list = channels
self.nickname = nickname
self.password = password
@ -118,12 +117,12 @@ class Gerrit(threading.Thread):
# Import here because it needs to happen after daemonization
import gerritlib.gerrit
try:
self.gerrit = gerritlib.gerrit.Gerrit(self.server, self.username,
self.port, self.keyfile)
self.gerrit = gerritlib.gerrit.Gerrit(
self.server, self.username, self.port, self.keyfile)
self.gerrit.startWatching()
self.log.info('Start watching Gerrit event stream.')
self.connected = True
except:
except Exception:
self.log.exception('Exception while connecting to gerrit')
self.connected = False
# Delay before attempting again.
@ -147,8 +146,8 @@ class Gerrit(threading.Thread):
self.ircbot.send(channel, msg)
for approval in data.get('approvals', []):
if (approval['type'] == 'VRIF' and approval['value'] == '-2' and
channel in self.channel_config.events.get(
if (approval['type'] == 'VRIF' and approval['value'] == '-2'
and channel in self.channel_config.events.get(
'x-vrif-minus-2', set())):
msg = 'Verification of a change to %s failed: %s %s' % (
data['change']['project'],
@ -157,8 +156,8 @@ class Gerrit(threading.Thread):
self.log.info('Compiled Message %s: %s' % (channel, msg))
self.ircbot.send(channel, msg)
if (approval['type'] == 'VRIF' and approval['value'] == '2' and
channel in self.channel_config.events.get(
if (approval['type'] == 'VRIF' and approval['value'] == '2'
and channel in self.channel_config.events.get(
'x-vrif-plus-2', set())):
msg = 'Verification of a change to %s succeeded: %s %s' % (
data['change']['project'],
@ -167,8 +166,8 @@ class Gerrit(threading.Thread):
self.log.info('Compiled Message %s: %s' % (channel, msg))
self.ircbot.send(channel, msg)
if (approval['type'] == 'CRVW' and approval['value'] == '-2' and
channel in self.channel_config.events.get(
if (approval['type'] == 'CRVW' and approval['value'] == '-2'
and channel in self.channel_config.events.get(
'x-crvw-minus-2', set())):
msg = 'A change to %s has been rejected: %s %s' % (
data['change']['project'],
@ -177,8 +176,8 @@ class Gerrit(threading.Thread):
self.log.info('Compiled Message %s: %s' % (channel, msg))
self.ircbot.send(channel, msg)
if (approval['type'] == 'CRVW' and approval['value'] == '2' and
channel in self.channel_config.events.get(
if (approval['type'] == 'CRVW' and approval['value'] == '2'
and channel in self.channel_config.events.get(
'x-crvw-plus-2', set())):
msg = 'A change to %s has been approved: %s %s' % (
data['change']['project'],
@ -225,7 +224,7 @@ class Gerrit(threading.Thread):
event = self.gerrit.getEvent()
self.log.info('Received event: %s' % event)
self._read(event)
except:
except Exception:
self.log.exception('Exception encountered in event loop')
if not self.gerrit.watcher_thread.is_alive():
# Start new gerrit connection. Don't need to restart IRC

View File

@ -1,10 +1,4 @@
distribute>=0.6.24
mock
nose
nose-exclude
nosexcover
openstack.nose_plugin
pep8==1.1
hacking>=0.5.4,<0.6
sphinx>=1.1.2
unittest2

23
tox.ini
View File

@ -1,28 +1,19 @@
[tox]
envlist = py26,py27,pep8
envlist = pep8
[testenv]
setenv = VIRTUAL_ENV={envdir}
NOSE_WITH_OPENSTACK=1
NOSE_OPENSTACK_COLOR=1
NOSE_OPENSTACK_RED=0.05
NOSE_OPENSTACK_YELLOW=0.025
NOSE_OPENSTACK_SHOW_ELAPSED=1
NOSE_OPENSTACK_STDOUT=1
deps = -r{toxinidir}/tools/pip-requires
-r{toxinidir}/tools/test-requires
commands = nosetests {posargs}
[testenv:pep8]
deps = pep8==1.1
commands = pep8 --repeat --show-source --exclude=.venv,.tox,dist,doc,*.egg .
[testenv:cover]
setenv = NOSE_WITH_COVERAGE=1
commands = flake8
[testenv:pyflakes]
deps = pyflakes
commands = pyflakes gerritbot/bot.py setup.py
commands = flake8
[testenv:venv]
commands = {posargs}
[flake8]
show-source = True
exclude = .venv,.tox,dist,doc,*.egg