More pep8 fixes.
This commit is contained in:
parent
0a0f5f6e84
commit
b494661ad8
@ -104,7 +104,7 @@ class Authority(object):
|
||||
class UserCerts(object):
|
||||
@falcon.before(validate)
|
||||
def on_post(self, req, resp):
|
||||
# TODO: validation
|
||||
# TODO(pino): validation
|
||||
try:
|
||||
user = db.createUserCert(
|
||||
self.session,
|
||||
|
@ -11,11 +11,9 @@
|
||||
# under the License.
|
||||
|
||||
import falcon
|
||||
import os
|
||||
import sqlalchemy as sa
|
||||
import sshpubkeys
|
||||
import uuid
|
||||
from Crypto.PublicKey import RSA
|
||||
from Crypto.PublicKey import RSA
|
||||
from datetime import datetime
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
@ -125,7 +123,7 @@ def createToken(session, host_id, auth_id, hostname):
|
||||
token = session.query(Token).filter(Token.host_id == host_id).one()
|
||||
if token is not None:
|
||||
return token
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
token = Token(host_id=host_id,
|
||||
@ -164,12 +162,12 @@ def createHostCert(session, token_id, host_id, pub):
|
||||
if token.used:
|
||||
if token.fingerprint_used != fingerprint:
|
||||
raise falcon.HTTPConflict(
|
||||
description='The token was previously used with a different public key')
|
||||
description='Token already signed a different public key')
|
||||
# The token was already used for same host and pub key. Return record.
|
||||
host = session.query(HostCert).get([host_id, fingerprint])
|
||||
if host is None:
|
||||
raise falcon.HTTPInternalServerError(
|
||||
description='The token was used, but no corresponding Host record was found.')
|
||||
description='Token already used, but Host record not found.')
|
||||
if host.token_id == token_id:
|
||||
return host
|
||||
raise falcon.HTTPConflict(
|
||||
|
@ -22,7 +22,7 @@ def get_url():
|
||||
# return os.getenv("DATABASE_URL", "sqlite:///:memory:")
|
||||
|
||||
|
||||
class SQLAlchemySessionManager:
|
||||
class SQLAlchemySessionManager(object):
|
||||
"""
|
||||
Create scoped session for every request and close it when the request ends
|
||||
"""
|
||||
|
@ -11,7 +11,6 @@
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import os
|
||||
import requests
|
||||
import sshpubkeys
|
||||
import uuid
|
||||
|
@ -18,7 +18,7 @@ from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker, scoped_session
|
||||
from sqlalchemy.orm import scoped_session, sessionmaker
|
||||
|
||||
from tatu.db.models import createAuthority
|
||||
from tatu.db.persistence import get_url
|
||||
@ -64,9 +64,9 @@ class NotificationEndpoint(object):
|
||||
|
||||
def main():
|
||||
logging.register_options(CONF)
|
||||
extra_log_level_defaults = ['tatu=DEBUG', '__main__=DEBUG']
|
||||
logging.set_defaults(default_log_levels=logging.get_default_log_levels() +
|
||||
extra_log_level_defaults)
|
||||
log_levels = logging.get_default_log_levels() + \
|
||||
['tatu=DEBUG', '__main__=DEBUG']
|
||||
logging.set_defaults(default_log_levels=log_levels)
|
||||
logging.setup(CONF, DOMAIN)
|
||||
|
||||
transport = oslo_messaging.get_notification_transport(CONF)
|
||||
|
@ -46,14 +46,14 @@ def generateCert(auth_key, entity_key, hostname=None, principals='root'):
|
||||
cert = ''
|
||||
with open(cert_file, 'r') as text_file:
|
||||
cert = text_file.read()
|
||||
except Exception as e:
|
||||
print e
|
||||
#except Exception as e:
|
||||
# print e
|
||||
finally:
|
||||
# Delete temporary files
|
||||
for file in [ca_file, pub_file, cert_file]:
|
||||
try:
|
||||
os.remove(file)
|
||||
pass
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return cert
|
||||
|
Loading…
Reference in New Issue
Block a user