Fix the final PEP8 errors

Fix PEP8 E126,E127,E128 errors, which were the only ones remaining.

Fix PEP8 errors:
E126: continuation line over-indented for hanging indent
E127: continuation line over-indented for visual indent
E128: continuation line under-indented for visual indent

Remove the ignore= entries for flake8 in tox.ini

Change-Id: I919551121d85d2aab528f4fa5ecdb3cfd940557a
This commit is contained in:
John L. Villalovos 2015-03-10 14:07:06 -07:00
parent d76862b186
commit 144e82b163
19 changed files with 132 additions and 134 deletions

@ -24,7 +24,7 @@ from ironicclient import exc as exceptions
__version__ = pbr.version.VersionInfo('python-ironicclient').version_string()
__all__ = [
'client',
'exc',
'exceptions',
'client',
'exc',
'exceptions',
]

@ -94,7 +94,7 @@ def get_client(api_version, **kwargs):
ks_kwargs['region_name'] = kwargs.get('os_region_name')
endpoint = (kwargs.get('ironic_url') or
_get_endpoint(_ksclient, **ks_kwargs))
_get_endpoint(_ksclient, **ks_kwargs))
auth_ref = _ksclient.auth_ref

@ -237,8 +237,8 @@ class VerifiedHTTPSConnection(six.moves.http_client.HTTPSConnection):
def __init__(self, host, port, key_file=None, cert_file=None,
ca_file=None, timeout=None, insecure=False):
six.moves.http_client.HTTPSConnection.__init__(self, host, port,
key_file=key_file,
cert_file=cert_file)
key_file=key_file,
cert_file=cert_file)
self.key_file = key_file
self.cert_file = cert_file
if ca_file is not None:
@ -311,7 +311,7 @@ class SessionClient(adapter.LegacyJsonAdapter):
if 400 <= resp.status_code < 600:
error_json = _extract_error_json(resp.content)
raise exc.from_response(resp, error_json.get('faultstring'),
error_json.get('debuginfo'), method, url)
error_json.get('debuginfo'), method, url)
elif resp.status_code in (301, 302, 305):
# Redirected. Reissue the request to the new location.
location = resp.headers.get('location')

