Enable H302 hacking check

This change requires hacking >0.5.5

Change-Id: Ic36fa0502548335d433f3fbe663854523dd04397
This commit is contained in:
Ann Kamyshnikova 2013-06-25 17:12:58 +04:00
parent dee8afb7f8
commit 1a2df89c05
41 changed files with 61 additions and 61 deletions

View File

@ -19,8 +19,8 @@ import base64
from Crypto.Hash import HMAC
from Crypto import Random
from openstack.common.gettextutils import _
from openstack.common.importutils import import_module
from openstack.common.gettextutils import _ # noqa
from openstack.common import importutils
class CryptoutilsException(Exception):
@ -54,7 +54,7 @@ class HKDF(object):
"""
def __init__(self, hashtype='SHA256'):
self.hashfn = import_module('Crypto.Hash.' + hashtype)
self.hashfn = importutils.import_module('Crypto.Hash.' + hashtype)
self.max_okm_length = 255 * self.hashfn.digest_size
def extract(self, ikm, salt=None):
@ -107,8 +107,8 @@ class SymmetricCrypto(object):
"""
def __init__(self, enctype='AES', hashtype='SHA256'):
self.cipher = import_module('Crypto.Cipher.' + enctype)
self.hashfn = import_module('Crypto.Hash.' + hashtype)
self.cipher = importutils.import_module('Crypto.Cipher.' + enctype)
self.hashfn = importutils.import_module('Crypto.Hash.' + hashtype)
def new_key(self, size):
return Random.new().read(size)

View File

@ -18,7 +18,7 @@
"""DB related custom exceptions."""
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
class DBError(Exception):

View File

@ -26,7 +26,7 @@ from sqlalchemy import Column, Integer
from sqlalchemy import DateTime
from sqlalchemy.orm import object_mapper
from openstack.common.db.sqlalchemy.session import get_session
from openstack.common.db.sqlalchemy import session as sa
from openstack.common import timeutils
@ -37,7 +37,7 @@ class ModelBase(object):
def save(self, session=None):
"""Save this object."""
if not session:
session = get_session()
session = sa.get_session()
# NOTE(boris-42): This part of code should be look like:
# sesssion.add(self)
# session.flush()

View File

@ -256,7 +256,7 @@ from sqlalchemy.pool import NullPool, StaticPool
from sqlalchemy.sql.expression import literal_column
from openstack.common.db import exception
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import log as logging
from openstack.common import timeutils

View File

@ -22,7 +22,7 @@
import sqlalchemy
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import log as logging

View File

@ -36,7 +36,7 @@ from xml.dom import minidom
from xml.parsers import expat
from openstack.common import exception
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import jsonutils
from openstack.common import log as logging
from openstack.common import service

View File

@ -31,7 +31,7 @@ import eventlet.backdoor
import greenlet
from oslo.config import cfg
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import log as logging
help_for_backdoor_port = 'Acceptable ' + \

View File

@ -21,7 +21,7 @@ Exceptions common to OpenStack projects
import logging
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
_FATAL_EXCEPTION_FORMAT_ERRORS = False

View File

@ -24,7 +24,7 @@ import sys
import time
import traceback
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
class save_and_reraise_exception(object):

View File

@ -21,7 +21,7 @@ import errno
import os
from openstack.common import excutils
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import log as logging
LOG = logging.getLogger(__name__)

View File

@ -28,7 +28,7 @@ from eventlet import semaphore
from oslo.config import cfg
from openstack.common import fileutils
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import local
from openstack.common import log as logging

View File

@ -42,7 +42,7 @@ import traceback
from oslo.config import cfg
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import importutils
from openstack.common import jsonutils
from openstack.common import local

View File

@ -22,7 +22,7 @@ import sys
from eventlet import event
from eventlet import greenthread
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import log as logging
from openstack.common import timeutils

View File

@ -23,7 +23,7 @@ import webob.dec
import webob.exc
from openstack.common.deprecated import wsgi
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common.middleware import base

View File

@ -19,7 +19,7 @@ import uuid
from oslo.config import cfg
from openstack.common import context
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import importutils
from openstack.common import jsonutils
from openstack.common import log as logging

View File

@ -16,7 +16,7 @@
from oslo.config import cfg
from openstack.common import context as req_context
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import log as logging
from openstack.common import rpc

View File

@ -18,7 +18,7 @@
from oslo.config import cfg
from openstack.common import context as req_context
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import log as logging
from openstack.common import rpc

View File

@ -18,7 +18,7 @@ import time
from oslo.config import cfg
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import log as logging
from openstack.common import timeutils

View File

@ -65,7 +65,7 @@ from oslo.config import cfg
import six
from openstack.common import fileutils
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import jsonutils
from openstack.common import log as logging

View File

@ -27,7 +27,7 @@ import signal
from eventlet.green import subprocess
from eventlet import greenthread
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import log as logging

View File

@ -29,7 +29,7 @@ import inspect
from oslo.config import cfg
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import importutils
from openstack.common import local
from openstack.common import log as logging

View File

@ -36,7 +36,7 @@ from eventlet import queue
from eventlet import semaphore
from openstack.common import excutils
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import local
from openstack.common import log as logging
from openstack.common.rpc import common as rpc_common

View File

@ -24,7 +24,7 @@ import traceback
from oslo.config import cfg
import six
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import importutils
from openstack.common import jsonutils
from openstack.common import local

View File

@ -30,7 +30,7 @@ import kombu.messaging
from oslo.config import cfg
from openstack.common import excutils
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import network_utils
from openstack.common.rpc import amqp as rpc_amqp
from openstack.common.rpc import common as rpc_common

View File

@ -25,7 +25,7 @@ import greenlet
from oslo.config import cfg
from openstack.common import excutils
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import importutils
from openstack.common import jsonutils
from openstack.common import log as logging

View File

@ -27,7 +27,7 @@ import greenlet
from oslo.config import cfg
from openstack.common import excutils
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import importutils
from openstack.common import jsonutils
from openstack.common.rpc import common as rpc_common

View File

@ -23,7 +23,7 @@ import contextlib
import eventlet
from oslo.config import cfg
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import log as logging

View File

@ -23,7 +23,7 @@ import json
from oslo.config import cfg
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import log as logging
from openstack.common.rpc import matchmaker as mm

View File

@ -17,7 +17,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import log as logging
from openstack.common import rpc
from openstack.common.rpc import dispatcher as rpc_dispatcher

View File

@ -32,7 +32,7 @@ import logging as std_logging
from oslo.config import cfg
from openstack.common import eventlet_backdoor
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common import importutils
from openstack.common import log as logging
from openstack.common import threadgroup

View File

