import only modules (flake8 H302)

Change-Id: I0fa6fc6bf9d51b60fa987a0040168f3f0ef78a4a
This commit is contained in:
Dolph Mathews 2013-05-23 15:09:14 -05:00 committed by Gerrit Code Review
parent c49066d02b
commit 0f6f386c74
6 changed files with 13 additions and 15 deletions

View File

@ -29,7 +29,7 @@ BufferedHTTPResponse.
""" """
import time import time
from urllib import quote import urllib
from eventlet.green import httplib from eventlet.green import httplib
@ -130,7 +130,7 @@ def http_connect(ipaddr, port, device, partition, method, path,
:returns: HTTPConnection object :returns: HTTPConnection object
""" """
path = quote('/' + device + '/' + str(partition) + path) path = urllib.quote('/' + device + '/' + str(partition) + path)
return http_connect_raw(ipaddr, port, device, partition, method, path, return http_connect_raw(ipaddr, port, device, partition, method, path,
headers, query_string, ssl, key_file, cert_file) headers, query_string, ssl, key_file, cert_file)

View File

@ -21,11 +21,10 @@ from __future__ import absolute_import
import functools import functools
import logging import logging
import logging.config import logging.config
import logging.handlers
import pprint import pprint
import traceback import traceback
from logging.handlers import SysLogHandler
from logging.handlers import WatchedFileHandler
# A list of things we want to replicate from logging. # A list of things we want to replicate from logging.
# levels # levels
@ -57,8 +56,8 @@ Formatter = logging.Formatter
# handlers # handlers
StreamHandler = logging.StreamHandler StreamHandler = logging.StreamHandler
WatchedFileHandler = WatchedFileHandler WatchedFileHandler = logging.handlers.WatchedFileHandler
SysLogHandler = SysLogHandler SysLogHandler = logging.handlers.SysLogHandler
def log_debug(f): def log_debug(f):

View File

@ -24,10 +24,9 @@ for the EC2 module for how to generate the required credentials.
""" """
import base64 import base64
import hashlib
import hmac import hmac
from hashlib import sha1
from keystone.common import utils from keystone.common import utils
from keystone.common import wsgi from keystone.common import wsgi
from keystone import config from keystone import config
@ -51,7 +50,8 @@ class S3Controller(ec2.Ec2Controller):
def check_signature(self, creds_ref, credentials): def check_signature(self, creds_ref, credentials):
msg = base64.urlsafe_b64decode(str(credentials['token'])) msg = base64.urlsafe_b64decode(str(credentials['token']))
key = str(creds_ref['secret']) key = str(creds_ref['secret'])
signed = base64.encodestring(hmac.new(key, msg, sha1).digest()).strip() signed = base64.encodestring(
hmac.new(key, msg, hashlib.sha1).digest()).strip()
if not utils.auth_str_equal(credentials['signature'], signed): if not utils.auth_str_equal(credentials['signature'], signed):
raise exception.Unauthorized('Credential signature mismatch') raise exception.Unauthorized('Credential signature mismatch')

View File

@ -22,7 +22,7 @@ Starting point for routing EC2 requests.
""" """
from urlparse import urlparse import urlparse
from eventlet.green import httplib from eventlet.green import httplib
import webob.dec import webob.dec
@ -73,7 +73,7 @@ class EC2Token(wsgi.Middleware):
# Disable 'has no x member' pylint error # Disable 'has no x member' pylint error
# for httplib and urlparse # for httplib and urlparse
# pylint: disable-msg=E1101 # pylint: disable-msg=E1101
o = urlparse(FLAGS.keystone_ec2_url) o = urlparse.urlparse(FLAGS.keystone_ec2_url)
if o.scheme == 'http': if o.scheme == 'http':
conn = httplib.HTTPConnection(o.netloc) conn = httplib.HTTPConnection(o.netloc)
else: else:

View File

@ -16,7 +16,7 @@
import uuid import uuid
from keystone.contrib.s3.core import S3Controller from keystone.contrib import s3
from keystone.contrib import ec2 from keystone.contrib import ec2
from keystone import exception from keystone import exception
@ -30,7 +30,7 @@ class S3ContribCore(test.TestCase):
self.load_backends() self.load_backends()
self.ec2_api = ec2.Manager() self.ec2_api = ec2.Manager()
self.controller = S3Controller() self.controller = s3.S3Controller()
def test_good_signature(self): def test_good_signature(self):
creds_ref = {'secret': creds_ref = {'secret':

View File

@ -31,14 +31,13 @@ commands = {posargs}
[flake8] [flake8]
show-source = true show-source = true
# H302: import only modules
# H304: no relative imports. # H304: no relative imports.
# H306: imports not in alphabetical order # H306: imports not in alphabetical order
# H401: docstring should not start with a space # H401: docstring should not start with a space
# H402: one line docstring needs punctuation # H402: one line docstring needs punctuation
# H403: multi line docstring end on new line # H403: multi line docstring end on new line
# H404: multi line docstring should start with a summary # H404: multi line docstring should start with a summary
ignore = H302,H304,H306,H401,H402,H403,H404 ignore = H304,H306,H401,H402,H403,H404
builtins = _ builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools,vendor exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools,vendor