Add Tox with PEP 8 validation.

Change-Id: I09b2aae6b587128200d073510e2630bc82471c06
This commit is contained in:
François Rossigneux 2013-01-15 17:12:19 +01:00
parent 8b9b876a17
commit 9c192fffb0
12 changed files with 44 additions and 31 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
*.pyc
*.egg-info
.tox

1
MANIFEST.in Normal file
View File

@ -0,0 +1 @@
include etc/kwapi/*.conf

View File

@ -22,15 +22,18 @@ from kwapi.openstack.common import cfg, log
app_opts = [
cfg.IntOpt('api_port',
required=True,
),
]
required=True,
),
]
cfg.CONF.register_opts(app_opts)
if __name__ == '__main__':
cfg.CONF(sys.argv[1:], project='kwapi', default_config_files=['/etc/kwapi/api.conf'])
cfg.CONF(sys.argv[1:],
project='kwapi',
default_config_files=['/etc/kwapi/api.conf']
)
log.setup('kwapi')
root = app.make_app()
root.run(host='0.0.0.0', port=cfg.CONF.api_port)

View File

@ -24,11 +24,11 @@ from kwapi.openstack.common import cfg, log
if __name__ == "__main__":
cfg.CONF(sys.argv[1:], project='kwapi', default_config_files=['/etc/kwapi/drivers.conf'])
log.setup('kwapi')
driver_manager.start_zmq_server()
driver_manager.load_all_drivers()
driver_manager.check_drivers_alive()
signal.signal(signal.SIGTERM, driver_manager.signal_handler)
try:
signal.pause()

View File

@ -24,13 +24,13 @@ app_opts = [
cfg.IntOpt('rrd_port',
required=True,
),
]
]
cfg.CONF.register_opts(app_opts)
if __name__ == '__main__':
cfg.CONF(sys.argv[1:], project='kwapi', default_config_files=['/etc/kwapi/rrd.conf'])
log.setup('kwapi')
root = app.make_app()
root.run(host='0.0.0.0', port=cfg.CONF.rrd_port)

View File

@ -53,9 +53,9 @@ def load_all_drivers():
kwargs = {}
if 'parameters' in entries.keys():
kwargs = ast.literal_eval(entries['parameters'][0])
thread = load_driver(class_name, probe_ids, kwargs)
if thread is not None:
threads.append(thread)
driver_thread = load_driver(class_name, probe_ids, kwargs)
if driver_thread is not None:
threads.append(driver_thread)
def load_driver(class_name, probe_ids, kwargs):
@ -80,13 +80,15 @@ def check_drivers_alive():
"""
LOG.info('Checks driver threads')
for index, thread in enumerate(threads):
if not thread.is_alive():
for index, driver_thread in enumerate(threads):
if not driver_thread.is_alive():
LOG.warning('%s(probe_ids=%s, kwargs=%s) is crashed'
% (thread.__class__.__name__,
thread.probe_ids, thread.kwargs))
new_thread = load_driver(thread.__class__.__name__,
thread.probe_ids, thread.kwargs)
% (driver_thread.__class__.__name__,
driver_thread.probe_ids, driver_thread.kwargs))
new_thread = load_driver(driver_thread.__class__.__name__,
driver_thread.probe_ids,
driver_thread.kwargs
)
if new_thread is not None:
threads[index] = new_thread

View File

@ -54,7 +54,7 @@ class BaseParser(object):
value = value.strip()
if ((value and value[0] == value[-1]) and
(value[0] == "\"" or value[0] == "'")):
(value[0] == "\"" or value[0] == "'")):
value = value[1:-1]
return key.strip(), [value]

View File

@ -259,7 +259,7 @@ class JSONFormatter(logging.Formatter):
class PublishErrorsHandler(logging.Handler):
def emit(self, record):
if ('openstack.common.notifier.log_notifier' in
CONF.notification_driver):
CONF.notification_driver):
return
notifier.api.notify(None, 'error.publisher',
'error_notification',
@ -425,7 +425,7 @@ class LegacyFormatter(logging.Formatter):
self._fmt = CONF.logging_default_format_string
if (record.levelno == logging.DEBUG and
CONF.logging_debug_format_suffix):
CONF.logging_debug_format_suffix):
self._fmt += " " + CONF.logging_debug_format_suffix
# Cache this on the record, Logger will respect our formated copy

View File

@ -574,7 +574,7 @@ class ParseState(object):
for reduction, methname in self.reducers:
if (len(self.tokens) >= len(reduction) and
self.tokens[-len(reduction):] == reduction):
self.tokens[-len(reduction):] == reduction):
# Get the reduction method
meth = getattr(self, methname)

View File

@ -95,9 +95,9 @@ class DnsmasqFilter(CommandFilter):
def match(self, userargs):
if (userargs[0] == 'env' and
userargs[1].startswith(self.CONFIG_FILE_ARG) and
userargs[2].startswith('NETWORK_ID=') and
userargs[3] == 'dnsmasq'):
userargs[1].startswith(self.CONFIG_FILE_ARG) and
userargs[2].startswith('NETWORK_ID=') and
userargs[3] == 'dnsmasq'):
return True
return False

View File

@ -27,7 +27,7 @@ setuptools.setup(
author='François Rossigneux',
author_email='francois.rossigneux@inria.fr',
url='http://gitorious.ow2.org/xlcloud/kwapi',
url='https://github.com/stackforge/kwapi',
classifiers=[
'Development Status :: 3 - Alpha',
@ -50,14 +50,13 @@ setuptools.setup(
'bin/kwapi-drivers',
'bin/kwapi-rrd'],
data_files=[('/etc/kwapi', ['etc/kwapi/api.conf',
'etc/kwapi/drivers.conf',
'etc/kwapi/rrd.conf'])],
data_files=[('etc/kwapi', ['etc/kwapi/api.conf',
'etc/kwapi/drivers.conf',
'etc/kwapi/rrd.conf'])],
install_requires=['flask',
'pyserial',
'python-keystoneclient',
'pyzmq',
'py-rrdtool']
'python-rrdtool'],
)

6
tox.ini Normal file
View File

@ -0,0 +1,6 @@
[tox]
envlist = pep8
[testenv:pep8]
deps = pep8==1.4
commands = pep8 --show-source kwapi setup.py bin/kwapi-api bin/kwapi-api bin/kwapi-api