[Git][NTPsec/ntpsec][master] ntpviz: add a nice error message when gnuplot not found

Gary E. Miller gitlab at mg.gitlab.com
Sat Oct 29 03:32:09 UTC 2016


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
403b3dca by Gary E. Miller at 2016-10-28T20:31:39-07:00
ntpviz: add a nice error message when gnuplot not found

- - - - -


1 changed file:

- ntpstats/ntpviz


Changes:

=====================================
ntpstats/ntpviz
=====================================
--- a/ntpstats/ntpviz
+++ b/ntpstats/ntpviz
@@ -278,7 +278,16 @@ def gnuplot(template, outfile=None):
     os.close(tmp_file)
 
     # shell=True is a security hazard, do not use
-    rcode = subprocess.call( ['gnuplot', tmp_filename], stdout=out)
+    try:
+        rcode = subprocess.call( ['gnuplot', tmp_filename], stdout=out)
+    except OSError as e:
+        if e.errno == os.errno.ENOENT:
+            # gnuplot not found
+            sys.stderr.write("ntpviz: ERROR: gnuplot not found in path\n")
+        else:
+            # Something else went wrong while trying to run gnuplot
+            sys.stderr.write("ntpviz: ERROR: gnuplot failed\n")
+        raise SystemExit(1)
 
     if 0 != rcode:
         sys.stderr.write("ntpviz: WARNING: plot returned %s\n" % rcode)



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/403b3dca459cc9f8a9acb8421f909e6d7406dcfa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161029/9ebeb91b/attachment.html>


More information about the vc mailing list