Clean up pep8 E122, E123 violations

Fixed E122, E123 errors.
All other ignores are to be removed in the next sequence of patches.

Change-Id: I4b3edd9d1b2804ea7de255136da01b19f32abe1c
This commit is contained in:
Zhongyue Luo 2012-09-19 16:41:51 +08:00
parent ba3d3728d1
commit 9f9f22cd80
25 changed files with 72 additions and 78 deletions

View File

@ -29,7 +29,7 @@ context_opts = [
cfg.BoolOpt('owner_is_tenant', default=True),
cfg.StrOpt('admin_role', default='admin'),
cfg.BoolOpt('allow_anonymous_access', default=False),
]
]
CONF = cfg.CONF
CONF.register_opts(context_opts)

View File

@ -27,10 +27,10 @@ from glance.openstack.common import policy
LOG = logging.getLogger(__name__)
policy_opts = (
policy_opts = [
cfg.StrOpt('policy_file', default='policy.json'),
cfg.StrOpt('policy_default_rule', default='default'),
)
]
CONF = cfg.CONF
CONF.register_opts(policy_opts)

View File

@ -195,9 +195,9 @@ class KeystoneStrategy(BaseStrategy):
"passwordCredentials": {
"username": creds['username'],
"password": creds['password']
}
}
}
}
headers = {}
headers['Content-Type'] = 'application/json'

View File

@ -34,7 +34,7 @@ from glance.version import version_info as version
paste_deploy_opts = [
cfg.StrOpt('flavor'),
cfg.StrOpt('config_file'),
]
]
common_opts = [
cfg.BoolOpt('allow_additional_image_properties', default=True,
help=_('Whether to allow users to specify image properties '

View File

@ -54,7 +54,7 @@ db_opts = [
cfg.IntOpt('sql_max_retries', default=10),
cfg.IntOpt('sql_retry_interval', default=1),
cfg.BoolOpt('db_auto_create', default=False),
]
]
CONF = cfg.CONF
CONF.register_opts(db_opts)

View File

@ -89,12 +89,14 @@ def upgrade(migrate_engine):
# which returns all the images that have a type set
# but that DO NOT yet have an image_property record
# with key of type.
sel = select([images], from_obj=[
from_stmt = [
images.outerjoin(image_properties,
and_(images.c.id == image_properties.c.image_id,
image_properties.c.key == 'type'))]).where(
and_(image_properties.c.image_id == None,
images.c.type != None))
image_properties.c.key == 'type'))
]
and_stmt = and_(image_properties.c.image_id == None,
images.c.type != None)
sel = select([images], from_obj=from_stmt).where(and_stmt)
image_records = conn.execute(sel).fetchall()
property_insert = image_properties.insert()
for record in image_records:

View File

@ -104,14 +104,12 @@ def legacy_parse_uri(self, uri):
# swift://user:pass@http://authurl.com/v1/container/obj
# are immediately rejected.
if uri.count('://') != 1:
reason = _(
"URI cannot contain more than one occurrence of a scheme."
"If you have specified a URI like "
"swift://user:pass@http://authurl.com/v1/container/obj"
", you need to change it to use the swift+http:// scheme, "
"like so: "
"swift+http://user:pass@authurl.com/v1/container/obj"
)
reason = _("URI cannot contain more than one occurrence of a scheme."
"If you have specified a URI like "
"swift://user:pass@http://authurl.com/v1/container/obj"
", you need to change it to use the swift+http:// scheme, "
"like so: "
"swift+http://user:pass@authurl.com/v1/container/obj")
LOG.error(_("Invalid store uri %(uri)s: %(reason)s") % locals())
raise exception.BadStoreUri(message=reason)

View File

@ -34,7 +34,7 @@ image_cache_opts = [
cfg.IntOpt('image_cache_max_size', default=10 * (1024 ** 3)), # 10 GB
cfg.IntOpt('image_cache_stall_time', default=86400), # 24 hours
cfg.StrOpt('image_cache_dir'),
]
]
CONF = cfg.CONF
CONF.register_opts(image_cache_opts)

View File

@ -37,7 +37,7 @@ LOG = logging.getLogger(__name__)
sqlite_opts = [
cfg.StrOpt('image_cache_sqlite_db', default='cache.db'),
]
]
CONF = cfg.CONF
CONF.register_opts(sqlite_opts)

View File

@ -27,7 +27,7 @@ from glance.openstack.common import timeutils
notifier_opts = [
cfg.StrOpt('notifier_strategy', default='default')
]
]
CONF = cfg.CONF
CONF.register_opts(notifier_opts)

View File

@ -39,7 +39,7 @@ rabbit_opts = [
cfg.StrOpt('rabbit_max_retries', default=0),
cfg.StrOpt('rabbit_retry_backoff', default=2),
cfg.StrOpt('rabbit_retry_max_backoff', default=30)
]
]
CONF = cfg.CONF
CONF.register_opts(rabbit_opts)

