Commit 6045932f authored by Vincent Pelletier's avatar Vincent Pelletier

Use pkgutil instead of pkg_resources.

parent fcdcc68b
......@@ -42,23 +42,16 @@ import itertools
import json
import math
import os
import pkgutil
import platform
import re
import shlex
import sys
import time
import traceback
try:
import pkg_resources
except ImportError:
# By default, assume resources are next to __file__
abs_file_container = os.path.abspath(os.path.dirname(__file__))
def getResource(name):
return open(os.path.join(abs_file_container, name)).read()
else:
abs_file_container = None
def getResource(name):
return pkg_resources.resource_string(__name__, name)
def getResource(name, encoding='utf-8'):
return pkgutil.get_data(__name__, name).decode(encoding)
FILE_OPENER_LIST = [
(gzip.open, IOError),
......@@ -1100,7 +1093,6 @@ def _scanstring(*args, **kw):
json.decoder.scanstring = _scanstring
def main():
global abs_file_container
parser = ShlexArgumentParser(description='Compute Apdex out of '
'apache-style log files', fromfile_prefix_chars='@')
parser.add_argument('logfile', nargs='*',
......@@ -1134,8 +1126,7 @@ def main():
group.add_argument('-s', '--stats', action='store_true',
help='Enable parsing stats (time spent parsing input, time spent '
'generating output, ...)')
group.add_argument('--js', default=abs_file_container,
help='Folder containing needed js files. Default: %(default)s')
group.add_argument('--js', help='Folder containing needed js files.')
group.add_argument('--js-embed', action='store_true',
help='Embed js files instead of linking to them.')
group.add_argument('--fixed-yrange', nargs='?', type=int, const=-1,
......@@ -1171,7 +1162,6 @@ def main():
'ignored. Useful to exclude monitoring systems.')
args = parser.parse_args()
abs_file_container = getattr(args, 'js', abs_file_container)
if DURATION_US_FORMAT in args.logformat:
getDuration = lambda x: int(x.group('duration'))
elif DURATION_S_FORMAT in args.logformat:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment