From 13406c6e71d537ec7cbd30deb9c7403f51a567bf Mon Sep 17 00:00:00 2001 From: Keane Wolter Date: Wed, 21 Sep 2016 21:27:54 -0400 Subject: ntpshmviz patch Hi Eric, Just a couple exceptions for making sure matplotlib is installed and math is being done on numbers. Keane >From b4bbe0658d8a0887b61871e82bc9f4f095777b31 Mon Sep 17 00:00:00 2001 From: Keane Wolter Date: Wed, 21 Sep 2016 21:23:19 -0400 Subject: [PATCH] Added exceptions for math operation and matplotlib --- contrib/ntpshmviz | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'contrib/ntpshmviz') diff --git a/contrib/ntpshmviz b/contrib/ntpshmviz index 41e18590..d84362dd 100755 --- a/contrib/ntpshmviz +++ b/contrib/ntpshmviz @@ -11,8 +11,12 @@ import sys # need numpy for float128, normal python floats are too small to hold a timespec import numpy -import matplotlib.pyplot as PLT -from matplotlib.figure import Figure +try: + import matplotlib.pyplot as PLT + from matplotlib.figure import Figure +except: + print("Please make sure matplotlib is installed properly:", sys.exc_info()[0]) + sys.exit(1) class ntpOffset: def __init__(self, stream): @@ -69,7 +73,11 @@ class ntpOffset: if line[:1] != '#': line = line.lstrip() record = line.split(' ') - offset = numpy.float128(record[3]) - numpy.float128(record[4]) + try: + offset = numpy.float128(record[3]) - numpy.float128(record[4]) + except: + print ("Invalid data: ", sys.exc_info()[0], ". Data was: ", line) + continue # If the NTP unit is in the dictionary # append the offset to the list -- cgit v1.2.1