Fix some "H" pep errors

And be more specific about which ones we ignore.

Change-Id: I69fd6897957e3dcb5939cf48651a0f1b41b711dd
This commit is contained in:
Angus Salkeld 2013-05-20 14:08:03 +10:00
parent b343c1c22d
commit 2a08054f8c
11 changed files with 48 additions and 52 deletions

View File

@ -121,7 +121,7 @@ class HTTPClient(object):
LOG.debug('\n'.join(dump))
def _http_request(self, url, method, **kwargs):
""" Send an http request with the specified characteristics.
"""Send an http request with the specified characteristics.
Wrapper around httplib.HTTP(S)Connection.request to handle tasks such
as setting headers and error handling.
@ -256,7 +256,7 @@ class VerifiedHTTPSConnection(httplib.HTTPSConnection):
@staticmethod
def get_system_ca_file():
""""Return path to system default CA file"""
"""Return path to system default CA file."""
# Standard CA file locations for Debian/Ubuntu, RedHat/Fedora,
# Suse, FreeBSD/OpenBSD
ca_path = ['/etc/ssl/certs/ca-certificates.crt',

View File

@ -23,7 +23,7 @@ class BaseException(Exception):
class CommandError(BaseException):
"""Invalid usage of CLI"""
"""Invalid usage of CLI."""
class InvalidEndpoint(BaseException):
@ -35,7 +35,7 @@ class CommunicationError(BaseException):
class HTTPException(BaseException):
"""Base exception for all HTTP-derived exceptions"""
"""Base exception for all HTTP-derived exceptions."""
code = 'N/A'
@ -50,7 +50,7 @@ class HTTPMultipleChoices(HTTPException):
class BadRequest(HTTPException):
"""DEPRECATED"""
"""DEPRECATED."""
code = 400
@ -59,7 +59,7 @@ class HTTPBadRequest(BadRequest):
class Unauthorized(HTTPException):
"""DEPRECATED"""
"""DEPRECATED."""
code = 401
@ -68,7 +68,7 @@ class HTTPUnauthorized(Unauthorized):
class Forbidden(HTTPException):
"""DEPRECATED"""
"""DEPRECATED."""
code = 403
@ -77,7 +77,7 @@ class HTTPForbidden(Forbidden):
class NotFound(HTTPException):
"""DEPRECATED"""
"""DEPRECATED."""
code = 404
@ -90,7 +90,7 @@ class HTTPMethodNotAllowed(HTTPException):
class Conflict(HTTPException):
"""DEPRECATED"""
"""DEPRECATED."""
code = 409
@ -99,7 +99,7 @@ class HTTPConflict(Conflict):
class OverLimit(HTTPException):
"""DEPRECATED"""
"""DEPRECATED."""
code = 413
@ -120,7 +120,7 @@ class HTTPBadGateway(HTTPException):
class ServiceUnavailable(HTTPException):
"""DEPRECATED"""
"""DEPRECATED."""
code = 503
@ -145,10 +145,10 @@ def from_response(response, body_iter):
class NoTokenLookupException(Exception):
"""DEPRECATED"""
"""DEPRECATED."""
pass
class EndpointNotFound(Exception):
"""DEPRECATED"""
"""DEPRECATED."""
pass

View File

@ -21,9 +21,9 @@ import sys
from keystoneclient.v2_0 import client as ksclient
from heatclient import exc
from heatclient import client as heatclient
from heatclient.common import utils
from heatclient import exc
logger = logging.getLogger(__name__)

View File

@ -30,7 +30,7 @@ class Client(http.HTTPClient):
"""
def __init__(self, *args, **kwargs):
""" Initialize a new client for the Heat v1 API. """
"""Initialize a new client for the Heat v1 API."""
super(Client, self).__init__(*args, **kwargs)
self.stacks = stacks.StackManager(self)
self.resources = resources.ResourceManager(self)

View File

@ -58,7 +58,7 @@ def _set_template_fields(hc, args, fields):
@utils.arg('name', metavar='<STACK_NAME>',
help='Name of the stack to create.')
def do_create(hc, args):
'''DEPRECATED! Use stack-create instead'''
'''DEPRECATED! Use stack-create instead.'''
do_stack_create(hc, args)
@ -78,7 +78,7 @@ def do_create(hc, args):
@utils.arg('name', metavar='<STACK_NAME>',
help='Name of the stack to create.')
def do_stack_create(hc, args):
'''Create the stack'''
'''Create the stack.'''
fields = {'stack_name': args.name,
'timeout_mins': args.create_timeout,
'disable_rollback': not(args.enable_rollback),
@ -91,13 +91,13 @@ def do_stack_create(hc, args):
@utils.arg('id', metavar='<NAME or ID>', help='Name or ID of stack to delete.')
def do_delete(hc, args):
'''DEPRECATED! Use stack-delete instead'''
'''DEPRECATED! Use stack-delete instead.'''
do_stack_delete(hc, args)
@utils.arg('id', metavar='<NAME or ID>', help='Name or ID of stack to delete.')
def do_stack_delete(hc, args):
'''Delete the stack'''
'''Delete the stack.'''
fields = {'stack_id': args.id}
try:
hc.stacks.delete(**fields)
@ -110,14 +110,14 @@ def do_stack_delete(hc, args):
@utils.arg('id', metavar='<NAME or ID>',
help='Name or ID of stack to describe.')
def do_describe(hc, args):
'''DEPRECATED! Use stack-show instead'''
'''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.')
def do_stack_show(hc, args):
'''Describe the stack'''
'''Describe the stack.'''
fields = {'stack_id': args.id}
try:
stack = hc.stacks.get(**fields)
@ -149,7 +149,7 @@ def do_stack_show(hc, args):
@utils.arg('id', metavar='<NAME or ID>',
help='Name or ID of stack to update.')
def do_update(hc, args):
'''DEPRECATED! Use stack-update instead'''
'''DEPRECATED! Use stack-update instead.'''
do_stack_update(hc, args)
@ -164,7 +164,7 @@ def do_update(hc, args):
@utils.arg('id', metavar='<NAME or ID>',
help='Name or ID of stack to update.')
def do_stack_update(hc, args):
'''Update the stack'''
'''Update the stack.'''
fields = {'stack_id': args.id,
'parameters': utils.format_parameters(args.parameters)}
_set_template_fields(hc, args, fields)
@ -174,12 +174,12 @@ def do_stack_update(hc, args):
def do_list(hc, args={}):
'''DEPRECATED! Use stack-list instead'''
'''DEPRECATED! Use stack-list instead.'''
do_stack_list(hc, args)
def do_stack_list(hc, args={}):
'''List the user's stacks'''
'''List the user's stacks.'''
kwargs = {}
stacks = hc.stacks.list(**kwargs)
fields = ['id', 'stack_name', 'stack_status', 'creation_time']
@ -189,14 +189,14 @@ def do_stack_list(hc, args={}):
@utils.arg('id', metavar='<NAME or ID>',
help='Name or ID of stack to get the template for.')
def do_gettemplate(hc, args):
'''DEPRECATED! Use template-show instead'''
'''DEPRECATED! Use template-show instead.'''
do_template_show(hc, args)
@utils.arg('id', metavar='<NAME or ID>',
help='Name or ID of stack to get the template for.')
def do_template_show(hc, args):
'''Get the template for the specified stack'''
'''Get the template for the specified stack.'''
fields = {'stack_id': args.id}
try:
template = hc.stacks.template(**fields)
@ -215,7 +215,7 @@ def do_template_show(hc, args):
@utils.arg('-P', '--parameters', metavar='<KEY1=VALUE1;KEY2=VALUE2...>',
help='Parameter values to validate.')
def do_validate(hc, args):
'''DEPRECATED! Use template-validate instead'''
'''DEPRECATED! Use template-validate instead.'''
do_template_validate(hc, args)
@ -228,7 +228,7 @@ def do_validate(hc, args):
@utils.arg('-P', '--parameters', metavar='<KEY1=VALUE1;KEY2=VALUE2...>',
help='Parameter values to validate.')
def do_template_validate(hc, args):
'''Validate a template with parameters'''
'''Validate a template with parameters.'''
fields = {'parameters': utils.format_parameters(args.parameters)}
_set_template_fields(hc, args, fields)
@ -239,7 +239,7 @@ def do_template_validate(hc, args):
@utils.arg('id', metavar='<NAME or ID>',
help='Name or ID of stack to show the resources for.')
def do_resource_list(hc, args):
'''Show list of resources belonging to a stack'''
'''Show list of resources belonging to a stack.'''
fields = {'stack_id': args.id}
try:
resources = hc.resources.list(**fields)
@ -256,7 +256,7 @@ def do_resource_list(hc, args):
@utils.arg('resource', metavar='<RESOURCE>',
help='Name of the resource to show the details for.')
def do_resource(hc, args):
'''DEPRECATED! Use resource-show instead'''
'''DEPRECATED! Use resource-show instead.'''
do_resource_show(hc, args)
@ -265,7 +265,7 @@ def do_resource(hc, args):
@utils.arg('resource', metavar='<RESOURCE>',
help='Name of the resource to show the details for.')
def do_resource_show(hc, args):
'''Describe the resource'''
'''Describe the resource.'''
fields = {'stack_id': args.id,
'resource_name': args.resource}
try:
@ -287,7 +287,7 @@ def do_resource_show(hc, args):
@utils.arg('resource', metavar='<RESOURCE>',
help='Name of the resource to show the metadata for.')
def do_resource_metadata(hc, args):
'''List resource metadata'''
'''List resource metadata.'''
fields = {'stack_id': args.id,
'resource_name': args.resource}
try:
@ -304,7 +304,7 @@ def do_resource_metadata(hc, args):
@utils.arg('-r', '--resource', metavar='<RESOURCE>',
help='Name of the resource to filter events by')
def do_event_list(hc, args):
'''List events for a stack'''
'''List events for a stack.'''
fields = {'stack_id': args.id,
'resource_name': args.resource}
try:
@ -324,7 +324,7 @@ def do_event_list(hc, args):
@utils.arg('event', metavar='<EVENT>',
help='ID of event to display details for')
def do_event(hc, args):
'''DEPRECATED! Use event-show instead'''
'''DEPRECATED! Use event-show instead.'''
do_event_show(hc, args)
@ -335,7 +335,7 @@ def do_event(hc, args):
@utils.arg('event', metavar='<EVENT>',
help='ID of event to display details for')
def do_event_show(hc, args):
'''Describe the event'''
'''Describe the event.'''
fields = {'stack_id': args.id,
'resource_name': args.resource,
'event_id': args.event}

View File

@ -81,12 +81,12 @@ class StackManager(base.Manager):
return paginate(params)
def create(self, **kwargs):
"""Create a stack"""
"""Create a stack."""
resp, body = self.api.json_request(
'POST', '/stacks', body=kwargs)
def update(self, **kwargs):
"""Update a stack"""
"""Update a stack."""
stack_id = kwargs.pop('stack_id')
resp, body = self.api.json_request(
'PUT', '/stacks/%s' % stack_id, body=kwargs)
@ -114,7 +114,7 @@ class StackManager(base.Manager):
return body
def validate(self, **kwargs):
"""Validate a stack template"""
"""Validate a stack template."""
resp, body = self.api.json_request(
'POST', '/validate', body=kwargs)
return body

View File

@ -1,7 +1,7 @@
import json
from keystoneclient.v2_0 import client as ksclient
from heatclient.v1 import client as v1client
from keystoneclient.v2_0 import client as ksclient
def script_keystone_client():

View File

@ -1,9 +1,9 @@
import mox
import unittest
from heatclient import exc
from heatclient.common import http
import fakes
from heatclient.common import http
from heatclient import exc
class HttpClientTest(unittest.TestCase):
@ -195,8 +195,6 @@ class HttpClientTest(unittest.TestCase):
except exc.HTTPNotFound as e:
# Assert that the raised exception can be converted to string
self.assertNotEqual(e.message, None)
except:
raise
self.m.VerifyAll()
def test_http_300_json_request(self):
@ -220,8 +218,6 @@ class HttpClientTest(unittest.TestCase):
except exc.HTTPMultipleChoices as e:
# Assert that the raised exception can be converted to string
self.assertNotEqual(e.message, None)
except:
raise
self.m.VerifyAll()
#def test_https_json_request(self):

View File

@ -1,6 +1,6 @@
import cStringIO
import os
import httplib2
import os
import re
import sys
@ -12,10 +12,10 @@ except ImportError:
import simplejson as json
from keystoneclient.v2_0 import client as ksclient
from heatclient import exc
from heatclient.v1 import client as v1client
import heatclient.shell
import fakes
from heatclient import exc
import heatclient.shell
from heatclient.v1 import client as v1client
TEST_VAR_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__),
'var'))

View File

@ -12,8 +12,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import unittest
from heatclient.common import utils
import unittest
class shellTest(unittest.TestCase):

View File

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