From e259d1228638f9749d2bc87c0585d0e7a864a36d Mon Sep 17 00:00:00 2001 From: Dorian Scholz Date: Tue, 30 May 2017 13:35:18 +0800 Subject: Make dateutil optional: - import it only when user sets a date from a date string --- glucometer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'glucometer.py') diff --git a/glucometer.py b/glucometer.py index 19a47a8..9b3e66e 100755 --- a/glucometer.py +++ b/glucometer.py @@ -13,8 +13,6 @@ import inspect import logging import sys -from dateutil import parser as date_parser - from glucometerutils import common from glucometerutils import exceptions @@ -108,7 +106,11 @@ def main(): print(device.set_datetime()) elif args.set: try: + from dateutil import parser as date_parser new_date = date_parser.parse(args.set) + except ImportError: + logging.error('could not import module "dateutil", please install it.') + return 1 except ValueError: logging.error('%s: not a valid date', args.set) return 1 -- cgit v1.2.3