fix E122 and E126 flake8 issues

Simple indenting for clarity. E122 and E126 are generally pretty
reasonable and not pathologic, so make these cleanups so we can
start enforcing them.

Part of violetprint:travel-day-cleanups

Change-Id: Ie1ff8d31aab83b943784a34702cc5668add68a21
This commit is contained in:
Sean Dague 2013-04-14 15:34:30 -04:00
parent 2416cf3257
commit 14c6818df7
24 changed files with 117 additions and 116 deletions

View File

@ -261,7 +261,7 @@ def bash_openstack(manager,
state.delete_instance_state(kill_id)
for floating_ip_state in state.get_floating_ips():
manager.floating_ips_client.delete_floating_ip(
floating_ip_state.resource_id)
floating_ip_state.resource_id)
for keypair_state in state.get_keypairs():
manager.keypairs_client.delete_keypair(keypair_state.name)
for volume_state in state.get_volumes():

View File

@ -117,8 +117,8 @@ class Client(object):
ready = select.select(*select_params)
if not any(ready):
raise exceptions.TimeoutException(
"Command: '{0}' executed on host '{1}'.".format(
cmd, self.host))
"Command: '{0}' executed on host '{1}'.".format(
cmd, self.host))
if not ready[0]: # If there is nothing to read.
continue
out_chunk = err_chunk = None
@ -133,8 +133,8 @@ class Client(object):
exit_status = channel.recv_exit_status()
if 0 != exit_status:
raise exceptions.SSHExecCommandFailed(
command=cmd, exit_status=exit_status,
strerror=''.join(err_data))
command=cmd, exit_status=exit_status,
strerror=''.join(err_data))
return ''.join(out_data)
def test_connection_auth(self):

View File

@ -96,7 +96,7 @@ class BotoClientBase(object):
ec2_cred.secret
else:
raise exceptions.InvalidConfiguration(
"Unable to get access and secret keys")
"Unable to get access and secret keys")
return self.connect_method(**self.connection_data)

View File

@ -31,8 +31,8 @@ class SecurityGroupsClientXML(RestClientXML):
def __init__(self, config, username, password, auth_url, tenant_name=None):
super(SecurityGroupsClientXML, self).__init__(
config, username, password,
auth_url, tenant_name)
config, username, password,
auth_url, tenant_name)
self.service = self.config.compute.catalog_type
def _parse_array(self, node):

View File

@ -152,7 +152,7 @@ class IdentityClientJSON(RestClient):
def enable_disable_user(self, user_id, enabled):
"""Enables or disables a user."""
put_body = {
'enabled': enabled
'enabled': enabled
}
put_body = json.dumps({'user': put_body})
resp, body = self.put('users/%s/enabled' % user_id,

View File

@ -84,7 +84,7 @@ class SnapshotsClientJSON(RestClient):
# state in a "normal" lifecycle
if (status == 'error'):
raise exceptions.SnapshotBuildErrorException(
snapshot_id=snapshot_id)
snapshot_id=snapshot_id)
return status

View File

@ -93,7 +93,7 @@ class SnapshotsClientXML(RestClientXML):
# state in a "normal" lifecycle
if (status == 'error'):
raise exceptions.SnapshotBuildErrorException(
snapshot_id=snapshot_id)
snapshot_id=snapshot_id)
return status

View File

@ -443,7 +443,7 @@ class BotoTestCase(tempest.test.BaseTestCase):
return "_GONE"
except exception.EC2ResponseError as exc:
if cls.ec2_error_code.\
client.InvalidInstanceID.NotFound.match(exc):
client.InvalidInstanceID.NotFound.match(exc):
return "_GONE"
#NOTE(afazekas): incorrect code,
# but the resource must be destoreyd

View File