@ -19,7 +19,7 @@ import ssl
from oslo.config import cfg
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
ssl_opts = [

View File

@ -25,7 +25,7 @@ import unicodedata
import six
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
# Used for looking up extensions of text

View File

@ -14,7 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from eventlet import greenlet
import eventlet
from eventlet import greenpool
from eventlet import greenthread
@ -105,7 +105,7 @@ class ThreadGroup(object):
for x in self.timers:
try:
x.wait()
except greenlet.GreenletExit:
except eventlet.greenlet.GreenletExit:
pass
except Exception as ex:
LOG.exception(ex)
@ -115,7 +115,7 @@ class ThreadGroup(object):
continue
try:
x.wait()
except greenlet.GreenletExit:
except eventlet.greenlet.GreenletExit:
pass
except Exception as ex:
LOG.exception(ex)

View File

@ -13,7 +13,7 @@
# under the License.
from oslo.config import cfg
from six import StringIO
import six
import webob
from openstack.common.middleware import sizelimit
@ -28,14 +28,14 @@ class TestLimitingReader(utils.BaseTestCase):
def test_limiting_reader(self):
BYTES = 1024
bytes_read = 0
data = StringIO("*" * BYTES)
data = six.StringIO("*" * BYTES)
for chunk in sizelimit.LimitingReader(data, BYTES):
bytes_read += len(chunk)
self.assertEquals(bytes_read, BYTES)
bytes_read = 0
data = StringIO("*" * BYTES)
data = six.StringIO("*" * BYTES)
reader = sizelimit.LimitingReader(data, BYTES)
byte = reader.read(1)
while len(byte) != 0:
@ -49,7 +49,7 @@ class TestLimitingReader(utils.BaseTestCase):
def _consume_all_iter():
bytes_read = 0
data = StringIO("*" * BYTES)
data = six.StringIO("*" * BYTES)
for chunk in sizelimit.LimitingReader(data, BYTES - 1):
bytes_read += len(chunk)
@ -58,7 +58,7 @@ class TestLimitingReader(utils.BaseTestCase):
def _consume_all_read():
bytes_read = 0
data = StringIO("*" * BYTES)
data = six.StringIO("*" * BYTES)
reader = sizelimit.LimitingReader(data, BYTES - 1)
byte = reader.read(1)
while len(byte) != 0:

View File

@ -27,7 +27,7 @@ import eventlet
from oslo.config import cfg
from openstack.common import exception
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from openstack.common.rpc import common as rpc_common
from openstack.common.rpc import dispatcher as rpc_dispatcher
from tests import utils as test_utils

View File

@ -29,7 +29,7 @@ import socket
import fixtures
from oslo.config import cfg
from openstack.common.gettextutils import _
from openstack.common.gettextutils import _ # noqa
from tests.unit.rpc import common
try:

View File

@ -19,7 +19,7 @@ import datetime
import xmlrpclib
import netaddr
from six import StringIO
import six
from openstack.common import jsonutils
from tests import utils
@ -34,7 +34,7 @@ class JSONUtilsTestCase(utils.BaseTestCase):
self.assertEqual(jsonutils.loads('{"a": "b"}'), {'a': 'b'})
def test_load(self):
x = StringIO('{"a": "b"}')
x = six.StringIO('{"a": "b"}')
self.assertEqual(jsonutils.load(x), {'a': 'b'})

View File

@ -21,12 +21,12 @@ import sys
import tempfile
from oslo.config import cfg
from six import StringIO
import six
from openstack.common import context
from openstack.common import jsonutils
from openstack.common import log
from openstack.common.log_handler import PublishErrorsHandler
from openstack.common import log_handler
from openstack.common.notifier import api as notifier
from tests import utils as test_utils
@ -131,7 +131,8 @@ class PublishErrorsHandlerTestCase(test_utils.BaseTestCase):
"""Tests for log.PublishErrorsHandler"""
def setUp(self):
super(PublishErrorsHandlerTestCase, self).setUp()
self.publiserrorshandler = PublishErrorsHandler(logging.ERROR)
self.publiserrorshandler = log_handler.\
PublishErrorsHandler(logging.ERROR)
def test_emit_cfg_log_notifier_in_notifier_drivers(self):
self.config(notification_driver=[
@ -367,7 +368,7 @@ class SetDefaultsTestCase(test_utils.BaseTestCase):
class LogConfigOptsTestCase(test_utils.BaseTestCase):
def test_print_help(self):
f = StringIO()
f = six.StringIO()
CONF([])
CONF.print_help(file=f)
self.assertTrue('debug' in f.getvalue())

View File

@ -23,7 +23,7 @@ import urllib2
import mock
from oslo.config import cfg
from six import StringIO
import six
from openstack.common import jsonutils
from openstack.common import policy
@ -779,7 +779,7 @@ class HttpCheckTestCase(PolicyBaseTestCase):
return result
@mock.patch.object(urllib2, 'urlopen',
return_value=StringIO('True'))
return_value=six.StringIO('True'))
def test_accept(self, mock_urlopen):
check = policy.HttpCheck('http', '//example.com/%(name)s')
@ -798,7 +798,7 @@ class HttpCheckTestCase(PolicyBaseTestCase):
))
@mock.patch.object(urllib2, 'urlopen',
return_value=StringIO('other'))
return_value=six.StringIO('other'))
def test_reject(self, mock_urlopen):
check = policy.HttpCheck('http', '//example.com/%(name)s')

View File

@ -21,7 +21,7 @@ import fixtures
import os
import tempfile
from six import StringIO
import six
from openstack.common import processutils
from tests import utils
@ -214,7 +214,7 @@ class FakeSshChannel(object):
return self.rc
class FakeSshStream(StringIO):
class FakeSshStream(six.StringIO):
def setup_channel(self, rc):
self.channel = FakeSshChannel(rc)
@ -226,9 +226,9 @@ class FakeSshConnection(object):
def exec_command(self, cmd):
stdout = FakeSshStream('stdout')
stdout.setup_channel(self.rc)
return (StringIO(),
return (six.StringIO(),
stdout,
StringIO('stderr'))
six.StringIO('stderr'))
class SshExecuteTestCase(utils.BaseTestCase):

View File

@ -13,7 +13,6 @@ commands =
[flake8]
show-source = True
ignore = H302
exclude = .venv,.tox,dist,doc,*.egg,.update-venv
[testenv:pep8]