-
Notifications
You must be signed in to change notification settings - Fork 39
/
makeMeta.py
65 lines (53 loc) · 2.45 KB
/
makeMeta.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# REDPy - Repeating Earthquake Detector in Python
# Copyright (C) 2016-2020 Alicia Hotovec-Ellis (ahotovec-ellis@usgs.gov)
# Licensed under GNU GPLv3 (see LICENSE.txt)
import argparse
import numpy as np
import os
"""
Run this script to generate 'meta.html' in a specified directory and with a list of runs.
This page gathers the 'meta_recent.html' tabbed overviews within the output directories
into a single page.
usage: makeMeta.py [-h] [-v] [-p PATH] [-r RUNS] [-t TOPATH]
optional arguments:
-h, --help show this help message and exit
-v, --verbose increase written print statements
-p PATH, --path PATH relative path to where meta.html should be created (e.g., ./)
and ending in /
-r RUNS, --runs RUNS comma-separated list of runs to include, which should match their
groupName
-t TOPATH, --topath TOPATH
relative path from meta.html to the runs, ending in /
"""
parser = argparse.ArgumentParser(description=
"""Run this script to generate 'meta.html' in a specified directory and with a list
of runs. This page gathers the 'meta_recent.html' tabbed overviews within the
output directories into a single page.""")
parser.add_argument("-v", "--verbose", action="count", default=0,
help="increase written print statements")
parser.add_argument("-p", "--path",
help="relative path to where meta.html should be created (e.g., ./) and ending in /",
default='./')
parser.add_argument("-r", "--runs",
help="comma-separated list of runs to include, which should match their groupName")
parser.add_argument("-t", "--topath",
help="relative path from meta.html to the runs, ending in /", default='./')
args = parser.parse_args()
filename = '{}meta.html'.format(args.path)
if args.verbose: print("Creating {}...".format(filename))
if args.runs:
if args.verbose: print("Looping over runs: {}".format(args.runs))
runs = args.runs
else:
print("No runs supplied, assuming 'default' only")
runs = 'default'
with open(filename, 'w') as f:
f.write('<html><head><title>REDPy Meta Overview</title></head>')
f.write('<body style="padding:0;margin:0">')
for run in runs.split(','):
f.write("""
<iframe src="{0}{1}/meta_recent.html" title="{1}"
style="height:350px;width:1300px;border:none;"></iframe>
""".format(args.topath,run))
f.write('</body></html>')
if args.verbose: print("Done")