@ -73,8 +73,8 @@ class InstanceRunTest(BotoTestCase):
"location": cls.bucket_name + "/" + ari_manifest}}
for image in cls.images.itervalues():
image["image_id"] = cls.ec2_client.register_image(
name=image["name"],
image_location=image["location"])
name=image["name"],
image_location=image["location"])
cls.addResourceCleanUp(cls.ec2_client.deregister_image,
image["image_id"])
@ -151,13 +151,15 @@ class InstanceRunTest(BotoTestCase):
group_desc)
self.addResourceCleanUp(self.destroy_security_group_wait,
security_group)
self.assertTrue(self.ec2_client.authorize_security_group(
self.assertTrue(
self.ec2_client.authorize_security_group(
sec_group_name,
ip_protocol="icmp",
cidr_ip="0.0.0.0/0",
from_port=-1,
to_port=-1))
self.assertTrue(self.ec2_client.authorize_security_group(
self.assertTrue(
self.ec2_client.authorize_security_group(
sec_group_name,
ip_protocol="tcp",
cidr_ip="0.0.0.0/0",

View File

@ -63,12 +63,12 @@ class S3ImagesTest(BotoTestCase):
"location": self.bucket_name + "/" + self.ami_manifest,
"type": "ami"}
image["image_id"] = self.images_client.register_image(
name=image["name"],
image_location=image["location"])
name=image["name"],
image_location=image["location"])
#Note(afazekas): delete_snapshot=True might trigger boto lib? bug
image["cleanUp"] = self.addResourceCleanUp(
self.images_client.deregister_image,
image["image_id"])
self.images_client.deregister_image,
image["image_id"])
self.assertEqual(image["image_id"][0:3], image["type"])
retrieved_image = self.images_client.get_image(image["image_id"])
self.assertTrue(retrieved_image.name == image["name"])
@ -90,11 +90,11 @@ class S3ImagesTest(BotoTestCase):
"location": self.bucket_name + "/" + self.ari_manifest,
"type": "aki"}
image["image_id"] = self.images_client.register_image(
name=image["name"],
image_location=image["location"])
name=image["name"],
image_location=image["location"])
image["cleanUp"] = self.addResourceCleanUp(
self.images_client.deregister_image,
image["image_id"])
self.images_client.deregister_image,
image["image_id"])
self.assertEqual(image["image_id"][0:3], image["type"])
retrieved_image = self.images_client.get_image(image["image_id"])
self.assertTrue(retrieved_image.name == image["name"])
@ -115,11 +115,11 @@ class S3ImagesTest(BotoTestCase):
"location": "/" + self.bucket_name + "/" + self.ari_manifest,
"type": "ari"}
image["image_id"] = self.images_client.register_image(
name=image["name"],
image_location=image["location"])
name=image["name"],
image_location=image["location"])
image["cleanUp"] = self.addResourceCleanUp(
self.images_client.deregister_image,
image["image_id"])
self.images_client.deregister_image,
image["image_id"])
self.assertEqual(image["image_id"][0:3], image["type"])
retrieved_image = self.images_client.get_image(image["image_id"])
self.assertIn(retrieved_image.state, self.valid_image_state)

View File

