Fix all the pep8 E* and F* errors.

Change-Id: I34bab949e4795073544c64c9796237c60ace4d65
This commit is contained in:
Angus Salkeld 2013-06-27 13:13:14 +10:00
parent 61ce60358e
commit 2fcd4570f3
10 changed files with 115 additions and 109 deletions

View file

@ -100,7 +100,7 @@ class Resource(object):
def __repr__(self):
reprkeys = sorted(k for k in self.__dict__.keys()
if k[0] != '_' and k != 'manager')
if k[0] != '_' and k != 'manager')
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
return "<%s %s>" % (self.__class__.__name__, info)

View file

@ -42,131 +42,135 @@ class HeatShell(object):
# Global arguments
parser.add_argument('-h', '--help',
action='store_true',
help=argparse.SUPPRESS)
action='store_true',
help=argparse.SUPPRESS)
parser.add_argument('-d', '--debug',
default=bool(utils.env('HEATCLIENT_DEBUG')),
action='store_true',
help='Defaults to env[HEATCLIENT_DEBUG]')
default=bool(utils.env('HEATCLIENT_DEBUG')),
action='store_true',
help='Defaults to env[HEATCLIENT_DEBUG]')
parser.add_argument('-v', '--verbose',
default=False, action="store_true",
help="Print more verbose output")
default=False, action="store_true",
help="Print more verbose output")
parser.add_argument('-k', '--insecure',
default=False,
action='store_true',
help="Explicitly allow the client to perform \"insecure\" "
"SSL (https) requests. The server's certificate will "
"not be verified against any certificate authorities. "
"This option should be used with caution.")
default=False,
action='store_true',
help="Explicitly allow the client to perform"
"\"insecure\" SSL (https) requests. The server's "
"certificate will not be verified against any "
"certificate authorities. "
"This option should be used with caution.")
parser.add_argument('--cert-file',
help='Path of certificate file to use in SSL connection. This '
'file can optionally be prepended with the private key.')
help='Path of certificate file to use in SSL '
'connection. This file can optionally be prepended'
'with the private key.')
parser.add_argument('--key-file',
help='Path of client key to use in SSL connection. This option is '
'not necessary if your key is prepended to your cert file.')
help='Path of client key to use in SSL connection.'
'This option is not necessary if your key is'
' prepended to your cert file.')
parser.add_argument('--ca-file',
help='Path of CA SSL certificate(s) used to verify the remote '
'server\'s certificate. Without this option the client looks '
'for the default system CA certificates.')
help='Path of CA SSL certificate(s) used to verify'
' the remote server\'s certificate. Without this'
' option the client looks'
' for the default system CA certificates.')
parser.add_argument('--timeout',
default=600,
help='Number of seconds to wait for a response')
default=600,
help='Number of seconds to wait for a response')
parser.add_argument('--os-username',
default=utils.env('OS_USERNAME'),
help='Defaults to env[OS_USERNAME]')
default=utils.env('OS_USERNAME'),
help='Defaults to env[OS_USERNAME]')
parser.add_argument('--os_username',
help=argparse.SUPPRESS)
help=argparse.SUPPRESS)
parser.add_argument('--os-password',
default=utils.env('OS_PASSWORD'),
help='Defaults to env[OS_PASSWORD]')
default=utils.env('OS_PASSWORD'),
help='Defaults to env[OS_PASSWORD]')
parser.add_argument('--os_password',
help=argparse.SUPPRESS)
help=argparse.SUPPRESS)
parser.add_argument('--os-tenant-id',
default=utils.env('OS_TENANT_ID'),
help='Defaults to env[OS_TENANT_ID]')
default=utils.env('OS_TENANT_ID'),
help='Defaults to env[OS_TENANT_ID]')
parser.add_argument('--os_tenant_id',
help=argparse.SUPPRESS)
help=argparse.SUPPRESS)
parser.add_argument('--os-tenant-name',
default=utils.env('OS_TENANT_NAME'),
help='Defaults to env[OS_TENANT_NAME]')
default=utils.env('OS_TENANT_NAME'),
help='Defaults to env[OS_TENANT_NAME]')
parser.add_argument('--os_tenant_name',
help=argparse.SUPPRESS)
help=argparse.SUPPRESS)
parser.add_argument('--os-auth-url',
default=utils.env('OS_AUTH_URL'),
help='Defaults to env[OS_AUTH_URL]')
default=utils.env('OS_AUTH_URL'),
help='Defaults to env[OS_AUTH_URL]')
parser.add_argument('--os_auth_url',
help=argparse.SUPPRESS)
help=argparse.SUPPRESS)
parser.add_argument('--os-region-name',
default=utils.env('OS_REGION_NAME'),
help='Defaults to env[OS_REGION_NAME]')
default=utils.env('OS_REGION_NAME'),
help='Defaults to env[OS_REGION_NAME]')
parser.add_argument('--os_region_name',
help=argparse.SUPPRESS)
help=argparse.SUPPRESS)
parser.add_argument('--os-auth-token',
default=utils.env('OS_AUTH_TOKEN'),
help='Defaults to env[OS_AUTH_TOKEN]')
parser.add_argument('--os_auth_token',
help=argparse.SUPPRESS)
help=argparse.SUPPRESS)
parser.add_argument('--os-no-client-auth',
default=utils.env('OS_NO_CLIENT_AUTH'),
action='store_true',
help="Do not contact keystone for a token.\
Defaults to env[OS_NO_CLIENT_AUTH]")
default=utils.env('OS_NO_CLIENT_AUTH'),
action='store_true',
help="Do not contact keystone for a token.\
Defaults to env[OS_NO_CLIENT_AUTH]")
parser.add_argument('--heat-url',
default=utils.env('HEAT_URL'),
help='Defaults to env[HEAT_URL]')
default=utils.env('HEAT_URL'),
help='Defaults to env[HEAT_URL]')
parser.add_argument('--heat_url',
help=argparse.SUPPRESS)
help=argparse.SUPPRESS)
parser.add_argument('--heat-api-version',
default=utils.env('HEAT_API_VERSION', default='1'),
help='Defaults to env[HEAT_API_VERSION] or 1')
default=utils.env('HEAT_API_VERSION', default='1'),
help='Defaults to env[HEAT_API_VERSION] or 1')
parser.add_argument('--heat_api_version',
help=argparse.SUPPRESS)
help=argparse.SUPPRESS)
parser.add_argument('--os-service-type',
default=utils.env('OS_SERVICE_TYPE'),
help='Defaults to env[OS_SERVICE_TYPE]')
default=utils.env('OS_SERVICE_TYPE'),
help='Defaults to env[OS_SERVICE_TYPE]')
parser.add_argument('--os_service_type',
help=argparse.SUPPRESS)
help=argparse.SUPPRESS)
parser.add_argument('--os-endpoint-type',
default=utils.env('OS_ENDPOINT_TYPE'),
help='Defaults to env[OS_ENDPOINT_TYPE]')
default=utils.env('OS_ENDPOINT_TYPE'),
help='Defaults to env[OS_ENDPOINT_TYPE]')
parser.add_argument('--os_endpoint_type',
help=argparse.SUPPRESS)
help=argparse.SUPPRESS)
parser.add_argument('-t', '--token-only',
default=bool(False),
action='store_true',
help='Only send a token for auth, do not send username and '
'password as well.')
default=bool(False),
action='store_true',
help='Only send a token for auth, do not send'
' username and password as well.')
return parser
@ -191,13 +195,13 @@ class HeatShell(object):
arguments = getattr(callback, 'arguments', [])
subparser = subparsers.add_parser(command,
help=help,
description=desc,
add_help=False,
formatter_class=HelpFormatter)
help=help,
description=desc,
add_help=False,
formatter_class=HelpFormatter)
subparser.add_argument('-h', '--help',
action='help',
help=argparse.SUPPRESS)
action='help',
help=argparse.SUPPRESS)
self.subcommands[command] = subparser
for (args, kwargs) in arguments:
subparser.add_argument(*args, **kwargs)
@ -258,22 +262,23 @@ class HeatShell(object):
self.do_help(args)
return 0
heat_url = args.heat_url
if not args.os_username:
raise exc.CommandError("You must provide a username via"
" either --os-username or env[OS_USERNAME]")
" either --os-username or env[OS_USERNAME]")
if not args.os_password:
raise exc.CommandError("You must provide a password via"
" either --os-password or env[OS_PASSWORD]")
" either --os-password or env[OS_PASSWORD]")
if not (args.os_tenant_id or args.os_tenant_name):
raise exc.CommandError("You must provide a tenant_id via"
" either --os-tenant-id or via env[OS_TENANT_ID]")
" either --os-tenant-id or via "
"env[OS_TENANT_ID]")
if not args.os_auth_url:
raise exc.CommandError("You must provide an auth url via"
" either --os-auth-url or via env[OS_AUTH_URL]")
" either --os-auth-url or via "
"env[OS_AUTH_URL]")
kwargs = {
'username': args.os_username,
'password': args.os_password,

View file

@ -6,11 +6,11 @@ from keystoneclient.v2_0 import client as ksclient
def script_keystone_client():
ksclient.Client(auth_url='http://no.where',
insecure=False,
password='password',
tenant_id='',
tenant_name='tenant_name',
username='username').AndReturn(FakeKeystone('abcd1234'))
insecure=False,
password='password',
tenant_id='',
tenant_name='tenant_name',
username='username').AndReturn(FakeKeystone('abcd1234'))
def script_heat_list():
@ -27,11 +27,12 @@ def script_heat_list():
}]
}
resp = FakeHTTPResponse(200,
'success, yo',
{'content-type': 'application/json'},
json.dumps(resp_dict))
'success, you',
{'content-type': 'application/json'},
json.dumps(resp_dict))
v1client.Client.json_request('GET',
'/stacks?limit=20').AndReturn((resp, resp_dict))
'/stacks?limit=20').AndReturn((resp,
resp_dict))
def fake_headers():