View File

@ -70,7 +70,7 @@ qpid_opts = [
cfg.BoolOpt('qpid_tcp_nodelay',
default=True,
help='Disable Nagle algorithm'),
]
]
CONF = cfg.CONF
CONF.register_opts(qpid_opts)

View File

@ -31,14 +31,14 @@ LOG = logging.getLogger(__name__)
registry_addr_opts = [
cfg.StrOpt('registry_host', default='0.0.0.0'),
cfg.IntOpt('registry_port', default=9191),
]
]
registry_client_opts = [
cfg.StrOpt('registry_client_protocol', default='http'),
cfg.StrOpt('registry_client_key_file'),
cfg.StrOpt('registry_client_cert_file'),
cfg.StrOpt('registry_client_ca_file'),
cfg.StrOpt('metadata_encryption_key', secret=True),
]
]
registry_client_ctx_opts = [
cfg.StrOpt('admin_user', secret=True),
cfg.StrOpt('admin_password', secret=True),
@ -46,7 +46,7 @@ registry_client_ctx_opts = [
cfg.StrOpt('auth_url'),
cfg.StrOpt('auth_strategy', default='noauth'),
cfg.StrOpt('auth_region'),
]
]
CONF = cfg.CONF
CONF.register_opts(registry_addr_opts)
@ -85,7 +85,7 @@ def configure_registry_client():
'key_file': CONF.registry_client_key_file,
'cert_file': CONF.registry_client_cert_file,
'ca_file': CONF.registry_client_ca_file
}
}
def configure_registry_admin_creds():

View File

@ -40,7 +40,7 @@ store_opts = [
default='/var/lib/glance/scrubber'),
cfg.BoolOpt('delayed_delete', default=False),
cfg.IntOpt('scrub_time', default=0),
]
]
CONF = cfg.CONF
CONF.register_opts(store_opts)

View File

@ -51,7 +51,7 @@ rbd_opts = [
cfg.StrOpt('rbd_store_pool', default=DEFAULT_POOL),
cfg.StrOpt('rbd_store_user', default=DEFAULT_USER),
cfg.StrOpt('rbd_store_ceph_conf', default=DEFAULT_CONFFILE),
]
]
CONF = cfg.CONF
CONF.register_opts(rbd_opts)
@ -196,11 +196,11 @@ class Store(glance.store.base.Store):
librbd.create(ioctx, name, size, order, old_format=False,
features=rbd.RBD_FEATURE_LAYERING)
return StoreLocation({
'fsid': fsid,
'pool': self.pool,
'image': name,
'snapshot': DEFAULT_SNAPNAME,
})
'fsid': fsid,
'pool': self.pool,
'image': name,
'snapshot': DEFAULT_SNAPNAME,
})
else:
librbd.create(ioctx, name, size, order, old_format=True)
return StoreLocation({'image': name})

View File

@ -41,7 +41,7 @@ s3_opts = [
cfg.StrOpt('s3_store_object_buffer_dir'),
cfg.BoolOpt('s3_store_create_bucket_on_put', default=False),
cfg.StrOpt('s3_store_bucket_url_format', default='subdomain'),
]
]
CONF = cfg.CONF
CONF.register_opts(s3_opts)
@ -102,16 +102,14 @@ class StoreLocation(glance.store.location.StoreLocation):
# s3://accesskey:secretkey@https://s3.amazonaws.com/bucket/key-id
# are immediately rejected.
if uri.count('://') != 1:
reason = _(
"URI cannot contain more than one occurrence of a scheme."
"If you have specified a URI like "
"s3://accesskey:secretkey@https://s3.amazonaws.com/bucket/"
"key-id"
", you need to change it to use the s3+https:// scheme, "
"like so: "
"s3+https://accesskey:secretkey@s3.amazonaws.com/bucket/"
"key-id"
)
reason = _("URI cannot contain more than one occurrence "
"of a scheme. If you have specified a URI like "
"s3://accesskey:secretkey@"
"https://s3.amazonaws.com/bucket/key-id"
", you need to change it to use the "
"s3+https:// scheme, like so: "
"s3+https://accesskey:secretkey@"
"s3.amazonaws.com/bucket/key-id")
LOG.error(_("Invalid store uri %(uri)s: %(reason)s") % locals())
raise exception.BadStoreUri(message=reason)

View File

@ -36,7 +36,7 @@ LOG = logging.getLogger(__name__)
scrubber_opts = [
cfg.BoolOpt('cleanup_scrubber', default=False),
cfg.IntOpt('cleanup_scrubber_time', default=86400)
]
]
CONF = cfg.CONF
CONF.register_opts(scrubber_opts)