@ -92,9 +92,9 @@ class FlavorsExtraSpecsTestJSON(base.BaseComputeAdminTest):
def test_flavor_non_admin_get_keys(self):
specs = {"key1": "value1", "key2": "value2"}
set_resp, set_body = self.client.set_flavor_extra_spec(
self.flavor['id'], specs)
self.flavor['id'], specs)
resp, body = self.flavors_client.get_flavor_extra_spec(
self.flavor['id'])
self.flavor['id'])
self.assertEqual(resp.status, 200)
for key in specs:
self.assertEquals(body[key], specs[key])
@ -103,7 +103,7 @@ class FlavorsExtraSpecsTestJSON(base.BaseComputeAdminTest):
def test_flavor_non_admin_unset_keys(self):
specs = {"key1": "value1", "key2": "value2"}
set_resp, set_body = self.client.set_flavor_extra_spec(
self.flavor['id'], specs)
self.flavor['id'], specs)
self.assertRaises(exceptions.Unauthorized,
self.flavors_client.unset_flavor_extra_spec,

View File

@ -102,14 +102,14 @@ class FloatingIPsTestJSON(base.BaseComputeTest):
# to a specific server should be successful
#Association of floating IP to fixed IP address
resp, body =\
self.client.associate_floating_ip_to_server(self.floating_ip,
self.server_id)
resp, body = self.client.associate_floating_ip_to_server(
self.floating_ip,
self.server_id)
self.assertEqual(202, resp.status)
#Disassociation of floating IP that was associated in this method
resp, body = \
self.client.disassociate_floating_ip_from_server(self.floating_ip,
self.server_id)
resp, body = self.client.disassociate_floating_ip_from_server(
self.floating_ip,
self.server_id)
self.assertEqual(202, resp.status)
@attr(type='negative')
@ -150,13 +150,13 @@ class FloatingIPsTestJSON(base.BaseComputeTest):
self.new_server_id = body['id']
#Associating floating IP for the first time
resp, _ = \
self.client.associate_floating_ip_to_server(self.floating_ip,
self.server_id)
resp, _ = self.client.associate_floating_ip_to_server(
self.floating_ip,
self.server_id)
#Associating floating IP for the second time
resp, body = \
self.client.associate_floating_ip_to_server(self.floating_ip,
self.new_server_id)
resp, body = self.client.associate_floating_ip_to_server(
self.floating_ip,
self.new_server_id)
self.addCleanup(self.servers_client.delete_server, self.new_server_id)
if (resp['status'] is not None):

View File

@ -57,7 +57,7 @@ class TestServerAdvancedOps(test.DefaultClientSmokeTest):
flavor_id = self.config.compute.flavor_ref
base_image_id = self.config.compute.image_ref
self.instance = self.compute_client.servers.create(
i_name, base_image_id, flavor_id)
i_name, base_image_id, flavor_id)
try:
self.assertEqual(self.instance.name, i_name)
self.set_resource('instance', self.instance)

View File

@ -78,7 +78,7 @@ class TestServerBasicOps(test.DefaultClientSmokeTest):
for ruleset in rulesets:
try:
self.compute_client.security_group_rules.create(
self.secgroup.id, **ruleset)
self.secgroup.id, **ruleset)
except Exception:
self.fail("Failed to create rule in security group.")
@ -90,7 +90,7 @@ class TestServerBasicOps(test.DefaultClientSmokeTest):
'key_name': self.get_resource('keypair').id
}
self.instance = self.compute_client.servers.create(
i_name, base_image_id, flavor_id, **create_kwargs)
i_name, base_image_id, flavor_id, **create_kwargs)
try:
self.assertEqual(self.instance.name, i_name)
self.set_resource('instance', self.instance)

View File