View file

@ -62,26 +62,26 @@ class EnvVarTest(TestCase):
scenarios = [
('username', dict(
remove='OS_USERNAME',
err='You must provide a username')),
remove='OS_USERNAME',
err='You must provide a username')),
('password', dict(
remove='OS_PASSWORD',
err='You must provide a password')),
remove='OS_PASSWORD',
err='You must provide a password')),
('tenant_name', dict(
remove='OS_TENANT_NAME',
err='You must provide a tenant_id')),
remove='OS_TENANT_NAME',
err='You must provide a tenant_id')),
('auth_url', dict(
remove='OS_AUTH_URL',
err='You must provide an auth url')),
remove='OS_AUTH_URL',
err='You must provide an auth url')),
]
def test_missing_auth(self):
fake_env = {
'OS_USERNAME': 'username',
'OS_PASSWORD': 'password',
'OS_TENANT_NAME': 'tenant_name',
'OS_AUTH_URL': 'http://no.where',
'OS_USERNAME': 'username',
'OS_PASSWORD': 'password',
'OS_TENANT_NAME': 'tenant_name',
'OS_AUTH_URL': 'http://no.where',
}
fake_env[self.remove] = None
self.set_fake_env(fake_env)

View file

@ -48,4 +48,4 @@ class shellTest(testtools.TestCase):
def test_format_parameter_bad_parameter(self):
params = 'KeyName=heat_key;UpstreamDNS8.8.8.8'
self.assertRaises(exc.MalformedRequestBody,
utils.format_parameters, params)
utils.format_parameters, params)

