Add PEP8 check and fix related issues
- Add PEP8 section to tox.ini - Add hacking to requirements to enforce OpenStack style requirements - Fix formatting issues flagged by flake8 check - Add copyright notices to all remaining files - Update .gitignore file - Fix an unused variable bug - Fix a mutable default argument bug Change-Id: I711efd8055f98e4ffc0bef706f25c6a335409aaa
This commit is contained in:
parent
519bbeaab3
commit
4b2cd52264
4
.gitignore
vendored
4
.gitignore
vendored
@ -52,3 +52,7 @@ coverage.xml
|
|||||||
# Sphinx documentation
|
# Sphinx documentation
|
||||||
docs/_build/
|
docs/_build/
|
||||||
|
|
||||||
|
# IDE Project Files
|
||||||
|
*.project
|
||||||
|
*.pydev*
|
||||||
|
*.idea
|
||||||
|
@ -15,8 +15,9 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from winchester.config import ConfigItem
|
||||||
from winchester.config import ConfigManager, ConfigSection, ConfigItem
|
from winchester.config import ConfigManager
|
||||||
|
from winchester.config import ConfigSection
|
||||||
from winchester.db import DBInterface
|
from winchester.db import DBInterface
|
||||||
from winchester import models
|
from winchester import models
|
||||||
|
|
||||||
@ -25,18 +26,20 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class Impl(object):
|
class Impl(object):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def config_description(cls):
|
def config_description(cls):
|
||||||
return dict(config_path=ConfigItem(
|
return dict(
|
||||||
|
config_path=ConfigItem(
|
||||||
help="Path(s) to find additional config files",
|
help="Path(s) to find additional config files",
|
||||||
multiple=True, default='.'),
|
multiple=True, default='.'),
|
||||||
database=ConfigSection(help="Database connection info.",
|
database=ConfigSection(
|
||||||
|
help="Database connection info.",
|
||||||
config_description=DBInterface.config_description()),
|
config_description=DBInterface.config_description()),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, config, scratchpad):
|
def __init__(self, config, scratchpad):
|
||||||
"""config is a ConfigParser object.
|
"""config is a ConfigParser object.
|
||||||
|
|
||||||
Use the scratchpad to ensure we don't create multiple
|
Use the scratchpad to ensure we don't create multiple
|
||||||
connections to the db.
|
connections to the db.
|
||||||
"""
|
"""
|
||||||
@ -49,7 +52,8 @@ class Impl(object):
|
|||||||
self.config_description())
|
self.config_description())
|
||||||
|
|
||||||
scratchpad['quincy_config'] = quincy_config
|
scratchpad['quincy_config'] = quincy_config
|
||||||
scratchpad['quincy_driver'] = DBInterface(quincy_config['database'])
|
scratchpad['quincy_driver'] = DBInterface(
|
||||||
|
quincy_config['database'])
|
||||||
|
|
||||||
self.winchester_config = scratchpad['quincy_config']
|
self.winchester_config = scratchpad['quincy_config']
|
||||||
self.driver = scratchpad['quincy_driver']
|
self.driver = scratchpad['quincy_driver']
|
||||||
@ -64,14 +68,16 @@ class Impl(object):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
logger.error("invalid stream state %s" % state)
|
logger.error("invalid stream state %s" % state)
|
||||||
raise
|
raise
|
||||||
return self.driver.find_streams(count=count,
|
return self.driver.find_streams(
|
||||||
|
count=count,
|
||||||
state=state, name=trigger_name,
|
state=state, name=trigger_name,
|
||||||
younger_than=younger_than, older_than=older_than,
|
younger_than=younger_than,
|
||||||
|
older_than=older_than,
|
||||||
distinguishing_traits=distinguishing_traits,
|
distinguishing_traits=distinguishing_traits,
|
||||||
mark=mark, limit=limit)
|
mark=mark, limit=limit)
|
||||||
|
|
||||||
def get_stream(self, stream_id, details):
|
def get_stream(self, stream_id, details):
|
||||||
stream = int(stream_id)
|
stream_id = int(stream_id)
|
||||||
# Returns a list, but should be just one stream.
|
# Returns a list, but should be just one stream.
|
||||||
return self.driver.find_streams(stream_id=stream_id,
|
return self.driver.find_streams(stream_id=stream_id,
|
||||||
include_events=details)
|
include_events=details)
|
||||||
@ -87,12 +93,12 @@ class Impl(object):
|
|||||||
self.driver.reset_stream(stream)
|
self.driver.reset_stream(stream)
|
||||||
|
|
||||||
def find_events(self, from_datetime=None, to_datetime=None,
|
def find_events(self, from_datetime=None, to_datetime=None,
|
||||||
event_name=None, traits=[],
|
event_name=None, traits=None,
|
||||||
mark=None, limit=None, count=False):
|
mark=None, limit=None, count=False):
|
||||||
return self.driver.find_events(from_datetime=from_datetime,
|
return self.driver.find_events(from_datetime=from_datetime,
|
||||||
to_datetime=to_datetime,
|
to_datetime=to_datetime,
|
||||||
event_name=event_name,
|
event_name=event_name,
|
||||||
traits=traits,
|
traits=traits or [],
|
||||||
mark=mark, limit=limit,
|
mark=mark, limit=limit,
|
||||||
count=count)
|
count=count)
|
||||||
|
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
|
hacking>=0.10.0,<0.11
|
||||||
winchester >=0.0.dev0
|
winchester >=0.0.dev0
|
||||||
simport >=0.0.dev0
|
simport >=0.0.dev0
|
||||||
|
11
tox.ini
11
tox.ini
@ -1,5 +1,5 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = py26,py27
|
envlist = py26,py27,pep8
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps =
|
deps =
|
||||||
@ -8,3 +8,12 @@ deps =
|
|||||||
mock
|
mock
|
||||||
|
|
||||||
commands = nosetests -d -v --with-coverage --cover-inclusive --cover-package quince []
|
commands = nosetests -d -v --with-coverage --cover-inclusive --cover-package quince []
|
||||||
|
|
||||||
|
[testenv:pep8]
|
||||||
|
commands =
|
||||||
|
flake8
|
||||||
|
|
||||||
|
[flake8]
|
||||||
|
ignore =
|
||||||
|
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,*db/__init__.py,*db/migrations/versions/*_.py
|
||||||
|
show-source = True
|
||||||
|
Loading…
Reference in New Issue
Block a user