View File

@ -61,7 +61,7 @@ swift_opts = [
cfg.BoolOpt('swift_store_create_container_on_put', default=False),
cfg.BoolOpt('swift_store_multi_tenant', default=False),
cfg.ListOpt('swift_store_admin_tenants', default=[]),
]
]
CONF = cfg.CONF
CONF.register_opts(swift_opts)
@ -128,14 +128,12 @@ class StoreLocation(glance.store.location.StoreLocation):
# swift://user:pass@http://authurl.com/v1/container/obj
# are immediately rejected.
if uri.count('://') != 1:
reason = _(
"URI cannot contain more than one occurrence of a scheme."
"If you have specified a URI like "
"swift://user:pass@http://authurl.com/v1/container/obj"
", you need to change it to use the swift+http:// scheme, "
"like so: "
"swift+http://user:pass@authurl.com/v1/container/obj"
)
reason = _("URI cannot contain more than one occurrence "
"of a scheme. If you have specified a URI like "
"swift://user:pass@http://authurl.com/v1/container/obj"
", you need to change it to use the "
"swift+http:// scheme, like so: "
"swift+http://user:pass@authurl.com/v1/container/obj")
LOG.error(_("Invalid store uri %(uri)s: %(reason)s") % locals())
raise exception.BadStoreUri(message=reason)

View File

@ -78,7 +78,7 @@ class V2Token(object):
"adminURL": "http://localhost:9292",
"internalURL": "http://localhost:9292",
"publicURL": "http://localhost:9292"
}
}
@property
def base_token(self):

View File

@ -341,23 +341,21 @@ class TestMigrations(utils.BaseTestCase):
unquoted_locations = [
'swift://acct:usr:pass@example.com/container/obj-id',
'file://foo',
]
]
quoted_locations = [
'swift://acct%3Ausr:pass@example.com/container/obj-id',
'file://foo',
]
]
# Insert images with an unquoted image location
now = datetime.datetime.now()
kwargs = dict(
deleted=False,
created_at=now,
updated_at=now,
status='active',
is_public=True,
min_disk=0,
min_ram=0,
)
kwargs = dict(deleted=False,
created_at=now,
updated_at=now,
status='active',
is_public=True,
min_disk=0,
min_ram=0)
for i, location in enumerate(unquoted_locations):
kwargs.update(location=location, id=i)
conn.execute(images_table.insert(), [kwargs])

View File

@ -53,7 +53,7 @@ class TestStoreLocation(base.StoreClearingUnitTest):
'rbd://imagename',
'rbd://fsid/pool/image/snap',
'rbd://%2F/%2F/%2F/%2F',
]
]
for uri in good_store_uris:
loc = location.get_location_from_uri(uri)

View File

@ -236,8 +236,8 @@ class SwiftTests(object):
http:// in the swift_store_auth_address config value
"""
loc = get_location_from_uri("swift+http://%s:key@auth_address/"
"glance/%s" % (
self.swift_store_user, FAKE_UUID))
"glance/%s" %
(self.swift_store_user, FAKE_UUID))
(image_swift, image_size) = self.store.get(loc)
self.assertEqual(image_size, 5120)

View File

@ -40,11 +40,11 @@ def get_fake_request(path='', method='POST', is_admin=False, user=USER1):
req.method = method
kwargs = {
'user': user,
'tenant': TENANT1,
'roles': [],
'is_admin': is_admin,
}
'user': user,
'tenant': TENANT1,
'roles': [],
'is_admin': is_admin,
}
req.context = glance.context.RequestContext(**kwargs)

View File

@ -3270,7 +3270,7 @@ class TestImageSerializer(base.IsolatedUnitTest):
'receiver_tenant_id': self.receiving_tenant,
'receiver_user_id': self.receiving_user,
'destination_ip': '1.2.3.4',
}
}
def fake_info(_event_type, _payload):
self.assertEqual(_payload, expected_payload)
@ -3299,7 +3299,7 @@ class TestImageSerializer(base.IsolatedUnitTest):
'receiver_tenant_id': self.receiving_tenant,
'receiver_user_id': self.receiving_user,
'destination_ip': '1.2.3.4',
}
}
def fake_error(_event_type, _payload):
self.assertEqual(_payload, expected_payload)

View File

@ -18,7 +18,7 @@ downloadcache = ~/cache/pip
[testenv:pep8]
deps = pep8==1.3.3
commands = pep8 --ignore=E122,E123,E124,E125,E126,E127,E128,E711 --repeat --show-source --exclude=.venv,.tox,dist,doc,openstack .
commands = pep8 --ignore=E124,E125,E126,E127,E128,E711 --repeat --show-source --exclude=.venv,.tox,dist,doc,openstack .
[testenv:cover]
setenv = NOSE_WITH_COVERAGE=1