Add .gitreviw file; Fixed pyflakes violations; Fixed pep7 violations; Fixed tox.ini config;

Change-Id: Ia0f42318babb87a2be3db005c1939565590b2e4d
This commit is contained in:
John Wood 2013-06-26 15:23:41 -05:00
parent 5bb13c5118
commit a98b5b7c02
20 changed files with 38 additions and 38 deletions

4
.gitreview Normal file
View File

@ -0,0 +1,4 @@
[gerrit]
host=review.openstack.org
port=29418
project=stackforge/barbican.git

View File

@ -66,4 +66,4 @@ def create_admin_app(global_config, **local_conf):
wsgi_app = api = falcon.API()
api.add_route('/', versions)
return wsgi_app
return wsgi_app

View File

@ -16,6 +16,7 @@
"""
Barbican middleware modules.
"""
import sys
import webob.dec
from barbican.common import utils

View File

@ -24,6 +24,7 @@ from barbican.api import policy
from barbican.api.middleware import Middleware
import barbican.context
import barbican.openstack.common.log as logging
from barbican.openstack.common.gettextutils import _
context_opts = [

View File

@ -25,6 +25,7 @@ from oslo.config import cfg
from barbican.common import exception
import barbican.openstack.common.log as logging
from barbican.openstack.common import policy
from barbican.openstack.common.gettextutils import _
LOG = logging.getLogger(__name__)

View File

@ -233,7 +233,7 @@ def handle_exceptions(operation_name=_('System')):
fn(inst, req, resp, *args, **kwargs)
except falcon.HTTPError as f:
raise f # Already converted to Falcon exception, just reraise
except Exception as e:
except Exception:
message = _('{0} failure seen - please contact site '
'administrator').format(operation_name)
LOG.exception(message)
@ -305,7 +305,7 @@ class SecretsResource(api.ApiResource):
except exception.LimitExceeded:
LOG.exception('Secret data too big to process')
_secret_data_too_large(req, resp)
except Exception as e:
except Exception:
LOG.exception('Secret creation failed - unknown')
_general_failure('Secret creation failed - unknown', req, resp)
@ -393,7 +393,7 @@ class SecretResource(api.ApiResource):
LOG.exception('Secret information of type {0} not '
'found for decryption.'.format(cnsode.mime_type))
_get_secret_info_not_found(cnsode.mime_type, req, resp)
except Exception as e:
except Exception:
LOG.exception('Secret decryption failed - unknown')
_failed_to_decrypt_data(req, resp)
@ -438,7 +438,7 @@ class SecretResource(api.ApiResource):
except exception.LimitExceeded:
LOG.exception('Secret data too big to process')
_secret_data_too_large(req, resp)
except Exception as e:
except Exception:
LOG.exception('Secret creation failed - unknown')
_failed_to_create_encrypted_datum(req, resp)

View File

@ -24,6 +24,7 @@ import os
import sys
from barbican.version import __version__
from barbican.openstack.common.gettextutils import _
from oslo.config import cfg
CONF = cfg.CONF

View File

@ -16,7 +16,6 @@
"""
Shared business logic.
"""
from sys import getsizeof
from barbican.common import exception, validators
from barbican.model import models
from barbican.common import utils

View File

@ -8,6 +8,7 @@ from oslo.config import cfg
from barbican.common import exception
from barbican.openstack.common import timeutils
from barbican.common import utils
from barbican.openstack.common.gettextutils import _
LOG = utils.getLogger(__name__)

View File

@ -17,17 +17,14 @@
Defines database models for Barbican
"""
import dateutil.parser
from sqlalchemy import Column, Integer, String, BigInteger
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import ForeignKey, DateTime, Boolean, Text, LargeBinary
from sqlalchemy.orm import relationship, backref, object_mapper
from sqlalchemy import Index, UniqueConstraint
from sqlalchemy.orm import relationship, object_mapper
from barbican.openstack.common import timeutils
from barbican.openstack.common import uuidutils
from barbican.openstack.common import jsonutils as json
from barbican.common import utils
LOG = utils.getLogger(__name__)

View File

@ -28,7 +28,6 @@ from oslo.config import cfg
import sqlalchemy
import sqlalchemy.orm as sa_orm
import sqlalchemy.sql as sa_sql
from sqlalchemy import or_
from barbican.common import exception
@ -63,6 +62,9 @@ CONF = cfg.CONF
CONF.register_opts(db_opts)
CONF.import_opt('debug', 'barbican.openstack.common.log')
_CONNECTION = None
_IDLE_TIMEOUT = None
def setup_db_env():
"""
@ -107,10 +109,10 @@ def get_engine():
_RETRY_INTERVAL
if not _ENGINE:
tries = _MAX_RETRIES
retry_interval = _RETRY_INTERVAL
if not _CONNECTION:
raise exception.BarbicanException('No _CONNECTION configured')
connection_dict = sqlalchemy.engine.url.make_url(_CONNECTION)
#TODO: connection_dict = sqlalchemy.engine.url.make_url(_CONNECTION)
engine_args = {
'pool_recycle': _IDLE_TIMEOUT,
@ -313,7 +315,7 @@ class BaseRepo(object):
except sqlalchemy.exc.IntegrityError:
LOG.exception('Problem saving entity for update')
raise exception.NotFound("Entity ID %s not found"
% entity_id)
% entity.id)
def update(self, entity_id, values, purge_props=False):
"""

View File

@ -18,7 +18,6 @@ Queue objects for Cloudkeep's Barbican
"""
from oslo.config import cfg
from barbican.common import config
from barbican.openstack.common.gettextutils import _
from barbican.openstack.common import importutils
from barbican.common import utils

View File

@ -20,7 +20,7 @@ from celery import Celery
from oslo.config import cfg
from barbican.tasks.resources import BeginOrder
from barbican.common import config, utils
from barbican.common import utils
LOG = utils.getLogger(__name__)

View File

@ -16,11 +16,10 @@
"""
Task resources for the Barbican API.
"""
from time import sleep
from barbican.crypto.extension_manager import CryptoExtensionManager
from barbican.model import repositories as rep
from barbican.model.models import States
from barbican.common.resources import create_secret, get_or_create_tenant
from barbican.common.resources import create_secret
from barbican.common import utils
LOG = utils.getLogger(__name__)

View File

@ -18,11 +18,9 @@ import falcon
import json
import unittest
from datetime import datetime
from barbican.api import resources as res
from barbican.crypto.extension_manager import CryptoExtensionManager
from barbican.model import models
from barbican.common import config
from barbican.common import exception as excep
from barbican.common.validators import DEFAULT_MAX_SECRET_BYTES
from barbican.openstack.common import jsonutils
@ -301,7 +299,6 @@ class WhenGettingSecretsListUsingSecretsResource(unittest.TestCase):
self.keystone_id = 'keystone1234'
self.name = 'name1234'
self.mime_type = 'text/plain'
secret_id_base = "idsecret"
self.secret_algorithm = "algo"
self.secret_bit_length = 512
self.secret_cypher_type = "cytype"
@ -739,7 +736,6 @@ class WhenGettingOrdersListUsingOrdersResource(unittest.TestCase):
self.keystone_id = 'keystoneid1234'
self.name = 'name1234'
self.mime_type = 'text/plain'
secret_id_base = "idsecret"
self.secret_algorithm = "algo"
self.secret_bit_length = 512
self.secret_cypher_type = "cytype"

View File

@ -15,7 +15,6 @@
import unittest
import datetime
from mock import MagicMock
from barbican.common import exception as excep
from barbican.common import validators
@ -52,11 +51,11 @@ class WhenTestingSecretValidator(unittest.TestCase):
def test_should_validate_no_name(self):
del self.secret_req['name']
result = self.validator.validate(self.secret_req)
self.validator.validate(self.secret_req)
def test_should_validate_empty_name(self):
self.secret_req['name'] = ' '
result = self.validator.validate(self.secret_req)
self.validator.validate(self.secret_req)
def test_should_validate_no_plain_text(self):
del self.secret_req['plain_text']

View File

@ -14,23 +14,18 @@
# limitations under the License.
from mock import MagicMock
import json
import unittest
from datetime import datetime
from barbican.crypto.extension_manager import CryptoExtensionManager
from barbican.tasks.resources import BeginOrder
from barbican.model.models import (Tenant, Secret, TenantSecret,
EncryptedDatum, Order, States)
from barbican.model.repositories import OrderRepo
from barbican.common import config
from barbican.common import exception
from barbican.openstack.common import timeutils
def suite():
suite = unittest.TestSuite()
suite.addTest(WhenTestingVersionResource())
suite.addTest(WhenBeginningOrder())
return suite

View File

@ -1,8 +1,4 @@
import httplib
import os
import StringIO
import subprocess
import sys
host = "localhost"

View File

@ -2,4 +2,5 @@ mock>=1.0.0
nose
nosexcover
testtools
tox
tox
pep8

10
tox.ini
View File

@ -1,5 +1,5 @@
[tox]
envlist = py27
envlist = pep8,pyflakes,py27
[testenv]
setenv =
@ -8,5 +8,13 @@ setenv =
deps = -r{toxinidir}/tools/pip-requires
-r{toxinidir}/tools/test-requires
[testenv:pyflakes]
deps = pyflakes
commands = pyflakes barbican setup.py
[testenv:pep8]
deps = pep8
commands = pep8 barbican --ignore=E711 --count --repeat --show-source --exclude=.tox setup.py
[testenv:py27]
commands = nosetests {posargs:--with-xcoverage --all-modules --cover-inclusive --traverse-namespace --with-xunit --cover-package=barbican}