[Git][NTPsec/ntpsec][master] 2 commits: ntpviz: fix png filenames to not break Windows.
Gary E. Miller
gitlab at mg.gitlab.com
Sat Sep 22 19:20:02 UTC 2018
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
84700837 by Gary E. Miller at 2018-09-22T19:07:57Z
ntpviz: fix png filenames to not break Windows.
- - - - -
8eff6897 by Gary E. Miller at 2018-09-22T19:14:37Z
ntpviz: pycodestyle cleanups
- - - - -
1 changed file:
- ntpclients/ntpviz.py
Changes:
=====================================
ntpclients/ntpviz.py
=====================================
@@ -387,6 +387,7 @@ def gnuplot_fmt(min, max):
def gnuplot(template, outfile=None):
"Run a specified gnuplot program."
+
if not len(template):
# silently ignore empty plots
return ''
@@ -955,7 +956,7 @@ plot \
try:
ip = socket.gethostbyname(key)
namelist.append(key)
- except:
+ except socket.error:
# ignore it
ip = key
# socket.getfqdn() is also flakey...
@@ -1479,7 +1480,7 @@ Python by ESR, concept and gnuplot code by Dan Drown.
action="store_true",
dest='nice',
help="Run as lowest priority")
- except:
+ except OSError:
pass
parser.add_argument('-V', '--version',
@@ -1867,7 +1868,7 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
if len(statlist) > 1:
index_buffer += local_offset_multiplot(statlist)
else:
- # imagepairs in the order of the heml entries
+ # imagepairs in the order of the html entries
imagepairs = [
("local-offset", stats.local_offset_gnuplot()),
# skipa next one, redundant to one above
@@ -1902,15 +1903,17 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
sys.stderr.write("ntpviz: plotting %s\n" % image['title'])
stats.append(image['stats'])
# give each H2 an unique ID.
- id = image['title'].lower()
- id = id.replace(' ', '_').replace(':', '_')
+ id = image['title'].lower().replace(' ', '_').replace(':', '_')
+
index_buffer += """\
<div id="%s">\n<h2><a class="section" href="#%s">%s</a></h2>
""" % (id, id, image['title'])
div_name = imagename.replace('-', ' ')
- index_buffer += imagewrapper % \
- (imagename.replace(':', '%3A'), div_name)
+ # Windows hates colons in filename
+ imagename = imagename.replace(':', '-')
+ index_buffer += imagewrapper % (imagename, div_name)
+
if image['html']:
index_buffer += "<div>\n%s</div>\n" % image['html']
index_buffer += "<br><br>\n"
@@ -1977,7 +1980,7 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
try:
os.remove(csv_filename)
os.remove(index_filename)
- except:
+ except OSError:
pass
os.rename(csv_filename + ".tmp", csv_filename)
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/84339f7b1b238b49c1991a71a03e4ae74c5511d9...8eff6897b6b7423c5c3abff5a7a8e6071c2c100c
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/84339f7b1b238b49c1991a71a03e4ae74c5511d9...8eff6897b6b7423c5c3abff5a7a8e6071c2c100c
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20180922/730d15c6/attachment-0001.html>
More information about the vc
mailing list