summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.com>2019-07-07 23:10:14 +0200
committerDiego Elio Pettenò <flameeyes@flameeyes.com>2019-07-07 23:10:14 +0200
commitbc2d1a0ee33acb339a20e6ffcd4e5e7a28fa260d (patch)
tree78651c587d9653b77c5d5b02341809cb6ada8691
parentFix type annotations. (diff)
downloadglucometerutils-bc2d1a0ee33acb339a20e6ffcd4e5e7a28fa260d.tar
glucometerutils-bc2d1a0ee33acb339a20e6ffcd4e5e7a28fa260d.tar.gz
glucometerutils-bc2d1a0ee33acb339a20e6ffcd4e5e7a28fa260d.tar.bz2
glucometerutils-bc2d1a0ee33acb339a20e6ffcd4e5e7a28fa260d.tar.lz
glucometerutils-bc2d1a0ee33acb339a20e6ffcd4e5e7a28fa260d.tar.xz
glucometerutils-bc2d1a0ee33acb339a20e6ffcd4e5e7a28fa260d.tar.zst
glucometerutils-bc2d1a0ee33acb339a20e6ffcd4e5e7a28fa260d.zip
-rw-r--r--glucometerutils/common.py11
-rw-r--r--glucometerutils/drivers/fslibre.py3
-rw-r--r--glucometerutils/support/freestyle.py9
3 files changed, 19 insertions, 4 deletions
diff --git a/glucometerutils/common.py b/glucometerutils/common.py
index a258e4b..4af2001 100644
--- a/glucometerutils/common.py
+++ b/glucometerutils/common.py
@@ -8,7 +8,7 @@ import enum
import textwrap
try:
- from typing import Sequence, Text
+ from typing import Optional, Sequence, Text
except ImportError:
pass
@@ -131,6 +131,7 @@ class MeterInfo:
version_info = attr.ib(default=()) # type: Sequence[Text]
native_unit = attr.ib(
default=Unit.MG_DL, validator=attr.validators.in_(Unit)) # type: Unit
+ patient_name = attr.ib(default=None) # type: Optional[Text]
def __str__(self):
version_information_string = 'N/A'
@@ -138,7 +139,7 @@ class MeterInfo:
version_information_string = '\n '.join(
self.version_info).strip()
- return textwrap.dedent("""\
+ base_output = textwrap.dedent("""\
{model}
Serial Number: {serial_number}
Version Information:
@@ -147,3 +148,9 @@ class MeterInfo:
""").format(model=self.model, serial_number=self.serial_number,
version_information_string=version_information_string,
native_unit=self.native_unit.value)
+
+ if self.patient_name != None:
+ base_output += 'Patient Name: {patient_name}\n'.format(
+ patient_name=self.patient_name)
+
+ return base_output
diff --git a/glucometerutils/drivers/fslibre.py b/glucometerutils/drivers/fslibre.py
index 85bfdab..87a6556 100644
--- a/glucometerutils/drivers/fslibre.py
+++ b/glucometerutils/drivers/fslibre.py
@@ -208,7 +208,8 @@ class Device(freestyle.FreeStyleHidDevice):
serial_number=self.get_serial_number(),
version_info=(
'Software version: ' + self._get_version(),),
- native_unit=self.get_glucose_unit())
+ native_unit=self.get_glucose_unit(),
+ patient_name=self.get_patient_name())
def get_serial_number(self):
"""Overridden function as the command is not compatible."""
diff --git a/glucometerutils/support/freestyle.py b/glucometerutils/support/freestyle.py
index 475d6f5..4684194 100644
--- a/glucometerutils/support/freestyle.py
+++ b/glucometerutils/support/freestyle.py
@@ -14,7 +14,7 @@ import logging
import re
try:
- from typing import Iterator, List, Text, Tuple
+ from typing import Iterator, List, Optional, Text, Tuple
except ImportError:
pass
@@ -186,6 +186,13 @@ class FreeStyleHidDevice(hiddevice.HidDevice):
"""Returns the serial number of the device."""
return self._send_text_command(b'$serlnum?').rstrip('\r\n')
+ def get_patient_name(self):
+ # type: () -> Optional[Text]
+ patient_name = self._send_text_command(b'$ptname?').rstrip('\r\n')
+ if not patient_name:
+ return None
+ return patient_name
+
def get_datetime(self):
# type: () -> datetime.datetime
"""Gets the date and time as reported by the device.