Skip to content
Snippets Groups Projects
Commit 59dc7e80 authored by Gary E. Miller's avatar Gary E. Miller :speech_balloon:
Browse files

Use a 'title' file if present in the output directory.

I run 8 copies of ntpviz, now I can tell them apart.
parent 45a4e9b8
No related branches found
No related tags found
Loading
......@@ -105,8 +105,9 @@ named 'ntpgraphs', but the name can be changed with the -o option.
Warning: existing PNG files and index.html in this directory will be
clobbered.
When an index is generated, ntpviz will look for two files in the
output directory. Neither file need be present, and both files may
When an index is generated, ntpviz will look for three files in the
output directory. None of the files need be present, and the
'header' and 'footer' files may contain arbitrary html.
contain aribtrary HTML.
The first file is named 'header'. The contents of that file will be
......@@ -120,6 +121,9 @@ added almost at the bottom of the body on the generated index.
It is suggested that notes on the server be included in the footer
file: OS, versions, CPU speed, etc. You may also put links there.
The thrid file is named 'title' and must be a single line of text. This
text will be used as the HTML title of the generated index.
The code includes various sanity checks and will bail out with a message to
standard error on, for example, missing logfile data required for a plot.
......
......@@ -820,6 +820,19 @@ at 0s. Typical 90% ranges may be: local serial GPS 200 ms; local LAN peer
""",
}
start_time = datetime.datetime.utcnow()
start_time_str = start_time.strftime("%c")
# if title file, get title from it
title_f = os.path.join(outdir, "title")
title = 'ntpviz'
if os.path.isfile(title_f):
try:
title_file = open( title_f, 'r')
title = title_file.read()
except IOError:
pass
index_header = '''\
<!DOCTYPE html>
<html lang="en">
......@@ -827,7 +840,7 @@ at 0s. Typical 90% ranges may be: local serial GPS 200 ms; local LAN peer
<meta charset="UTF-8">
<meta http-equiv="refresh" content="1800">
<meta name="expires" content="0">
<title>ntpviz plot</title>
<title>%(title)s</title>
<style>
dt {
font-weight: bold;
......@@ -845,11 +858,10 @@ dd {
<img src="ntpsec-logo.png" alt="NTPsec" style="float:left;margin:5px 50px;">
</a>
<div>
<h1 style="margin-bottom:10px;">NTP Stats</h1>
'''
<h1 style="margin-bottom:10px;">%(title)s</h1>
Report generated: %(start_time_str)s UTC <br>
''' % locals()
start_time = datetime.datetime.utcnow()
index_header += 'Report generated: %s UTC <br>' % start_time.strftime("%c")
# Ugh. Not clear what to do in the multiplot case
if len(statlist) == 1:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment