[Git][NTPsec/ntpsec][master] Make ntpq die gracefully is the ntp library can't be found

Eric S. Raymond gitlab at mg.gitlab.com
Mon Nov 7 12:20:30 UTC 2016


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


Commits:
6e2b363c by Eric S. Raymond at 2016-11-07T07:14:29-05:00
Make ntpq die gracefully is the ntp library can't be found

- - - - -


1 changed file:

- ntpq/ntpq


Changes:

=====================================
ntpq/ntpq
=====================================
--- a/ntpq/ntpq
+++ b/ntpq/ntpq
@@ -14,10 +14,14 @@ from __future__ import print_function, division
 import os, sys, getopt, cmd, re
 import socket, hashlib
 
-from ntp.packet import *
-from ntp.util import *
-from ntp.ntpc import *
-import ntp.version
+try:
+    from ntp.packet import *
+    from ntp.util import *
+    from ntp.ntpc import *
+    import ntp.version
+except ImportError:
+    sys.stderr.write("ntpq: can't find the Python NTP library -- bailing out.\n")
+    sys.exit(1)
 
 # This import only works on Unixes.  The intention is to enable
 # Ctrl-P, Ctrl-N, and friends in Cmd.



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/6e2b363c1f42d3090fcdb3eeb5d166b26195e132
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161107/90f02237/attachment.html>


More information about the vc mailing list