@ -213,7 +213,7 @@ class IronicShell(object):
'Defaults to env[OS_SERVICE_ENDPOINT].')
parser.add_argument('--os_endpoint',
help=argparse.SUPPRESS)
help=argparse.SUPPRESS)
parser.add_argument('--os-endpoint-type',
default=cliutils.env('OS_ENDPOINT_TYPE'),
@ -250,8 +250,8 @@ class IronicShell(object):
httplib2.debuglevel = 1
else:
logging.basicConfig(
format="%(levelname)s %(message)s",
level=logging.CRITICAL)
format="%(levelname)s %(message)s",
level=logging.CRITICAL)
def do_bash_completion(self):
"""Prints all of the commands and options for bash-completion."""
@ -306,10 +306,11 @@ class IronicShell(object):
auth_token = kwargs.pop('auth_token', None)
if auth_token:
return v2_auth.Token(v2_auth_url, auth_token,
tenant_id=kwargs.pop('project_id', None),
tenant_name=kwargs.pop('project_name', None))
tenant_id=kwargs.pop('project_id', None),
tenant_name=kwargs.pop('project_name', None))
else:
return v2_auth.Password(v2_auth_url,
return v2_auth.Password(
v2_auth_url,
username=kwargs.pop('username', None),
password=kwargs.pop('password', None),
tenant_id=kwargs.pop('project_id', None),
@ -432,10 +433,11 @@ class IronicShell(object):
if not (args.os_tenant_id or args.os_tenant_name or
args.os_project_id or args.os_project_name):
raise exc.CommandError(_("You must provide a project name or"
" project id via --os-project-name, --os-project-id,"
" env[OS_PROJECT_ID] or env[OS_PROJECT_NAME]. You may"
" use os-project and os-tenant interchangeably."))
raise exc.CommandError(
_("You must provide a project name or"
" project id via --os-project-name, --os-project-id,"
" env[OS_PROJECT_ID] or env[OS_PROJECT_NAME]. You may"
" use os-project and os-tenant interchangeably."))
if not args.os_auth_url:
raise exc.CommandError(_("You must provide an auth url via "

@ -49,7 +49,7 @@ class TestIronicClient(testtools.TestCase):
conf_settings = ['api_version']
if auth_strategy == 'keystone':
conf_settings += ['os_auth_url', 'os_username',
'os_password', 'os_tenant_name']
'os_password', 'os_tenant_name']
else:
conf_settings += ['os_auth_token', 'ironic_url']

@ -96,7 +96,7 @@ class HttpClientTest(utils.BaseTestCase):
def test_server_exception_msg_and_traceback(self):
error_msg = 'another test error'
error_trace = ("\"Traceback (most recent call last):\\n\\n "
"File \\\"/usr/local/lib/python2.7/...")
"File \\\"/usr/local/lib/python2.7/...")
error_body = _get_error_body(error_msg, error_trace)
fake_resp = utils.FakeResponse({'content-type': 'application/json'},
six.StringIO(error_body),
@ -227,7 +227,7 @@ class HttpClientTest(utils.BaseTestCase):
status=401)
client = http.HTTPClient('http://localhost/')
client.get_connection = (
lambda *a, **kw: utils.FakeConnection(fake_resp))
lambda *a, **kw: utils.FakeConnection(fake_resp))
self.assertRaises(exc.Unauthorized, client.json_request,
'GET', '/v1/resources')
@ -238,12 +238,12 @@ class SessionClientTest(utils.BaseTestCase):
def test_server_exception_msg_and_traceback(self):
error_msg = 'another test error'
error_trace = ("\"Traceback (most recent call last):\\n\\n "
"File \\\"/usr/local/lib/python2.7/...")
"File \\\"/usr/local/lib/python2.7/...")
error_body = _get_error_body(error_msg, error_trace)
fake_session = utils.FakeSession({'Content-Type': 'application/json'},
error_body,
500)
error_body,
500)
client = http.SessionClient(session=fake_session,
auth=None,
@ -266,8 +266,8 @@ class SessionClientTest(utils.BaseTestCase):
error_body = _get_error_body()
fake_session = utils.FakeSession({'Content-Type': 'application/json'},
error_body,
500)
error_body,
500)
client = http.SessionClient(session=fake_session,
auth=None,

@ -127,7 +127,7 @@ class ShellTest(utils.BaseTestCase):
self.make_env(exclude='OS_PASSWORD')
# We will get a Connection Refused because there is no keystone.
self.assertRaises(keystone_exc.ConnectionRefused,
self.shell, 'node-list')
self.shell, 'node-list')
# Make sure we are actually prompted.
mock_getpass.assert_called_with('OpenStack Password: ')
@ -137,7 +137,7 @@ class ShellTest(utils.BaseTestCase):
self.make_env(exclude='OS_PASSWORD')
# We should get Command Error because we mock Ctl-D.
self.assertRaises(exc.CommandError,
self.shell, 'node-list')
self.shell, 'node-list')
# Make sure we are actually prompted.
mock_getpass.assert_called_with('OpenStack Password: ')
@ -174,7 +174,7 @@ class ShellTest(utils.BaseTestCase):
self.shell('--ironic-api-version 1.2 help')
self.shell('--ironic-api-version latest help')
self.assertRaises(exc.CommandError,
self.shell, '--ironic-api-version 1.2.1 help')
self.shell, '--ironic-api-version 1.2.1 help')
class TestCase(testtools.TestCase):

@ -119,7 +119,7 @@ class FakeKeystone():
self.auth_token = auth_token
self.auth_ref = {
'token': {'expires': FakeKeystone.timestamp.strftime(
'%Y-%m-%dT%H:%M:%S.%f'),
'%Y-%m-%dT%H:%M:%S.%f'),
'id': 'd1a541311782870742235'}
}
@ -141,4 +141,4 @@ class FakeSession():
def request(self, url, method, **kwargs):
return FakeSessionResponse(self.headers, self.content,
self.status_code)
self.status_code)

