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