Final pep8 fixes.

This commit is contained in:
Pino de Candia 2017-12-08 22:21:25 +00:00
parent b494661ad8
commit 4597a67e0c
9 changed files with 24 additions and 24 deletions

View File

@ -10,11 +10,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from Crypto.PublicKey import RSA
import falcon import falcon
import json import json
import logging import logging
import uuid import uuid
from Crypto.PublicKey import RSA
from tatu.db import models as db from tatu.db import models as db

View File

@ -91,6 +91,7 @@ castellan library, it is not meant for direct usage within tatu.
class TatuKeyManager(KeyManager): class TatuKeyManager(KeyManager):
"""Tatu specific key manager """Tatu specific key manager
This manager is a thin wrapper around the secret being stored. It is This manager is a thin wrapper around the secret being stored. It is
intended for backward compatible use only. It will not store keys intended for backward compatible use only. It will not store keys
or generate UUIDs but instead return the secret that is being stored. or generate UUIDs but instead return the secret that is being stored.

View File

@ -10,13 +10,13 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from Crypto.PublicKey import RSA
from datetime import datetime
import falcon import falcon
import sqlalchemy as sa import sqlalchemy as sa
import sshpubkeys
from Crypto.PublicKey import RSA
from datetime import datetime
from sqlalchemy.exc import IntegrityError from sqlalchemy.exc import IntegrityError
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.declarative import declarative_base
import sshpubkeys
from tatu.castellano import get_secret, store_secret from tatu.castellano import get_secret, store_secret
from tatu.utils import generateCert, random_uuid from tatu.utils import generateCert, random_uuid

View File

@ -23,9 +23,6 @@ def get_url():
class SQLAlchemySessionManager(object): class SQLAlchemySessionManager(object):
"""
Create scoped session for every request and close it when the request ends
"""
def __init__(self): def __init__(self):
self.engine = create_engine(get_url()) self.engine = create_engine(get_url())
@ -33,10 +30,12 @@ class SQLAlchemySessionManager(object):
self.Session = scoped_session(sessionmaker(self.engine)) self.Session = scoped_session(sessionmaker(self.engine))
def process_resource(self, req, resp, resource, params): def process_resource(self, req, resp, resource, params):
# Create a scoped session for every request
resource.session = self.Session() resource.session = self.Session()
def process_response(self, req, resp, resource, req_succeeded): def process_response(self, req, resp, resource, req_succeeded):
if hasattr(resource, 'session'): if hasattr(resource, 'session'):
if not req_succeeded: if not req_succeeded:
resource.session.rollback() resource.session.rollback()
# Close the scoped session when the request ends
self.Session.remove() self.Session.remove()

View File

@ -10,11 +10,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from Crypto.PublicKey import RSA
import json import json
import requests import requests
import sshpubkeys import sshpubkeys
import uuid import uuid
from Crypto.PublicKey import RSA
from tatu.utils import random_uuid from tatu.utils import random_uuid

View File

@ -10,15 +10,15 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import oslo_messaging
import sys
import time
import uuid
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
import oslo_messaging
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from sqlalchemy import create_engine from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker from sqlalchemy.orm import scoped_session, sessionmaker
import sys
import time
import uuid
from tatu.db.models import createAuthority from tatu.db.models import createAuthority
from tatu.db.persistence import get_url from tatu.db.persistence import get_url
@ -65,7 +65,7 @@ class NotificationEndpoint(object):
def main(): def main():
logging.register_options(CONF) logging.register_options(CONF)
log_levels = logging.get_default_log_levels() + \ log_levels = logging.get_default_log_levels() + \
['tatu=DEBUG', '__main__=DEBUG'] ['tatu=DEBUG', '__main__=DEBUG']
logging.set_defaults(default_log_levels=log_levels) logging.set_defaults(default_log_levels=log_levels)
logging.setup(CONF, DOMAIN) logging.setup(CONF, DOMAIN)

View File

@ -9,14 +9,15 @@
# 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.
from Crypto.PublicKey import RSA
import falcon import falcon
from falcon import testing
import json import json
import pytest import pytest
import sshpubkeys import sshpubkeys
import time import time
import uuid import uuid
from Crypto.PublicKey import RSA
from falcon import testing
from tatu.api.app import create_app from tatu.api.app import create_app
from tatu.db.persistence import SQLAlchemySessionManager from tatu.db.persistence import SQLAlchemySessionManager

View File

@ -12,6 +12,7 @@
import os import os
import subprocess import subprocess
from tempfile import NamedTemporaryFile
import uuid import uuid
@ -46,8 +47,6 @@ def generateCert(auth_key, entity_key, hostname=None, principals='root'):
cert = '' cert = ''
with open(cert_file, 'r') as text_file: with open(cert_file, 'r') as text_file:
cert = text_file.read() cert = text_file.read()
#except Exception as e:
# print e
finally: finally:
# Delete temporary files # Delete temporary files
for file in [ca_file, pub_file, cert_file]: for file in [ca_file, pub_file, cert_file]:

14
tox.ini
View File

@ -33,12 +33,16 @@ commands =
python setup.py testr --coverage --testr-args='{posargs}' python setup.py testr --coverage --testr-args='{posargs}'
coverage report coverage report
[testenv:bandit]
# Skip B104 hardcoded_bind_all_interfaces
deps = -r{toxinidir}/test-requirements.txt
commands = bandit -r tatu -n5 -x tests -ll -s B104
[flake8] [flake8]
# Following checks are ignored on purpose. # Following checks are ignored on purpose.
# # H301 one import per line
# E251 unexpected spaces around keyword / parameter equals # E251 unexpected spaces around keyword / parameter equals
# reason: no improvement in readability ignore = E251,D100,D101,D102,D202,D208,H301
ignore = E251,D100,D101,D102,D202,D208
exclude = .git,.venv,.tox,dist,tools,doc,*egg,build exclude = .git,.venv,.tox,dist,tools,doc,*egg,build
max-complexity=30 max-complexity=30
@ -48,7 +52,3 @@ deps =
pylint pylint
commands = commands =
pylint --rcfile=pylintrc --output-format=colorized pylint --rcfile=pylintrc --output-format=colorized
[hacking]
import_exceptions = dragonflow._i18n
local-check-factory = neutron_lib.hacking.checks.factory