Commit ff49a276 authored by Vincent Pelletier's avatar Vincent Pelletier

As a single file is generated, allow using stdout and specifying file name.

parent 3a47b90d
...@@ -384,9 +384,8 @@ def main(): ...@@ -384,9 +384,8 @@ def main():
default='%h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i" %D', default='%h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i" %D',
help='Apache LogFormat used to generate provided logs. ' help='Apache LogFormat used to generate provided logs. '
'Default: %(default)r') 'Default: %(default)r')
parser.add_argument('-o', '--out', default=os.getcwd(), parser.add_argument('-o', '--out', default='-',
help='Directory in which statistic files will be generated. ' help='Filename to write output to. Use - for stdout. Default: %(default)s')
'Default: %(default)s')
parser.add_argument('-q', '--quiet', action='store_true', parser.add_argument('-q', '--quiet', action='store_true',
help='Suppress warnings about malformed lines.') help='Suppress warnings about malformed lines.')
parser.add_argument('--js', parser.add_argument('--js',
...@@ -520,8 +519,11 @@ def main(): ...@@ -520,8 +519,11 @@ def main():
all_lines += lineno all_lines += lineno
sys.stderr.write('%i\n' % lineno) sys.stderr.write('%i\n' % lineno)
end_parsing_time = time.time() end_parsing_time = time.time()
os.chdir(args.out) if args.out == '-':
with open('index.html', 'w') as out: out = sys.stdout
else:
out = open(args.out, 'w')
with out:
out.write('<html><head><title>Stats</title><style>' out.write('<html><head><title>Stats</title><style>'
'.stats th, .stats td { border: solid 1px #000; } ' '.stats th, .stats td { border: solid 1px #000; } '
'.stats th { text-align: center; } ' '.stats th { text-align: center; } '
......
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