@ -29,9 +29,9 @@ CHASSIS = {'id': 42,
'description': 'data-center-1-chassis'}
CHASSIS2 = {'id': 43,
'uuid': 'eeeeeeee-dddd-cccc-bbbb-aaaaaaaaaaaa',
'extra': {},
'description': 'data-center-1-chassis'}
'uuid': 'eeeeeeee-dddd-cccc-bbbb-aaaaaaaaaaaa',
'extra': {},
'description': 'data-center-1-chassis'}
NODE = {'id': 123,

@ -96,10 +96,10 @@ class DriverManagerTest(testtools.TestCase):
# anything to verify.
vendor_passthru_args = {'arg1': 'val1'}
kwargs = {
'driver_name': 'driver_name',
'method': 'method',
'args': vendor_passthru_args
}
'driver_name': 'driver_name',
'method': 'method',
'args': vendor_passthru_args
}
final_path = 'driver_name/vendor_passthru/method'
for http_method in ('POST', 'PUT', 'PATCH'):
@ -113,10 +113,10 @@ class DriverManagerTest(testtools.TestCase):
@mock.patch.object(driver.DriverManager, 'get')
def test_vendor_passthru_get(self, get_mock):
kwargs = {
'driver_name': 'driver_name',
'method': 'method',
'http_method': 'GET',
}
'driver_name': 'driver_name',
'method': 'method',
'http_method': 'GET',
}
final_path = 'driver_name/vendor_passthru/method'
self.mgr.vendor_passthru(**kwargs)
@ -125,10 +125,10 @@ class DriverManagerTest(testtools.TestCase):
@mock.patch.object(driver.DriverManager, 'delete')
def test_vendor_passthru_delete(self, delete_mock):
kwargs = {
'driver_name': 'driver_name',
'method': 'method',
'http_method': 'DELETE',
}
'driver_name': 'driver_name',
'method': 'method',
'http_method': 'DELETE',
}
final_path = 'driver_name/vendor_passthru/method'
self.mgr.vendor_passthru(**kwargs)
@ -137,9 +137,9 @@ class DriverManagerTest(testtools.TestCase):
@mock.patch.object(driver.DriverManager, 'delete')
def test_vendor_passthru_unknown_http_method(self, delete_mock):
kwargs = {
'driver_name': 'driver_name',
'method': 'method',
'http_method': 'UNKNOWN',
}
'driver_name': 'driver_name',
'method': 'method',
'http_method': 'UNKNOWN',
}
self.assertRaises(exc.InvalidAttribute, self.mgr.vendor_passthru,
**kwargs)

@ -42,8 +42,8 @@ class DriverShellTest(utils.BaseTestCase):
d_shell.do_driver_vendor_passthru(client_mock, args)
client_mock.driver.vendor_passthru.assert_called_once_with(
args.driver_name, args.method, http_method=args.http_method,
args={'arg1': 'val1', 'arg2': 'val2'})
args.driver_name, args.method, http_method=args.http_method,
args={'arg1': 'val1', 'arg2': 'val2'})
def test_do_driver_vendor_passthru_without_args(self):
client_mock = mock.MagicMock()
@ -55,5 +55,5 @@ class DriverShellTest(utils.BaseTestCase):
d_shell.do_driver_vendor_passthru(client_mock, args)
client_mock.driver.vendor_passthru.assert_called_once_with(
args.driver_name, args.method, args={},
http_method=args.http_method)
args.driver_name, args.method, args={},
http_method=args.http_method)

@ -26,22 +26,22 @@ from ironicclient.tests.unit import utils
from ironicclient.v1 import node
NODE1 = {'id': 123,
'uuid': '66666666-7777-8888-9999-000000000000',
'chassis_uuid': 'aaaaaaaa-1111-bbbb-2222-cccccccccccc',
'maintenance': False,
'driver': 'fake',
'driver_info': {'user': 'foo', 'password': 'bar'},
'properties': {'num_cpu': 4},
'extra': {}}
'uuid': '66666666-7777-8888-9999-000000000000',
'chassis_uuid': 'aaaaaaaa-1111-bbbb-2222-cccccccccccc',
'maintenance': False,
'driver': 'fake',
'driver_info': {'user': 'foo', 'password': 'bar'},
'properties': {'num_cpu': 4},
'extra': {}}
NODE2 = {'id': 456,
'uuid': '66666666-7777-8888-9999-111111111111',
'instance_uuid': '66666666-7777-8888-9999-222222222222',
'chassis_uuid': 'aaaaaaaa-1111-bbbb-2222-cccccccccccc',
'maintenance': True,
'driver': 'fake too',
'driver_info': {'user': 'foo', 'password': 'bar'},
'properties': {'num_cpu': 4},
'extra': {}}
'uuid': '66666666-7777-8888-9999-111111111111',
'instance_uuid': '66666666-7777-8888-9999-222222222222',
'chassis_uuid': 'aaaaaaaa-1111-bbbb-2222-cccccccccccc',
'maintenance': True,
'driver': 'fake too',
'driver_info': {'user': 'foo', 'password': 'bar'},
'properties': {'num_cpu': 4},
'extra': {}}
PORT = {'id': 456,
'uuid': '11111111-2222-3333-4444-555555555555',
'node_id': 123,
@ -634,7 +634,7 @@ class NodeManagerTest(testtools.TestCase):
def test_node_set_provision_state_with_configdrive(self):
target_state = 'active'
self.mgr.set_provision_state(NODE1['uuid'], target_state,
configdrive='foo')
configdrive='foo')
body = {'target': target_state, 'configdrive': 'foo'}
expect = [
('PUT', '/v1/nodes/%s/states/provision' % NODE1['uuid'], {}, body),
@ -649,7 +649,7 @@ class NodeManagerTest(testtools.TestCase):
f.write(file_content)
f.flush()
self.mgr.set_provision_state(NODE1['uuid'], target_state,
configdrive=f.name)
configdrive=f.name)
body = {'target': target_state, 'configdrive': file_content}
expect = [
@ -699,10 +699,10 @@ class NodeManagerTest(testtools.TestCase):
# anything to verify.
vendor_passthru_args = {'arg1': 'val1'}
kwargs = {
'node_id': 'node_uuid',
'method': 'method',
'args': vendor_passthru_args
}
'node_id': 'node_uuid',
'method': 'method',
'args': vendor_passthru_args
}
final_path = 'node_uuid/vendor_passthru/method'
for http_method in ('POST', 'PUT', 'PATCH'):
@ -716,10 +716,10 @@ class NodeManagerTest(testtools.TestCase):
@mock.patch.object(node.NodeManager, 'get')
def test_vendor_passthru_get(self, get_mock):
kwargs = {
'node_id': 'node_uuid',
'method': 'method',
'http_method': 'GET',
}
'node_id': 'node_uuid',
'method': 'method',
'http_method': 'GET',
}
final_path = 'node_uuid/vendor_passthru/method'
self.mgr.vendor_passthru(**kwargs)
@ -728,10 +728,10 @@ class NodeManagerTest(testtools.TestCase):
@mock.patch.object(node.NodeManager, 'delete')
def test_vendor_passthru_delete(self, delete_mock):
kwargs = {
'node_id': 'node_uuid',
'method': 'method',
'http_method': 'DELETE',
}
'node_id': 'node_uuid',
'method': 'method',
'http_method': 'DELETE',
}
final_path = 'node_uuid/vendor_passthru/method'
self.mgr.vendor_passthru(**kwargs)
@ -740,10 +740,10 @@ class NodeManagerTest(testtools.TestCase):
@mock.patch.object(node.NodeManager, 'delete')
def test_vendor_passthru_unknown_http_method(self, delete_mock):
kwargs = {
'node_id': 'node_uuid',
'method': 'method',
'http_method': 'UNKNOWN',
}
'node_id': 'node_uuid',
'method': 'method',
'http_method': 'UNKNOWN',
}
self.assertRaises(exc.InvalidAttribute, self.mgr.vendor_passthru,
**kwargs)

@ -176,9 +176,8 @@ class NodeShellTest(utils.BaseTestCase):
args.reason = 'reason'
n_shell.do_node_set_maintenance(client_mock, args)
client_mock.node.set_maintenance.assert_called_once_with('node_uuid',
'true',
maint_reason='reason')
client_mock.node.set_maintenance.assert_called_once_with(
'node_uuid', 'true', maint_reason='reason')
def test_do_node_set_maintenance_false(self):
client_mock = mock.MagicMock()
@ -189,9 +188,8 @@ class NodeShellTest(utils.BaseTestCase):
args.reason = None
n_shell.do_node_set_maintenance(client_mock, args)
client_mock.node.set_maintenance.assert_called_once_with('node_uuid',
'false',
maint_reason=None)
client_mock.node.set_maintenance.assert_called_once_with(
'node_uuid', 'false', maint_reason=None)
def test_do_node_set_maintenance_false_with_reason_fails(self):
client_mock = mock.MagicMock()
@ -212,9 +210,8 @@ class NodeShellTest(utils.BaseTestCase):
args.reason = 'reason'
n_shell.do_node_set_maintenance(client_mock, args)
client_mock.node.set_maintenance.assert_called_once_with('node_uuid',
'on',
maint_reason='reason')
client_mock.node.set_maintenance.assert_called_once_with(
'node_uuid', 'on', maint_reason='reason')
def test_do_node_set_maintenance_off(self):
client_mock = mock.MagicMock()
@ -225,9 +222,8 @@ class NodeShellTest(utils.BaseTestCase):
args.reason = None
n_shell.do_node_set_maintenance(client_mock, args)
client_mock.node.set_maintenance.assert_called_once_with('node_uuid',
'off',
maint_reason=None)
client_mock.node.set_maintenance.assert_called_once_with(
'node_uuid', 'off', maint_reason=None)
def test_do_node_set_maintenance_off_with_reason_fails(self):
client_mock = mock.MagicMock()
@ -269,8 +265,8 @@ class NodeShellTest(utils.BaseTestCase):
n_shell.do_node_vendor_passthru(client_mock, args)
client_mock.node.vendor_passthru.assert_called_once_with(
args.node, args.method, args={'arg1': 'val1', 'arg2': 'val2'},
http_method=args.http_method)
args.node, args.method, args={'arg1': 'val1', 'arg2': 'val2'},
http_method=args.http_method)
def test_do_node_vendor_passthru_without_args(self):
client_mock = mock.MagicMock()
@ -282,7 +278,7 @@ class NodeShellTest(utils.BaseTestCase):
n_shell.do_node_vendor_passthru(client_mock, args)
client_mock.node.vendor_passthru.assert_called_once_with(
args.node, args.method, args={}, http_method=args.http_method)
args.node, args.method, args={}, http_method=args.http_method)
def test_do_node_set_provision_state_active(self):
client_mock = mock.MagicMock()
@ -338,7 +334,7 @@ class NodeShellTest(utils.BaseTestCase):
n_shell.do_node_set_boot_device(client_mock, args)
client_mock.node.set_boot_device.assert_called_once_with(
'node_uuid', 'pxe', False)
'node_uuid', 'pxe', False)
def test_do_node_get_boot_device(self):
client_mock = mock.MagicMock()
@ -355,4 +351,4 @@ class NodeShellTest(utils.BaseTestCase):
n_shell.do_node_get_supported_boot_devices(client_mock, args)
client_mock.node.get_supported_boot_devices.assert_called_once_with(
'node_uuid')
'node_uuid')

@ -30,10 +30,10 @@ PORT = {'id': 987,
'extra': {}}
PORT2 = {'id': 988,
'uuid': '55555555-4444-3333-2222-111111111111',
'node_uuid': '55555555-4444-3333-2222-111111111111',
'address': 'AA:AA:AA:BB:BB:BB',
'extra': {}}
'uuid': '55555555-4444-3333-2222-111111111111',
'node_uuid': '55555555-4444-3333-2222-111111111111',
'address': 'AA:AA:AA:BB:BB:BB',
'extra': {}}
CREATE_PORT = copy.deepcopy(PORT)
del CREATE_PORT['id']

@ -79,4 +79,4 @@ class DriverManager(base.Manager):
return self.get(path)
else:
raise exc.InvalidAttribute(
_('Unknown HTTP method: %s') % http_method)
_('Unknown HTTP method: %s') % http_method)

@ -74,17 +74,17 @@ def do_driver_properties(cc, args):
help="Argument to be passed to the vendor-passthru method. "
"Can be specified multiple times.")
@cliutils.arg('--http-method',
metavar='<http-method>',
choices=['POST', 'PUT', 'GET', 'DELETE', 'PATCH'],
help="The HTTP method to use in the request. Valid HTTP "
"methods are: 'POST', 'PUT', 'GET', 'DELETE', and 'PATCH'. "
"Defaults to 'POST'.")
metavar='<http-method>',
choices=['POST', 'PUT', 'GET', 'DELETE', 'PATCH'],
help="The HTTP method to use in the request. Valid HTTP "
"methods are: 'POST', 'PUT', 'GET', 'DELETE', and 'PATCH'. "
"Defaults to 'POST'.")
@cliutils.arg('--http_method',
help=argparse.SUPPRESS)
help=argparse.SUPPRESS)
def do_driver_vendor_passthru(cc, args):
"""Call a vendor-passthru extension for a driver."""
arguments = utils.args_array_to_dict({'args': args.arguments[0]},
'args')['args']
'args')['args']
# If there were no arguments for the method, arguments will still
# be an empty list. So make it an empty dict.

@ -194,7 +194,7 @@ class NodeManager(base.Manager):
return self.get(path)
else:
raise exc.InvalidAttribute(
_('Unknown HTTP method: %s') % http_method)
_('Unknown HTTP method: %s') % http_method)
def set_maintenance(self, node_id, state, maint_reason=None):
path = "%s/maintenance" % node_id

@ -196,30 +196,30 @@ def do_node_update(cc, args):
@cliutils.arg('node',
metavar='<node>',
help="UUID of the node.")
metavar='<node>',
help="UUID of the node.")
@cliutils.arg('method',
metavar='<method>',
help="Vendor-passthru method to be called.")
metavar='<method>',
help="Vendor-passthru method to be called.")
@cliutils.arg('arguments',
metavar='<arg=value>',
nargs='*',
action='append',
default=[],
help="Argument to be passed to the vendor-passthru method. Can be "
"specified mutiple times.")
metavar='<arg=value>',
nargs='*',
action='append',
default=[],
help=("Argument to be passed to the vendor-passthru method. Can "
"be specified mutiple times."))
@cliutils.arg('--http-method',
metavar='<http-method>',
choices=['POST', 'PUT', 'GET', 'DELETE', 'PATCH'],
help="The HTTP method to use in the request. Valid HTTP "
"methods are: 'POST', 'PUT', 'GET', 'DELETE', and 'PATCH'. "
"Defaults to 'POST'.")
metavar='<http-method>',
choices=['POST', 'PUT', 'GET', 'DELETE', 'PATCH'],
help="The HTTP method to use in the request. Valid HTTP "
"methods are: 'POST', 'PUT', 'GET', 'DELETE', and 'PATCH'. "
"Defaults to 'POST'.")
@cliutils.arg('--http_method',
help=argparse.SUPPRESS)
help=argparse.SUPPRESS)
def do_node_vendor_passthru(cc, args):
"""Call a vendor-passthru extension for a node."""
arguments = utils.args_array_to_dict({'args': args.arguments[0]},
'args')['args']
'args')['args']
# If there were no arguments for the method, arguments will still
# be an empty list. So make it an empty dict.

@ -32,7 +32,7 @@ commands = {posargs}
setenv = OS_TEST_PATH=./ironicclient/tests/functional
[flake8]
ignore = E126,E127,E128
ignore =
builtins = _
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools