From fb1b6e58d10a9a5368c1f36f196304177a2de651 Mon Sep 17 00:00:00 2001 From: Thomas Rueckstiess Date: Tue, 6 Jan 2015 12:13:40 +1100 Subject: error msg if template missing. break lines at 80 chars. better help texts. --- tools/wtstats.py | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'tools') diff --git a/tools/wtstats.py b/tools/wtstats.py index 4bacc638587..86585547dde 100755 --- a/tools/wtstats.py +++ b/tools/wtstats.py @@ -1,7 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. -# Public Domain 2008-2014 WiredTiger, Inc. +# Public Domain 2008-2015 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. # @@ -89,22 +88,24 @@ def munge(args, title, values): import argparse def main(): - parser = argparse.ArgumentParser(description='Create graphs from WiredTiger statistics.') + parser = argparse.ArgumentParser(description='Create graphs from \ + WiredTiger statistics.') parser.add_argument('--all', '-A', action='store_true', - help='generate all series as separate HTML output files by category') + help='generate separate html files for each stats group') parser.add_argument('--clear', action='store_true', help='WiredTiger stats gathered with clear set') parser.add_argument('--include', '-I', metavar='regexp', type=re.compile, action='append', - help='include series with titles matching the specifed regexp') + help='only include series with titles matching regexp') parser.add_argument('--list', action='store_true', - help='list the series that would be displayed') + help='only list the parsed series, does not create html file') parser.add_argument('--output', '-o', metavar='file', default='wtstats', help='HTML output file prefix') parser.add_argument('--json', action='store_true', - help='output data series as json format') + help='additionally output data series in json format') parser.add_argument('files', metavar='file', nargs='+', - help='input files or directories generated by WiredTiger statistics logging') + help='input files or directories generated by WiredTiger statistics \ + logging') args = parser.parse_args() # Read the input file(s) into a dictionary of lists. @@ -196,8 +197,14 @@ def main(): # load template this_path = os.path.dirname(os.path.realpath(__file__)) srcfile = os.path.join(this_path, 'wtstats.html.template') - srcfile = open(srcfile) - contents = srcfile.read() + try: + srcfile = open(srcfile) + contents = srcfile.read() + except IOError: + print >>sys.stderr, "Cannot find template file 'wtstats.html.\ + template'. See ./template/README.md for more information." + sys.exit(-1) + srcfile.close() # if --json write data to .json @@ -209,7 +216,8 @@ def main(): # write output file dstfile = open(outputname, 'wt') - replaced_contents = contents.replace('"### INSERT DATA HERE ###"', json.dumps(json_output)) + replaced_contents = contents.replace('"### INSERT DATA HERE ###"', + json.dumps(json_output)) dstfile.write(replaced_contents) dstfile.close() print "created %s" % dstfile.name -- cgit v1.2.1