summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xglucometer.py6
-rw-r--r--glucometerutils/drivers/fslibre.py14
-rw-r--r--glucometerutils/support/__init__.py0
-rw-r--r--glucometerutils/support/freestyle.py1
-rw-r--r--glucometerutils/support/serial.py1
5 files changed, 14 insertions, 8 deletions
diff --git a/glucometer.py b/glucometer.py
index 9b3e66e..5440f0d 100755
--- a/glucometer.py
+++ b/glucometer.py
@@ -63,10 +63,10 @@ def main():
try:
driver = importlib.import_module('glucometerutils.drivers.' + args.driver)
- except ImportError:
+ except ImportError as e:
logging.error(
- 'No driver "%s" found, please check your --driver parameter.',
- args.driver)
+ 'Error importing driver "%s", please check your --driver parameter:\n%s',
+ args.driver, e)
return 1
# This check needs to happen before we try to initialize the device, as the
diff --git a/glucometerutils/drivers/fslibre.py b/glucometerutils/drivers/fslibre.py
index 47d2a8b..b364cc2 100644
--- a/glucometerutils/drivers/fslibre.py
+++ b/glucometerutils/drivers/fslibre.py
@@ -68,10 +68,12 @@ def _parse_record(record, entry_map):
if not record:
return {}
- return {
- key: int(record[idx])
- for idx, key in entry_map
- }
+ try:
+ return {
+ key: int(record[idx]) for idx, key in entry_map
+ }
+ except IndexError:
+ return {}
def _extract_timestamp(parsed_record):
@@ -145,7 +147,9 @@ def _parse_arresult(record):
comment_parts.append('Long-acting insulin')
if parsed_record['rapid-acting-flag']:
- if parsed_record['double-rapid-acting-insulin']:
+ # provide default value, as this record does not always exist
+ # (even if rapid-acting-flag is set)
+ if parsed_record.get('double-rapid-acting-insulin', 0):
comment_parts.append(
'Rapid-acting insulin (%d)' %
(parsed_record['double-rapid-acting-insulin']/2))
diff --git a/glucometerutils/support/__init__.py b/glucometerutils/support/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/glucometerutils/support/__init__.py
diff --git a/glucometerutils/support/freestyle.py b/glucometerutils/support/freestyle.py
index 6c6e294..bb891fd 100644
--- a/glucometerutils/support/freestyle.py
+++ b/glucometerutils/support/freestyle.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
"""Common routines to implement the FreeStyle common protocol.
Protocol documentation available at
diff --git a/glucometerutils/support/serial.py b/glucometerutils/support/serial.py
index 84bae87..d4f352b 100644
--- a/glucometerutils/support/serial.py
+++ b/glucometerutils/support/serial.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
"""Common routines and base driver class for serial-based meters.
"""