@ -43,25 +43,25 @@ class ServerRescueTestJSON(base.BaseComputeTest):
cls.sg_name = rand_name('sg')
cls.sg_desc = rand_name('sg-desc')
resp, cls.sg = \
cls.security_groups_client.create_security_group(cls.sg_name,
cls.sg_desc)
cls.security_groups_client.create_security_group(cls.sg_name,
cls.sg_desc)
cls.sg_id = cls.sg['id']
# Create a volume and wait for it to become ready for attach
resp, cls.volume_to_attach = \
cls.volumes_extensions_client.create_volume(1,
display_name=
'test_attach')
cls.volumes_extensions_client.create_volume(1,
display_name=
'test_attach')
cls.volumes_extensions_client.wait_for_volume_status(
cls.volume_to_attach['id'], 'available')
cls.volume_to_attach['id'], 'available')
# Create a volume and wait for it to become ready for attach
resp, cls.volume_to_detach = \
cls.volumes_extensions_client.create_volume(1,
display_name=
'test_detach')
cls.volumes_extensions_client.create_volume(1,
display_name=
'test_detach')
cls.volumes_extensions_client.wait_for_volume_status(
cls.volume_to_detach['id'], 'available')
cls.volume_to_detach['id'], 'available')
# Server for positive tests
resp, server = cls.create_server(image_id=cls.image_ref,
@ -93,8 +93,8 @@ class ServerRescueTestJSON(base.BaseComputeTest):
client = cls.volumes_extensions_client
client.delete_volume(str(cls.volume_to_attach['id']).strip())
client.delete_volume(str(cls.volume_to_detach['id']).strip())
resp, cls.sg = \
cls.security_groups_client.delete_security_group(cls.sg_id)
resp, cls.sg = cls.security_groups_client.delete_security_group(
cls.sg_id)
def tearDown(self):
super(ServerRescueTestJSON, self).tearDown()
@ -155,7 +155,7 @@ class ServerRescueTestJSON(base.BaseComputeTest):
self.volume_to_detach['id'],
device='/dev/%s' % self.device)
self.volumes_extensions_client.wait_for_volume_status(
self.volume_to_detach['id'], 'in-use')
self.volume_to_detach['id'], 'in-use')
# Rescue the server
self.servers_client.rescue_server(self.server_id, self.password)
@ -181,9 +181,8 @@ class ServerRescueTestJSON(base.BaseComputeTest):
#Association of floating IP to a rescued vm
client = self.floating_ips_client
resp, body =\
client.associate_floating_ip_to_server(self.floating_ip,
self.server_id)
resp, body = client.associate_floating_ip_to_server(self.floating_ip,
self.server_id)
self.assertEqual(202, resp.status)
#Disassociation of floating IP that was associated in this method

View File

@ -55,9 +55,9 @@ class ServersWhiteboxTest(whitebox.ComputeWhiteboxTest):
def test_create_server_vcpu_quota_full(self):
# Disallow server creation when tenant's vcpu quota is full
quotas = self.meta.tables['quotas']
stmt = quotas.select().where(
quotas.c.project_id == self.tenant_id).where(
quotas.c.resource == 'cores')
stmt = (quotas.select().
where(quotas.c.project_id == self.tenant_id).
where(quotas.c.resource == 'cores'))
result = self.connection.execute(stmt).first()
# Set vcpu quota for tenant if not already set
@ -87,9 +87,9 @@ class ServersWhiteboxTest(whitebox.ComputeWhiteboxTest):
def test_create_server_memory_quota_full(self):
# Disallow server creation when tenant's memory quota is full
quotas = self.meta.tables['quotas']
stmt = quotas.select().where(
quotas.c.project_id == self.tenant_id).where(
quotas.c.resource == 'ram')
stmt = (quotas.select().
where(quotas.c.project_id == self.tenant_id).
where(quotas.c.resource == 'ram'))
result = self.connection.execute(stmt).first()
# Set memory quota for tenant if not already set

View File

@ -89,9 +89,9 @@ class CreateRegisterImagesTest(base.BaseV1ImageTest):
self.addCleanup(container_client.delete_container, container_name)
cont_headers = {'X-Container-Read': '.r:*'}
resp, _ = container_client.update_container_metadata(
container_name,
metadata=cont_headers,
metadata_prefix='')
container_name,
metadata=cont_headers,
metadata_prefix='')
self.assertEqual(resp['status'], '204')
data = "TESTIMAGE"
@ -270,7 +270,7 @@ class ListImagesTest(base.BaseV1ImageTest):
@attr(type='image')
def test_index_name(self):
resp, images_list = self.client.image_list_detail(
name='New Remote Image dup')
name='New Remote Image dup')
self.assertEqual(resp['status'], '200')
result_set = set(map(lambda x: x['id'], images_list))
for image in images_list:

View File

@ -124,7 +124,7 @@ class ContainerTest(base.BaseObjectTest):
# List container metadata
resp, _ = self.container_client.list_container_metadata(
container_name)
container_name)
self.assertEqual(resp['status'], '204')
self.assertIn('x-container-meta-name', resp)
self.assertIn('x-container-meta-description', resp)
@ -132,10 +132,9 @@ class ContainerTest(base.BaseObjectTest):
self.assertEqual(resp['x-container-meta-description'], 'Travel')
# Delete container metadata
resp, _ = \
self.container_client.delete_container_metadata(
container_name,
metadata=metadata.keys())
resp, _ = self.container_client.delete_container_metadata(
container_name,
metadata=metadata.keys())
self.assertEqual(resp['status'], '204')
resp, _ = self.container_client.list_container_metadata(container_name)

