From 783ae018c61526f1b5e88f8d82e87c2955ba82bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Mon, 1 Jul 2019 20:49:29 +0100 Subject: Introduce an explicit InvalidDateTime exception for meters with unset time. At least the FreeStyle Precision Neo appears to be able to report an invalid date/time (255/255/255 255:255), probably when the RTC is lost (see issue #58). This returns a more precise output than N/A, and should suggest to confirm the date and time setting instead. --- glucometerutils/glucometer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'glucometerutils/glucometer.py') diff --git a/glucometerutils/glucometer.py b/glucometerutils/glucometer.py index 485b32b..14999a7 100755 --- a/glucometerutils/glucometer.py +++ b/glucometerutils/glucometer.py @@ -86,9 +86,9 @@ def main(): if args.action == 'info': try: time_str = device.get_datetime() - except ValueError: - time_str = 'N/A' #handles value error exception for when time format found isn't expected - except NotImplementedError: + except exceptions.InvalidDateTime: + time_str = 'INVALID' + except NotImplementedError, ValueError: # Catch any leftover ValueError time_str = 'N/A' print("{device_info}Time: {time}".format( device_info=str(device_info), time=time_str)) -- cgit v1.2.3