Merge "Enable pep8 on ./tools directory"
This commit is contained in:
commit
e8b085293c
@ -137,7 +137,11 @@ def no_db_session_in_public_api(logical_line, filename):
|
||||
yield (0, "N309: public db api methods may not accept session")
|
||||
|
||||
|
||||
def use_timeutils_utcnow(logical_line):
|
||||
def use_timeutils_utcnow(logical_line, filename):
|
||||
# tools are OK to use the standard datetime module
|
||||
if "/tools/" in filename:
|
||||
return
|
||||
|
||||
msg = "N310: timeutils.utcnow() must be used instead of datetime.%s()"
|
||||
|
||||
datetime_funcs = ['now', 'utcnow']
|
||||
@ -361,6 +365,10 @@ def use_jsonutils(logical_line, filename):
|
||||
if "plugins/xenserver" in filename:
|
||||
return
|
||||
|
||||
# tools are OK to use the standard json module
|
||||
if "/tools/" in filename:
|
||||
return
|
||||
|
||||
msg = "N324: jsonutils.%(fun)s must be used instead of json.%(fun)s"
|
||||
|
||||
if "json." in logical_line:
|
||||
|
@ -41,16 +41,15 @@
|
||||
"""Display a subunit stream through a colorized unittest test runner."""
|
||||
|
||||
import heapq
|
||||
import subunit
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import subunit
|
||||
import testtools
|
||||
|
||||
|
||||
class _AnsiColorizer(object):
|
||||
"""
|
||||
A colorizer is an object that loosely wraps around a stream, allowing
|
||||
"""A colorizer is an object that loosely wraps around a stream, allowing
|
||||
callers to write text to the stream in a particular color.
|
||||
|
||||
Colorizer classes must implement C{supported()} and C{write(text, color)}.
|
||||
@ -62,8 +61,7 @@ class _AnsiColorizer(object):
|
||||
self.stream = stream
|
||||
|
||||
def supported(cls, stream=sys.stdout):
|
||||
"""
|
||||
A class method that returns True if the current platform supports
|
||||
"""A class method that returns True if the current platform supports
|
||||
coloring terminal output using this method. Returns False otherwise.
|
||||
"""
|
||||
if not stream.isatty():
|
||||
@ -85,8 +83,7 @@ class _AnsiColorizer(object):
|
||||
supported = classmethod(supported)
|
||||
|
||||
def write(self, text, color):
|
||||
"""
|
||||
Write the given text to the stream in the given color.
|
||||
"""Write the given text to the stream in the given color.
|
||||
|
||||
@param text: Text to be written to the stream.
|
||||
|
||||
@ -97,9 +94,7 @@ class _AnsiColorizer(object):
|
||||
|
||||
|
||||
class _Win32Colorizer(object):
|
||||
"""
|
||||
See _AnsiColorizer docstring.
|
||||
"""
|
||||
"""See _AnsiColorizer docstring."""
|
||||
def __init__(self, stream):
|
||||
import win32console
|
||||
red, green, blue, bold = (win32console.FOREGROUND_RED,
|
||||
@ -147,9 +142,7 @@ class _Win32Colorizer(object):
|
||||
|
||||
|
||||
class _NullColorizer(object):
|
||||
"""
|
||||
See _AnsiColorizer docstring.
|
||||
"""
|
||||
"""See _AnsiColorizer docstring."""
|
||||
def __init__(self, stream):
|
||||
self.stream = stream
|
||||
|
||||
|
@ -52,7 +52,7 @@ import sys
|
||||
from nova.i18n import _
|
||||
|
||||
|
||||
### Dump
|
||||
# Dump
|
||||
|
||||
|
||||
def dump_db(db_driver, db_name, db_url, migration_version, dump_filename):
|
||||
@ -69,11 +69,12 @@ def dump_db(db_driver, db_name, db_url, migration_version, dump_filename):
|
||||
db_driver.drop(db_name)
|
||||
|
||||
|
||||
### Diff
|
||||
# Diff
|
||||
|
||||
|
||||
def diff_files(filename1, filename2):
|
||||
pipeline = ['diff -U 3 %(filename1)s %(filename2)s' % locals()]
|
||||
pipeline = ['diff -U 3 %(filename1)s %(filename2)s'
|
||||
% {'filename1': filename1, 'filename2': filename2}]
|
||||
|
||||
# Use colordiff if available
|
||||
if subprocess.call(['which', 'colordiff']) == 0:
|
||||
@ -85,7 +86,7 @@ def diff_files(filename1, filename2):
|
||||
subprocess.check_call(cmd, shell=True)
|
||||
|
||||
|
||||
### Database
|
||||
# Database
|
||||
|
||||
|
||||
class Mysql(object):
|
||||
@ -97,7 +98,8 @@ class Mysql(object):
|
||||
|
||||
def dump(self, name, dump_filename):
|
||||
subprocess.check_call(
|
||||
'mysqldump -u root %(name)s > %(dump_filename)s' % locals(),
|
||||
'mysqldump -u root %(name)s > %(dump_filename)s'
|
||||
% {'name': name, 'dump_filename': dump_filename},
|
||||
shell=True)
|
||||
|
||||
|
||||
@ -110,7 +112,8 @@ class Postgresql(object):
|
||||
|
||||
def dump(self, name, dump_filename):
|
||||
subprocess.check_call(
|
||||
'pg_dump %(name)s > %(dump_filename)s' % locals(),
|
||||
'pg_dump %(name)s > %(dump_filename)s'
|
||||
% {'name': name, 'dump_filename': dump_filename},
|
||||
shell=True)
|
||||
|
||||
|
||||
@ -121,7 +124,7 @@ def _get_db_driver_class(db_url):
|
||||
raise Exception(_("database %s not supported") % db_url)
|
||||
|
||||
|
||||
### Migrate
|
||||
# Migrate
|
||||
|
||||
|
||||
MIGRATE_REPO = os.path.join(os.getcwd(), "nova/db/sqlalchemy/migrate_repo")
|
||||
@ -170,7 +173,7 @@ def _migrate_get_earliest_version():
|
||||
return versions[0]
|
||||
|
||||
|
||||
### Git
|
||||
# Git
|
||||
|
||||
|
||||
def git_current_branch_name():
|
||||
@ -196,7 +199,7 @@ def git_has_uncommited_changes():
|
||||
return subprocess.call(['git', 'diff', '--quiet', '--exit-code']) == 1
|
||||
|
||||
|
||||
### Command
|
||||
# Command
|
||||
|
||||
|
||||
def die(msg):
|
||||
|
@ -24,7 +24,6 @@ import re
|
||||
import sys
|
||||
|
||||
from pylint import lint
|
||||
from pylint.reporters import text
|
||||
|
||||
# Note(maoy): E1103 is error code related to partial type inference
|
||||
ignore_codes = ["E1103"]
|
||||
@ -130,7 +129,9 @@ class ErrorKeys(object):
|
||||
|
||||
def run_pylint():
|
||||
buff = StringIO.StringIO()
|
||||
args = ["--msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}", "-E", "nova"]
|
||||
args = ["--msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}",
|
||||
"-E",
|
||||
"nova"]
|
||||
lint.Run(args, exit=False)
|
||||
val = buff.getvalue()
|
||||
buff.close()
|
||||
|
2
tox.ini
2
tox.ini
@ -72,7 +72,7 @@ commands = python setup.py build_sphinx
|
||||
# E251 Skipped due to https://github.com/jcrocholl/pep8/issues/301
|
||||
|
||||
ignore = E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E251,H405,H803,H904
|
||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools
|
||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools/xenserver*
|
||||
# To get a list of functions that are more complex than 25, set max-complexity
|
||||
# to 25 and run 'tox -epep8'.
|
||||
# 46 is currently the most complex thing we have
|
||||
|
Loading…
x
Reference in New Issue
Block a user