View File

@ -59,7 +59,7 @@ class ContainerTest(base.BaseObjectTest):
# Create a containers
vers_container_name = rand_name(name='TestVersionContainer')
resp, body = self.container_client.create_container(
vers_container_name)
vers_container_name)
self.containers.append(vers_container_name)
self.assertIn(resp['status'], ('202', '201'))
self.assertContainer(vers_container_name, '0', '0',
@ -68,9 +68,9 @@ class ContainerTest(base.BaseObjectTest):
base_container_name = rand_name(name='TestBaseContainer')
headers = {'X-versions-Location': vers_container_name}
resp, body = self.container_client.create_container(
base_container_name,
metadata=headers,
metadata_prefix='')
base_container_name,
metadata=headers,
metadata_prefix='')
self.containers.append(base_container_name)
self.assertIn(resp['status'], ('202', '201'))
self.assertContainer(base_container_name, '0', '0',

View File

@ -55,15 +55,15 @@ class VolumeTypesTest(BaseVolumeTest):
extra_specs = {"storage_protocol": "iSCSI",
"vendor_name": "Open Source"}
body = {}
resp, body = self.client.create_volume_type(vol_type_name,
extra_specs=
extra_specs)
resp, body = self.client.create_volume_type(
vol_type_name,
extra_specs=extra_specs)
self.assertEqual(200, resp.status)
self.assertTrue('id' in body)
self.assertTrue('name' in body)
resp, volume = self.volumes_client.\
create_volume(size=1, display_name=vol_name,
volume_type=vol_type_name)
resp, volume = self.volumes_client.create_volume(
size=1, display_name=vol_name,
volume_type=vol_type_name)
self.assertEqual(200, resp.status)
self.assertTrue('id' in volume)
self.assertTrue('display_name' in volume)
@ -74,8 +74,7 @@ class VolumeTypesTest(BaseVolumeTest):
"Field volume id is empty or not found.")
self.volumes_client.wait_for_volume_status(volume['id'],
'available')
resp, fetched_volume = self.volumes_client.\
get_volume(volume['id'])
resp, fetched_volume = self.volumes_client.get_volume(volume['id'])
self.assertEqual(200, resp.status)
self.assertEqual(vol_name, fetched_volume['display_name'],
'The fetched Volume is different '
@ -104,8 +103,9 @@ class VolumeTypesTest(BaseVolumeTest):
name = rand_name("volume-type-")
extra_specs = {"storage_protocol": "iSCSI",
"vendor_name": "Open Source"}
resp, body = self.client.\
create_volume_type(name, extra_specs=extra_specs)
resp, body = self.client.create_volume_type(
name,
extra_specs=extra_specs)
self.assertEqual(200, resp.status)
self.assertTrue('id' in body)
self.assertTrue('name' in body)
@ -114,8 +114,7 @@ class VolumeTypesTest(BaseVolumeTest):
"to the requested name")
self.assertTrue(body['id'] is not None,
"Field volume_type id is empty or not found.")
resp, fetched_volume_type = self.client.\
delete_volume_type(body['id'])
resp, _ = self.client.delete_volume_type(body['id'])
self.assertEqual(202, resp.status)
except Exception:
self.fail("Could not create a volume_type")
@ -127,8 +126,9 @@ class VolumeTypesTest(BaseVolumeTest):
name = rand_name("volume-type-")
extra_specs = {"storage_protocol": "iSCSI",
"vendor_name": "Open Source"}
resp, body = self.client.\
create_volume_type(name, extra_specs=extra_specs)
resp, body = self.client.create_volume_type(
name,
extra_specs=extra_specs)
self.assertEqual(200, resp.status)
self.assertTrue('id' in body)
self.assertTrue('name' in body)

View File

