diff options
author | Keane Wolter <daemoneye2@gmail.com> | 2016-09-21 21:27:54 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2016-09-27 14:24:41 -0400 |
commit | 13406c6e71d537ec7cbd30deb9c7403f51a567bf (patch) | |
tree | 9be5826c2f8f9bb07b1bd6c0977899e72cb1f664 /contrib/ntpshmviz | |
parent | 7487efe889f90b1f9ef80b0e4a30801c59ca2731 (diff) | |
download | gpsd-13406c6e71d537ec7cbd30deb9c7403f51a567bf.tar.gz |
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 <daemoneye2@gmail.com>
Date: Wed, 21 Sep 2016 21:23:19 -0400
Subject: [PATCH] Added exceptions for math operation and matplotlib
Diffstat (limited to 'contrib/ntpshmviz')
-rwxr-xr-x | contrib/ntpshmviz | 14 |
1 files changed, 11 insertions, 3 deletions
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 |