[Git][NTPsec/ntpsec][master] Fix various small bugs in the ntpviz prototype.

Eric S. Raymond gitlab at mg.gitlab.com
Thu Aug 11 13:41:51 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
c0b3604e by Eric S. Raymond at 2016-08-11T09:41:09-04:00
Fix various small bugs in the ntpviz prototype.

- - - - -


2 changed files:

- ntpstats/ntpstats.py
- ntpstats/ntpviz


Changes:

=====================================
ntpstats/ntpstats.py
=====================================
--- a/ntpstats/ntpstats.py
+++ b/ntpstats/ntpstats.py
@@ -137,7 +137,7 @@ set rmargin 12
 plot \
  "-" using 1:($2*1000000) title "clock offset us" with linespoints ls 1, \
  "-" using 1:3 title "frequency offset ppm" with linespoints ls 2 axis x1y2
-"""
+""" % locals()
         return plot_template.replace('@', '%') + self.dump("loopstats") + "e\n" + self.dump("loopstats")
     def loopstats_gnuplot(self, fld, title, legend):
         "Generate GNUPLOT code of a given loopstats field"
@@ -218,7 +218,7 @@ plot \\
             if key in peerdict:
                 plot_template += "\n".join(peerdict[key]) + "\ne\n"
             else:
-                stderr.write("No such peer as %s" % key)
+                sys.stderr.write("No such peer as %s" % key)
                 raise SystemExit(1)
         return plot_template[:-2]
     def peer_offsets_gnuplot(self, peerlist):


=====================================
ntpstats/ntpviz
=====================================
--- a/ntpstats/ntpviz
+++ b/ntpstats/ntpviz
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-"""
+"""\
 ntpviz - logfile visualizer for NTP log files
 
 Usage: ntpviz [-d statsdir] [-g] [-n name] [-p period] [-s starttime]
@@ -8,9 +8,8 @@ Usage: ntpviz [-d statsdir] [-g] [-n name] [-p period] [-s starttime]
               [--peer-jitters hosts | --all-peer-jitters]
 
 See the manual page for details.
-
-SPDX-License-Identifier: BSD-2-Clause
 """
+#SPDX-License-Identifier: BSD-2-Clause
 from __future__ import print_function, division
 
 import os, sys, getopt
@@ -18,7 +17,7 @@ from ntpstats import *
 
 if __name__ == '__main__':
     try:
-        (options, arguments) = getopt.getopt(sys.argv[1:], "d:gn:p:s:", [
+        (options, arguments) = getopt.getopt(sys.argv[1:], "d:ghn:p:s:", [
             "local-offset", "local-jitter", "local-stability",
             "all-peer-offsets", "peer-offsets=",
             "all-peer-jitters", "peer-jitters=",
@@ -40,6 +39,9 @@ if __name__ == '__main__':
             statsdir = val
         elif switch == "-g":
             generate = True
+        elif switch == "-h":
+            sys.stdout.write(__doc__)
+            raise SystemExit(0)
         elif switch == "-n":
             sitename = val
         elif switch == "-p":
@@ -71,11 +73,14 @@ if __name__ == '__main__':
         stats.sitename = os.path.basename(statsdir)
     if starttime:
         stats.clip(starttime, starttime + period)
-        
-    if os.path.exists("/usr/share/fonts/liberation"):
-        os.environ["GDFONTPATH"] = "/usr/share/fonts/liberation"
-    elif os.path.exists("/usr/share/fonts/truetype/liberation"):
-        os.environ["GDFONTPATH"] = "/usr/share/fonts/truetype/liberation"
+
+    for fontpath in ("/usr/share/fonts/liberation",
+                     "/usr/share/fonts/liberation-fonts",
+                     "/usr/share/fonts/truetype/liberation"):
+
+        if os.path.exists(fontpath):
+            os.environ["GDFONTPATH"] = fontpath
+            break
     else:
         sys.stderr.write("warning: liberation truetype fonts not found\n")
     os.environ["GNUPLOT_DEFAULT_GDFONT"] = "LiberationSans-Regular"



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/c0b3604e50c40766bfdeac267a7c264e316536f1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160811/810f52a6/attachment.html>


More information about the vc mailing list