View file

@ -57,7 +57,8 @@ class EventManager(stacks.StackChildManager):
:param event_id: ID of event to get the details for
"""
stack_id = self._resolve_stack_id(stack_id)
resp, body = self.api.json_request('GET',
'/stacks/%s/resources/%s/events/%s' %
(stack_id, resource_name, event_id))
url_str = '/stacks/%s/resources/%s/events/%s' % (stack_id,
resource_name,
event_id)
resp, body = self.api.json_request('GET', url_str)
return Event(self, body['event'])

View file

@ -51,8 +51,8 @@ class ResourceManager(stacks.StackChildManager):
"""
stack_id = self._resolve_stack_id(stack_id)
resp, body = self.api.json_request('GET',
'/stacks/%s/resources/%s' %
(stack_id, resource_name))
'/stacks/%s/resources/%s' %
(stack_id, resource_name))
return Resource(self, body['resource'])
@ -64,6 +64,6 @@ class ResourceManager(stacks.StackChildManager):
"""
stack_id = self._resolve_stack_id(stack_id)
resp, body = self.api.json_request('GET',
'/stacks/%s/resources/%s/metadata' %
(stack_id, resource_name))
'/stacks/%s/resources/%s/metadata' %
(stack_id, resource_name))
return body['metadata']

View file

@ -121,14 +121,14 @@ def do_stack_delete(hc, args):
@utils.arg('id', metavar='<NAME or ID>',
help='Name or ID of stack to describe.')
help='Name or ID of stack to describe.')
def do_describe(hc, args):
'''DEPRECATED! Use stack-show instead.'''
do_stack_show(hc, args)
@utils.arg('id', metavar='<NAME or ID>',
help='Name or ID of stack to describe.')
help='Name or ID of stack to describe.')
def do_stack_show(hc, args):
'''Describe the stack.'''
fields = {'stack_id': args.id}
@ -297,10 +297,9 @@ def do_resource_show(hc, args):
resource = hc.resources.get(**fields)
except exc.HTTPNotFound:
raise exc.CommandError('Stack or resource not found: %s %s' %
(args.id, args.resource))
(args.id, args.resource))
else:
link_format = lambda links: '\n'.join([l['href'] for l in links])
json_format = lambda js: json.dumps(js, indent=2)
formatters = {
'links': link_format
}
@ -319,7 +318,7 @@ def do_resource_metadata(hc, args):
metadata = hc.resources.metadata(**fields)
except exc.HTTPNotFound:
raise exc.CommandError('Stack or resource not found: %s %s' %
(args.id, args.resource))
(args.id, args.resource))
else:
print json.dumps(metadata, indent=2)

View file

@ -126,6 +126,6 @@ class StackChildManager(base.Manager):
if stack_id.find('/') > 0:
return stack_id
resp, body = self.api.json_request('GET',
'/stacks/%s' % stack_id)
'/stacks/%s' % stack_id)
stack = body['stack']
return '%s/%s' % (stack['stack_name'], stack['id'])

View file

@ -22,6 +22,6 @@ downloadcache = ~/cache/pip
[flake8]
show-source = True
ignore = E121,E128,H302,H303,H304,H403,H404,F403,F821,F841
ignore = H302,H303,H304,H403,H404
builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build