Cleanup repo a bit
A couple of cleanups: * Cleanup setup.cfg * Remove openstack-common.conf and babel.cfg, they are not used. * Remove unused Babel dependency, update requirements * Update to hacking 2.0.0 and fix problems found Change-Id: Ibaa6d6dcc39734610fa21e953d790217dee4c979
This commit is contained in:
parent
d80e6a55e0
commit
fe239b16d6
|
@ -1,7 +0,0 @@
|
|||
[DEFAULT]
|
||||
|
||||
# The list of modules to copy from oslo-incubator.git
|
||||
module=install_venv_common
|
||||
|
||||
# The base module to hold the copy of openstack.common
|
||||
base=os_loganalyze
|
|
@ -31,19 +31,19 @@ SUPPORTS_SEV = re.compile(
|
|||
# other things we understand
|
||||
r'|(keystone|tempest)\.txt|syslog)')
|
||||
|
||||
SYSLOGDATE = '\w+\s+\d+\s+\d{2}:\d{2}:\d{2}((\.|\,)\d{3,6})?'
|
||||
DATEFMT = '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}((\.|\,)\d{3,6})?'
|
||||
STATUSFMT = '(DEBUG|INFO|WARNING|ERROR|TRACE|AUDIT|CRITICAL)'
|
||||
SYSLOGDATE = r'\w+\s+\d+\s+\d{2}:\d{2}:\d{2}((\.|\,)\d{3,6})?'
|
||||
DATEFMT = r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}((\.|\,)\d{3,6})?'
|
||||
STATUSFMT = r'(DEBUG|INFO|WARNING|ERROR|TRACE|AUDIT|CRITICAL)'
|
||||
|
||||
OSLO_LOGMATCH = '^(?P<date>%s)(?P<line>(?P<pid> \d+)? (?P<status>%s).*)' % \
|
||||
OSLO_LOGMATCH = r'^(?P<date>%s)(?P<line>(?P<pid> \d+)? (?P<status>%s).*)' % \
|
||||
(DATEFMT, STATUSFMT)
|
||||
SYSLOG_MATCH = ('^(?P<date>%s)(?P<line> (?P<host>[\w\-]+) '
|
||||
'(?P<service>[^\[\s]+):.*)' %
|
||||
SYSLOG_MATCH = (r'^(?P<date>%s)(?P<line> (?P<host>[\w\-]+) '
|
||||
r'(?P<service>[^\[\s]+):.*)' %
|
||||
(SYSLOGDATE))
|
||||
SYSTEMD_MATCH = (
|
||||
'^(?P<date>%s)(?P<line> (?P<host>\S+) \S+\[\d+\]\: (?P<status>%s)?.*)' %
|
||||
r'^(?P<date>%s)(?P<line> (?P<host>\S+) \S+\[\d+\]\: (?P<status>%s)?.*)' %
|
||||
(SYSLOGDATE, STATUSFMT))
|
||||
CONSOLE_MATCH = '^(?P<date>%s)(?P<line>.*)' % DATEFMT
|
||||
CONSOLE_MATCH = r'^(?P<date>%s)(?P<line>.*)' % DATEFMT
|
||||
|
||||
OSLORE = re.compile(OSLO_LOGMATCH)
|
||||
SYSLOGRE = re.compile(SYSLOG_MATCH)
|
||||
|
@ -79,7 +79,7 @@ class LogLine(object):
|
|||
return 'INFO'
|
||||
|
||||
def safe_date(self):
|
||||
return '_' + re.sub('[\s\:\.\,]', '_', self.date)
|
||||
return '_' + re.sub(r'[\s\:\.\,]', '_', self.date)
|
||||
|
||||
def _parse(self, line, old_sev):
|
||||
m = OSLORE.match(line)
|
||||
|
@ -128,7 +128,7 @@ class SevFilter(object):
|
|||
self.strip_control = False
|
||||
|
||||
def strip(self, line):
|
||||
return re.sub('\x1b\[(([03]\d)|\;)+m', '', line)
|
||||
return re.sub(r'\x1b\[(([03]\d)|\;)+m', '', line)
|
||||
|
||||
def __iter__(self):
|
||||
old_sev = "NONE"
|
||||
|
|
|
@ -164,9 +164,9 @@ def get_file_generator(environ, root_path, config=None):
|
|||
file_generator = DiskIterableBuffer(logname, logpath, config)
|
||||
|
||||
if not file_generator or not file_generator.obj:
|
||||
if (config.has_section('general') and
|
||||
config.has_option('general', 'generate_folder_index') and
|
||||
config.getboolean('general', 'generate_folder_index')):
|
||||
if (config.has_section('general')
|
||||
and config.has_option('general', 'generate_folder_index')
|
||||
and config.getboolean('general', 'generate_folder_index')):
|
||||
index_generator = IndexIterableBuffer(logname, logpath,
|
||||
config)
|
||||
if len(index_generator.file_list) > 0:
|
||||
|
|
|
@ -178,8 +178,8 @@ class TestWsgiDisk(base.TestCase):
|
|||
self.assertEqual(first, f.readline())
|
||||
|
||||
def test_config_no_filter(self):
|
||||
self.wsgi_config_file = (base.samples_path('samples') +
|
||||
'wsgi_plain.conf')
|
||||
self.wsgi_config_file = (base.samples_path('samples')
|
||||
+ 'wsgi_plain.conf')
|
||||
# Try to limit the filter to 10 lines, but we should get the full
|
||||
# amount.
|
||||
gen = self.get_generator('devstacklog.txt.gz', limit=10)
|
||||
|
@ -193,8 +193,8 @@ class TestWsgiDisk(base.TestCase):
|
|||
self.assertNotEqual(12, lines)
|
||||
|
||||
def test_config_passthrough_view(self):
|
||||
self.wsgi_config_file = (base.samples_path('samples') +
|
||||
'wsgi_plain.conf')
|
||||
self.wsgi_config_file = (base.samples_path('samples')
|
||||
+ 'wsgi_plain.conf')
|
||||
# Check there is no HTML on a file that should otherwise have it
|
||||
gen = self.get_generator('devstacklog.txt.gz')
|
||||
|
||||
|
@ -202,8 +202,8 @@ class TestWsgiDisk(base.TestCase):
|
|||
self.assertNotIn('<html>', first)
|
||||
|
||||
def test_file_conditions(self):
|
||||
self.wsgi_config_file = (base.samples_path('samples') +
|
||||
'wsgi_file_conditions.conf')
|
||||
self.wsgi_config_file = (base.samples_path('samples')
|
||||
+ 'wsgi_file_conditions.conf')
|
||||
# Check we are matching and setting the HTML filter
|
||||
gen = self.get_generator('devstacklog.txt.gz')
|
||||
|
||||
|
@ -255,8 +255,8 @@ class TestWsgiDisk(base.TestCase):
|
|||
self.assertEqual('Invalid Range', body)
|
||||
|
||||
def test_folder_index(self):
|
||||
self.wsgi_config_file = (base.samples_path('samples') +
|
||||
'wsgi_folder_index.conf')
|
||||
self.wsgi_config_file = (base.samples_path('samples')
|
||||
+ 'wsgi_folder_index.conf')
|
||||
gen = self.get_generator('')
|
||||
full = ''
|
||||
for line in gen:
|
||||
|
|
|
@ -77,8 +77,8 @@ def should_be_html(environ):
|
|||
log files kill their browser (as per a nova-api log).
|
||||
"""
|
||||
text_override = False
|
||||
accepts_html = ('HTTP_ACCEPT' in environ and
|
||||
'text/html' in environ['HTTP_ACCEPT'])
|
||||
accepts_html = ('HTTP_ACCEPT' in environ
|
||||
and 'text/html' in environ['HTTP_ACCEPT'])
|
||||
parameters = cgi.parse_qs(environ.get('QUERY_STRING', ''))
|
||||
if 'content-type' in parameters:
|
||||
ct = cgi.escape(parameters['content-type'][0])
|
||||
|
|
|
@ -39,91 +39,91 @@ def get_config(wsgi_config):
|
|||
|
||||
|
||||
def get_range(environ, start_response, view_generator):
|
||||
if '-' not in environ['HTTP_RANGE']:
|
||||
status = '400 Bad Request'
|
||||
response_headers = [('Content-type', 'text/plain')]
|
||||
start_response(status, response_headers)
|
||||
yield 'Invalid Range'
|
||||
return
|
||||
if '-' not in environ['HTTP_RANGE']:
|
||||
status = '400 Bad Request'
|
||||
response_headers = [('Content-type', 'text/plain')]
|
||||
start_response(status, response_headers)
|
||||
yield 'Invalid Range'
|
||||
return
|
||||
|
||||
_range = environ['HTTP_RANGE'].split('=')[1].split('-')
|
||||
_range = environ['HTTP_RANGE'].split('=')[1].split('-')
|
||||
|
||||
try:
|
||||
start = None
|
||||
if _range[0] is not '':
|
||||
start = int(_range[0])
|
||||
try:
|
||||
start = None
|
||||
if _range[0] != '':
|
||||
start = int(_range[0])
|
||||
|
||||
end = None
|
||||
if _range[1] is not '':
|
||||
end = int(_range[1])
|
||||
except ValueError:
|
||||
status = '400 Bad Request'
|
||||
response_headers = [('Content-type', 'text/plain')]
|
||||
start_response(status, response_headers)
|
||||
yield 'Invalid Range'
|
||||
return
|
||||
end = None
|
||||
if _range[1] != '':
|
||||
end = int(_range[1])
|
||||
except ValueError:
|
||||
status = '400 Bad Request'
|
||||
response_headers = [('Content-type', 'text/plain')]
|
||||
start_response(status, response_headers)
|
||||
yield 'Invalid Range'
|
||||
return
|
||||
|
||||
if start is None and end is None:
|
||||
status = '400 Bad Request'
|
||||
response_headers = [('Content-type', 'text/plain')]
|
||||
start_response(status, response_headers)
|
||||
yield 'Invalid Range'
|
||||
return
|
||||
if start is None and end is None:
|
||||
status = '400 Bad Request'
|
||||
response_headers = [('Content-type', 'text/plain')]
|
||||
start_response(status, response_headers)
|
||||
yield 'Invalid Range'
|
||||
return
|
||||
|
||||
# bytes=-5 means the last 5 bytes
|
||||
remainder = None
|
||||
if start is None:
|
||||
remainder = -end # this will be a negative index
|
||||
start = 0
|
||||
end = None
|
||||
# bytes=-5 means the last 5 bytes
|
||||
remainder = None
|
||||
if start is None:
|
||||
remainder = -end # this will be a negative index
|
||||
start = 0
|
||||
end = None
|
||||
|
||||
position = 0
|
||||
body = []
|
||||
position = 0
|
||||
body = []
|
||||
|
||||
status = '206 Partial Content'
|
||||
start_response(status, view_generator.headers)
|
||||
status = '206 Partial Content'
|
||||
start_response(status, view_generator.headers)
|
||||
|
||||
stop = False
|
||||
for chunk in view_generator:
|
||||
new_chunk = None
|
||||
stop = False
|
||||
for chunk in view_generator:
|
||||
new_chunk = None
|
||||
|
||||
if (position + len(chunk)) < start:
|
||||
# ignore this chunk
|
||||
position += len(chunk)
|
||||
elif position < start:
|
||||
# start is between position and position + len(chunk)
|
||||
# we only want a portion of this chunk
|
||||
offset = start - position
|
||||
if end and end < (position + len(chunk)):
|
||||
# the entire range is a subset of this chunk
|
||||
cutoff = end - position + 1
|
||||
new_chunk = chunk[offset:cutoff]
|
||||
stop = True # don't break until we have yielded
|
||||
else:
|
||||
new_chunk = chunk[offset:]
|
||||
position += len(chunk[offset:])
|
||||
elif end and end <= (position + len(chunk)):
|
||||
if (position + len(chunk)) < start:
|
||||
# ignore this chunk
|
||||
position += len(chunk)
|
||||
elif position < start:
|
||||
# start is between position and position + len(chunk)
|
||||
# we only want a portion of this chunk
|
||||
offset = start - position
|
||||
if end and end < (position + len(chunk)):
|
||||
# the entire range is a subset of this chunk
|
||||
cutoff = end - position + 1
|
||||
new_chunk = chunk[:cutoff]
|
||||
new_chunk = chunk[offset:cutoff]
|
||||
stop = True # don't break until we have yielded
|
||||
else:
|
||||
new_chunk = chunk
|
||||
position += len(chunk)
|
||||
new_chunk = chunk[offset:]
|
||||
position += len(chunk[offset:])
|
||||
elif end and end <= (position + len(chunk)):
|
||||
cutoff = end - position + 1
|
||||
new_chunk = chunk[:cutoff]
|
||||
stop = True # don't break until we have yielded
|
||||
else:
|
||||
new_chunk = chunk
|
||||
position += len(chunk)
|
||||
|
||||
if remainder and new_chunk:
|
||||
body.append(new_chunk)
|
||||
elif new_chunk:
|
||||
yield new_chunk
|
||||
if remainder and new_chunk:
|
||||
body.append(new_chunk)
|
||||
elif new_chunk:
|
||||
yield new_chunk
|
||||
|
||||
if stop:
|
||||
break
|
||||
if stop:
|
||||
break
|
||||
|
||||
if remainder:
|
||||
_body = ''.join(body)
|
||||
if len(_body) > -remainder: # remainder is negative
|
||||
yield _body[remainder:]
|
||||
else:
|
||||
yield _body
|
||||
if remainder:
|
||||
_body = ''.join(body)
|
||||
if len(_body) > -remainder: # remainder is negative
|
||||
yield _body[remainder:]
|
||||
else:
|
||||
yield _body
|
||||
|
||||
|
||||
def application(environ, start_response, root_path=None,
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
# The order of packages is significant, because pip processes them in the order
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
pbr>=1.6
|
||||
Babel>=1.3
|
||||
pbr>=2.0,!=2.1.0
|
||||
Jinja2>=2.6 # BSD License (3 clause)
|
||||
PyYAML>=3.1.0
|
||||
python-magic
|
||||
|
|
25
setup.cfg
25
setup.cfg
|
@ -5,7 +5,7 @@ description-file =
|
|||
README.rst
|
||||
author = OpenStack
|
||||
author-email = openstack-dev@lists.openstack.org
|
||||
home-page = http://www.openstack.org/
|
||||
home-page = https://www.openstack.org/
|
||||
classifier =
|
||||
Environment :: OpenStack
|
||||
Intended Audience :: Information Technology
|
||||
|
@ -15,7 +15,6 @@ classifier =
|
|||
Programming Language :: Python
|
||||
Programming Language :: Python :: 2
|
||||
Programming Language :: Python :: 2.7
|
||||
Programming Language :: Python :: 2.6
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3.3
|
||||
|
||||
|
@ -27,25 +26,3 @@ packages =
|
|||
console_scripts =
|
||||
htmlify-log.py = os_loganalyze.cmd.htmlify_log:main
|
||||
htmlify-server.py = os_loganalyze.cmd.htmlify_server:main
|
||||
|
||||
[build_sphinx]
|
||||
source-dir = doc/source
|
||||
build-dir = doc/build
|
||||
all_files = 1
|
||||
|
||||
[upload_sphinx]
|
||||
upload-dir = doc/build/html
|
||||
|
||||
[compile_catalog]
|
||||
directory = os_loganalyze/locale
|
||||
domain = os-loganalyze
|
||||
|
||||
[update_catalog]
|
||||
domain = os-loganalyze
|
||||
output_dir = os_loganalyze/locale
|
||||
input_file = os_loganalyze/locale/os-loganalyze.pot
|
||||
|
||||
[extract_messages]
|
||||
keywords = _ gettext ngettext l_ lazy_gettext
|
||||
mapping_file = babel.cfg
|
||||
output_file = os_loganalyze/locale/os-loganalyze.pot
|
|
@ -1,15 +1,14 @@
|
|||
# The order of packages is significant, because pip processes them in the order
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
hacking>=0.12.0,!=0.13.0,<0.14 # Apache-2.0
|
||||
|
||||
hacking>=2.0.0,<2.1.0 # Apache-2.0
|
||||
|
||||
coverage>=3.6
|
||||
discover
|
||||
fixtures>=1.3.1
|
||||
mock>=1.2
|
||||
python-subunit>=0.0.18
|
||||
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
|
||||
oslosphinx>=2.5.0 # Apache-2.0
|
||||
testrepository>=0.0.18
|
||||
testscenarios>=0.4
|
||||
testtools>=1.4.0
|
||||
|
|
10
tox.ini
10
tox.ini
|
@ -1,11 +1,11 @@
|
|||
[tox]
|
||||
minversion = 1.6
|
||||
envlist = py27,pypy,pep8
|
||||
minversion = 3.1.0
|
||||
envlist = py27,py36,pep8
|
||||
skipsdist = True
|
||||
ignore_basepython_conflict = True
|
||||
|
||||
[testenv]
|
||||
usedevelop = True
|
||||
install_command = pip install -U {opts} {packages}
|
||||
setenv =
|
||||
VIRTUAL_ENV={envdir}
|
||||
deps = -r{toxinidir}/requirements.txt
|
||||
|
@ -29,7 +29,9 @@ commands = python ./os_loganalyze/server.py -l {toxinidir}/os_loganalyze/tests/s
|
|||
|
||||
[flake8]
|
||||
# H904 Wrap long lines in parentheses instead of a backslash
|
||||
# W503 line break before binary operator
|
||||
# E741 ambiguous variable name 'l'
|
||||
show-source = True
|
||||
ignore = E123,E125,H803,H904
|
||||
ignore = E123,E125,E741,H803,H904,W503
|
||||
builtins = _
|
||||
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
|
||||
|
|
Loading…
Reference in New Issue