Merge "Update hacking for Python3"
This commit is contained in:
commit
c7e0ecdfc5
|
@ -25,8 +25,8 @@ import sys
|
|||
|
||||
from oslo_utils.encodeutils import safe_decode
|
||||
from oslo_utils.encodeutils import safe_encode
|
||||
import six.moves.urllib.parse as urlparse
|
||||
from six.moves import urllib
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
ADMIN = 'root'
|
||||
ADMIN_PASS = 'root'
|
||||
|
@ -46,8 +46,8 @@ def format_response(req):
|
|||
try:
|
||||
json_value = json.loads(req.read())
|
||||
if (len(json_value['results'][0]) > 0 and
|
||||
'series' in json_value['results'][0] and
|
||||
'values' in json_value['results'][0]['series'][0]):
|
||||
'series' in json_value['results'][0] and
|
||||
'values' in json_value['results'][0]['series'][0]):
|
||||
return json_value['results'][0]['series'][0]['values']
|
||||
else:
|
||||
return []
|
||||
|
@ -77,7 +77,8 @@ def influxdb_get_post(uri, query, db=None):
|
|||
"""Runs a query using HTTP GET or POST and returns the response as a Python list.
|
||||
At some InfluxDB release several ops changed from using GET to POST. For example,
|
||||
CREATE DATABASE. To maintain backward compatibility, this function first trys the
|
||||
query using POST and if that fails it retries again using GET."""
|
||||
query using POST and if that fails it retries again using GET.
|
||||
"""
|
||||
|
||||
query_params = {"q": query}
|
||||
if db:
|
||||
|
@ -115,10 +116,12 @@ def main(argv=None):
|
|||
query="SHOW RETENTION POLICIES ON {0}".format(DBNAME))
|
||||
if not any(pol[0] == SHARDSPACE_NAME for pol in policies):
|
||||
# Set retention policy
|
||||
policy = "CREATE RETENTION POLICY {0} ON {1} DURATION {2} REPLICATION {3} DEFAULT".format(SHARDSPACE_NAME,
|
||||
DBNAME,
|
||||
RETENTION,
|
||||
REPLICATION)
|
||||
policy = ("CREATE RETENTION POLICY {0} ON {1} DURATION {2} "
|
||||
"REPLICATION {3} DEFAULT".format(SHARDSPACE_NAME,
|
||||
DBNAME,
|
||||
RETENTION,
|
||||
REPLICATION)
|
||||
)
|
||||
influxdb_get_post(uri=api_uri, db=DBNAME, query=policy)
|
||||
|
||||
# Create the users
|
||||
|
@ -130,5 +133,6 @@ def main(argv=None):
|
|||
.format(name, password)),
|
||||
db=DBNAME)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
"""Health check will returns 0 when service is working properly."""
|
||||
|
||||
import logging
|
||||
from urllib import request
|
||||
import os
|
||||
import sys
|
||||
from urllib import request
|
||||
|
||||
|
||||
LOG_LEVEL = logging.getLevelName(os.environ.get('LOG_LEVEL', 'INFO'))
|
||||
|
|
|
@ -22,7 +22,6 @@ extras==1.0.0
|
|||
falcon==2.0.0
|
||||
fasteners==0.7.0
|
||||
fixtures==3.0.0
|
||||
flake8==2.5.5
|
||||
funcsigs==1.0.0
|
||||
future==0.16.0
|
||||
futures==3.0.0
|
||||
|
@ -30,7 +29,6 @@ gevent==1.2.2
|
|||
gitdb==0.6.4
|
||||
GitPython==1.0.1
|
||||
greenlet==0.4.10
|
||||
hacking==1.1.0
|
||||
httplib2==0.9.1
|
||||
idna==2.6
|
||||
imagesize==0.7.1
|
||||
|
@ -72,13 +70,11 @@ paramiko==2.0.0
|
|||
PasteDeploy==1.5.0
|
||||
Paste==2.0.2
|
||||
pbr==2.0.0
|
||||
pep8==1.5.7
|
||||
positional==1.2.1
|
||||
prettytable==0.7.2
|
||||
pyasn1==0.1.8
|
||||
pycadf==1.1.0
|
||||
pycparser==2.18
|
||||
pyflakes==0.8.1
|
||||
Pygments==2.2.0
|
||||
pyinotify==0.9.6
|
||||
PyMySQL==0.7.6
|
||||
|
|
|
@ -21,5 +21,6 @@ from monasca_api.api import server
|
|||
def main():
|
||||
return server.get_wsgi_app(config_base_path='/etc/monasca')
|
||||
|
||||
|
||||
if __name__ == '__main__' or __name__.startswith('_mod_wsgi'):
|
||||
application = main()
|
||||
|
|
|
@ -111,41 +111,41 @@ def do_version():
|
|||
|
||||
|
||||
def add_command_parsers(subparsers):
|
||||
parser = subparsers.add_parser('fingerprint',
|
||||
help="Compute SHA1 fingerprint of "
|
||||
"current database schema ")
|
||||
parser.add_argument('-r', '--raw', action='store_true',
|
||||
help='Print raw schema dump used for '
|
||||
'fingerprinting')
|
||||
parser.set_defaults(func=do_fingerprint)
|
||||
parser = subparsers.add_parser('fingerprint',
|
||||
help="Compute SHA1 fingerprint of "
|
||||
"current database schema ")
|
||||
parser.add_argument('-r', '--raw', action='store_true',
|
||||
help='Print raw schema dump used for '
|
||||
'fingerprinting')
|
||||
parser.set_defaults(func=do_fingerprint)
|
||||
|
||||
parser = subparsers.add_parser('detect-revision',
|
||||
help="Attempt to detect revision "
|
||||
"matching current database "
|
||||
" schema ")
|
||||
parser.set_defaults(func=do_detect_revision)
|
||||
parser = subparsers.add_parser('detect-revision',
|
||||
help="Attempt to detect revision "
|
||||
"matching current database "
|
||||
" schema ")
|
||||
parser.set_defaults(func=do_detect_revision)
|
||||
|
||||
parser = subparsers.add_parser('stamp', help='Stamp database with an '
|
||||
'Alembic revision')
|
||||
parser.add_argument('revision', nargs='?', metavar='VERSION',
|
||||
help='Revision to stamp database with',
|
||||
default=None)
|
||||
parser.add_argument('-f', '--from-fingerprint', action='store_true',
|
||||
help='Try to determine VERSION from fingerprint')
|
||||
parser.set_defaults(func=do_stamp)
|
||||
parser = subparsers.add_parser('stamp', help='Stamp database with an '
|
||||
'Alembic revision')
|
||||
parser.add_argument('revision', nargs='?', metavar='VERSION',
|
||||
help='Revision to stamp database with',
|
||||
default=None)
|
||||
parser.add_argument('-f', '--from-fingerprint', action='store_true',
|
||||
help='Try to determine VERSION from fingerprint')
|
||||
parser.set_defaults(func=do_stamp)
|
||||
|
||||
parser = subparsers.add_parser('upgrade',
|
||||
help='Upgrade database to given or '
|
||||
'latest revision')
|
||||
parser.add_argument('revision', metavar='VERSION', nargs='?',
|
||||
help='Alembic revision to upgrade database to',
|
||||
default='head')
|
||||
parser.add_argument('-f', '--from-fingerprint', action='store_true',
|
||||
help='Try to determine VERSION from fingerprint')
|
||||
parser.set_defaults(func=do_upgrade)
|
||||
parser = subparsers.add_parser('upgrade',
|
||||
help='Upgrade database to given or '
|
||||
'latest revision')
|
||||
parser.add_argument('revision', metavar='VERSION', nargs='?',
|
||||
help='Alembic revision to upgrade database to',
|
||||
default='head')
|
||||
parser.add_argument('-f', '--from-fingerprint', action='store_true',
|
||||
help='Try to determine VERSION from fingerprint')
|
||||
parser.set_defaults(func=do_upgrade)
|
||||
|
||||
parser = subparsers.add_parser('version', help="Show database's current Alembic version")
|
||||
parser.set_defaults(func=do_version)
|
||||
parser = subparsers.add_parser('version', help="Show database's current Alembic version")
|
||||
parser.set_defaults(func=do_version)
|
||||
|
||||
|
||||
command_opt = cfg.SubCommandOpt('command',
|
||||
|
|
|
@ -78,5 +78,6 @@ def run_migrations_online():
|
|||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
if have_context:
|
||||
run_migrations_online()
|
||||
|
|
|
@ -221,6 +221,7 @@ def periodsValidation(instr, loc, tokens):
|
|||
# Must return the string
|
||||
return tokens[0]
|
||||
|
||||
|
||||
# Initialize non-ascii unicode code points in the Basic Multilingual Plane.
|
||||
unicode_printables = u''.join(
|
||||
six.unichr(c) for c in range(128, 65536) if not six.unichr(c).isspace())
|
||||
|
|
|
@ -14,17 +14,15 @@
|
|||
|
||||
import re
|
||||
|
||||
from hacking import core
|
||||
|
||||
assert_no_xrange_re = re.compile(r"\s*xrange\s*\(")
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def no_xrange(logical_line):
|
||||
"""Do not use 'xrange'
|
||||
B319
|
||||
"""
|
||||
if assert_no_xrange_re.match(logical_line):
|
||||
yield (0, "B319: Do not use xrange().")
|
||||
|
||||
|
||||
def factory(register):
|
||||
register(no_xrange)
|
||||
|
|
|
@ -180,6 +180,7 @@ def _hex_to_unicode(hex_raw):
|
|||
hex_str = hex_str_raw.decode('utf-8', 'replace')
|
||||
return hex_str
|
||||
|
||||
|
||||
# NOTE(trebskit) => http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
|
||||
UNICODE_MESSAGES = [
|
||||
# Unicode is evil...
|
||||
|
|
|
@ -103,7 +103,7 @@ class TestTimestampsValidation(base.BaseTestCase):
|
|||
try:
|
||||
helpers.validate_start_end_timestamps(start_timestamp,
|
||||
end_timestamp)
|
||||
except:
|
||||
except Exception:
|
||||
self.fail("shouldn't happen")
|
||||
|
||||
def test_same_timestamps(self):
|
||||
|
@ -156,6 +156,7 @@ class TestConvertTimeString(base.BaseTestCase):
|
|||
ValueError,
|
||||
helpers._convert_time_string, date_time_string)
|
||||
|
||||
|
||||
valid_periods = [0, 60]
|
||||
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ def validate_alarm_action_list(v):
|
|||
def validate_undetermined_action_list(v):
|
||||
validate_action_list(v, 'UNDETERMINED')
|
||||
|
||||
|
||||
alarm_definition_schema = {
|
||||
Required('name'): All(Any(str, six.text_type), Length(max=255)),
|
||||
Required('expression'): All(Any(str, six.text_type)),
|
||||
|
|
|
@ -713,7 +713,7 @@ def paginate_statistics(statistics, uri, limit):
|
|||
|
||||
def create_alarms_count_next_link(uri, offset, limit):
|
||||
if offset is None:
|
||||
offset = 0
|
||||
offset = 0
|
||||
parsed_url = urlparse.urlparse(uri)
|
||||
base_url = build_base_uri(parsed_url)
|
||||
new_query_params = [u'offset=' + urlparse.quote(str(offset + limit))]
|
||||
|
|
|
@ -173,9 +173,9 @@ htmlhelp_basename = 'MonitoringApiReleaseNotesDoc'
|
|||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [(
|
||||
master_doc, 'MonitoringApiReleaseNotes.tex',
|
||||
u'Monitoring API Release Notes', [author],
|
||||
'manual'
|
||||
master_doc, 'MonitoringApiReleaseNotes.tex',
|
||||
u'Monitoring API Release Notes', [author],
|
||||
'manual'
|
||||
)]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# Hacking already pins down pep8, pyflakes and flake8
|
||||
bandit>=1.1.0 # Apache-2.0
|
||||
bashate>=0.5.1 # Apache-2.0
|
||||
hacking>=1.1.0,<1.2.0 # Apache-2.0
|
||||
hacking>=3.0,<3.1.0 # Apache-2.0
|
||||
Babel!=2.4.0,>=2.3.4 # BSD
|
||||
coverage!=4.4,>=4.0 # Apache-2.0
|
||||
cassandra-driver!=3.6.0,>=3.3.0 # Apache-2.0
|
||||
|
|
8
tox.ini
8
tox.ini
|
@ -144,7 +144,8 @@ commands = bindep test
|
|||
# H201 no 'except:' at least use 'except Exception:'
|
||||
# H302 import only modules
|
||||
# H405 multi line docstring summary not separated with an empty line
|
||||
ignore = F821,H201,H302,H405
|
||||
# W504 line break after binary operator
|
||||
ignore = F821,H201,H302,H405,W504
|
||||
# H106: Don't put vim configuration in source files
|
||||
# H203: Use assertIs(Not)None to check for None
|
||||
# H204: Use assert(Not)Equal to check for equality.
|
||||
|
@ -161,6 +162,11 @@ local-check-factory = monasca_api.hacking.checks.factory
|
|||
import_exceptions =
|
||||
six.moves
|
||||
|
||||
[flake8:local-plugins]
|
||||
extension =
|
||||
B319 = checks:no_xrange
|
||||
paths = ./monasca_api/hacking
|
||||
|
||||
[testenv:lower-constraints]
|
||||
deps =
|
||||
-c{toxinidir}/lower-constraints.txt
|
||||
|
|
Loading…
Reference in New Issue