@ -37,13 +37,13 @@ class VolumeTypesExtraSpecsTest(base.BaseVolumeAdminTest):
# List Volume types extra specs.
try:
extra_specs = {"spec1": "val1"}
resp, body = self.client.\
create_volume_type_extra_specs(self.volume_type['id'], extra_specs)
resp, body = self.client.create_volume_type_extra_specs(
self.volume_type['id'], extra_specs)
self.assertEqual(200, resp.status)
self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly created")
resp, body = self.client.\
list_volume_types_extra_specs(self.volume_type['id'])
resp, body = self.client.list_volume_types_extra_specs(
self.volume_type['id'])
self.assertEqual(200, resp.status)
self.assertTrue(type(body), dict)
self.assertTrue('spec1' in body, "Incorrect volume type extra"
@ -55,17 +55,17 @@ class VolumeTypesExtraSpecsTest(base.BaseVolumeAdminTest):
# Update volume type extra specs
try:
extra_specs = {"spec2": "val1"}
resp, body = self.client.\
create_volume_type_extra_specs(self.volume_type['id'], extra_specs)
resp, body = self.client.create_volume_type_extra_specs(
self.volume_type['id'], extra_specs)
self.assertEqual(200, resp.status)
self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly created")
extra_spec = {"spec2": "val2"}
resp, body = self.client.\
update_volume_type_extra_specs(self.volume_type['id'],
extra_spec.keys()[0],
extra_spec)
resp, body = self.client.update_volume_type_extra_specs(
self.volume_type['id'],
extra_spec.keys()[0],
extra_spec)
self.assertEqual(200, resp.status)
self.assertTrue('spec2' in body,
"Volume type extra spec incorrectly updated")
@ -78,22 +78,23 @@ class VolumeTypesExtraSpecsTest(base.BaseVolumeAdminTest):
# Create/Get/Delete volume type extra spec.
try:
extra_specs = {"spec3": "val1"}
resp, body = self.client.\
create_volume_type_extra_specs(self.volume_type['id'], extra_specs)
resp, body = self.client.create_volume_type_extra_specs(
self.volume_type['id'],
extra_specs)
self.assertEqual(200, resp.status)
self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly created")
resp, fetched_vol_type_extra_spec = self.client.\
get_volume_type_extra_specs(self.volume_type['id'],
extra_specs.keys()[0])
resp, _ = self.client.get_volume_type_extra_specs(
self.volume_type['id'],
extra_specs.keys()[0])
self.assertEqual(200, resp.status)
self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly fetched")
resp, _ = self.client.\
delete_volume_type_extra_specs(self.volume_type['id'],
extra_specs.keys()[0])
resp, _ = self.client.delete_volume_type_extra_specs(
self.volume_type['id'],
extra_specs.keys()[0])
self.assertEqual(202, resp.status)
except Exception:
self.fail("Could not create a volume_type extra spec")

View File

@ -111,7 +111,7 @@ class ComputeWhiteboxTest(test.ComputeFuzzClientTest, WhiteboxTest):
image_id = cls.image_ref
resp, server = cls.servers_client.create_server(
server_name, image_id, flavor)
server_name, image_id, flavor)
cls.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
cls.servers.append(server)
return server

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
flake8 --ignore=E122,E125,E126,H302,H304,H404,F --show-source --exclude=.git,.venv,.tox,dist,doc,openstack,*egg .
flake8 --ignore=E125,H302,H304,H404,F --show-source --exclude=.git,.venv,.tox,dist,doc,openstack,*egg .
pep8_ret=$?
pyflakes tempest stress setup.py tools cli bin | grep "imported but unused"

View File

@ -165,7 +165,7 @@ def main(argv):
resp, body = coverage_client.report_coverage_xml(file=CLI.filename)
elif CLI.html:
resp, body = coverage_client.report_coverage_html(
file=CLI.filename)
file=CLI.filename)
else:
resp, body = coverage_client.report_coverage(file=CLI.filename)
if not resp['status'] == '200':