Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions dexcom_reader/database_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
import util
import binascii

try:
xrange
except NameError:
xrange = range


class BaseDatabaseRecord(object):
FORMAT = None

@classmethod
def _CheckFormat(cls):
if cls.FORMAT is None or not cls.FORMAT:
if not cls.FORMAT:
raise NotImplementedError("Subclasses of %s need to define FORMAT"
% cls.__name__)

Expand All @@ -26,7 +31,7 @@ def _ClassSize(cls):
@property
def FMT(self):
self._CheckFormat()
return _ClassFormat()
return self._ClassFormat()

@property
def SIZE(self):
Expand Down
32 changes: 19 additions & 13 deletions dexcom_reader/readdata.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import crc16
import constants
import database_records
Expand All @@ -12,6 +13,11 @@
import xml.etree.ElementTree as ET
import platform

try:
xrange
except NameError:
xrange = range


class ReadPacket(object):
def __init__(self, command, data):
Expand Down Expand Up @@ -41,19 +47,19 @@ def LocateAndDownload(cls):
sys.exit(1)
else:
dex = cls(device)
print ('Found %s S/N: %s'
% (dex.GetFirmwareHeader().get('ProductName'),
dex.ReadManufacturingData().get('SerialNumber')))
print 'Transmitter paired: %s' % dex.ReadTransmitterId()
print 'Battery Status: %s (%d%%)' % (dex.ReadBatteryState(),
dex.ReadBatteryLevel())
print 'Record count:'
print '- Meter records: %d' % (len(dex.ReadRecords('METER_DATA')))
print '- CGM records: %d' % (len(dex.ReadRecords('EGV_DATA')))
print ('- CGM commitable records: %d'
% (len([not x.display_only for x in dex.ReadRecords('EGV_DATA')])))
print '- Event records: %d' % (len(dex.ReadRecords('USER_EVENT_DATA')))
print '- Insertion records: %d' % (len(dex.ReadRecords('INSERTION_TIME')))
print('Found %s S/N: %s'
% (dex.GetFirmwareHeader().get('ProductName'),
dex.ReadManufacturingData().get('SerialNumber')))
print('Transmitter paired: %s' % dex.ReadTransmitterId())
print('Battery Status: %s (%d%%)' % (dex.ReadBatteryState(),
dex.ReadBatteryLevel()))
print('Record count:')
print('- Meter records: %d' % (len(dex.ReadRecords('METER_DATA'))))
print('- CGM records: %d' % (len(dex.ReadRecords('EGV_DATA'))))
print('- CGM commitable records: %d'
% (len([not x.display_only for x in dex.ReadRecords('EGV_DATA')])))
print('- Event records: %d' % (len(dex.ReadRecords('USER_EVENT_DATA'))))
print('- Insertion records: %d' % (len(dex.ReadRecords('INSERTION_TIME'))))

def __init__(self, port):
self._port_name = port
Expand Down
17 changes: 9 additions & 8 deletions dexcom_reader/record_test.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from __future__ import print_function
import readdata

dd = readdata.Dexcom.FindDevice()
dr = readdata.Dexcom(dd)
meter_records = dr.ReadRecords('METER_DATA')
print 'First Meter Record = '
print meter_records[0]
print 'Last Meter Record ='
print meter_records[-1]
print('First Meter Record = ')
print(meter_records[0])
print('Last Meter Record =')
print(meter_records[-1])
insertion_records = dr.ReadRecords('INSERTION_TIME')
print 'First Insertion Record = '
print insertion_records[0]
print 'Last Insertion Record = '
print insertion_records[-1]
print('First Insertion Record = ')
print(insertion_records[0])
print('Last Insertion Record = ')
print(insertion_records[-1])
4 changes: 2 additions & 2 deletions dexcom_reader/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ def recur(v):
else:
break

if type(v) == list:
if isinstance(v, list):
for x in v:
out = recur(x)
if out is not None:
return out
elif type(v) == dict or issubclass(type(v), dict):
elif isinstance(v, dict) or issubclass(type(v), dict):
for x in v.values():
out = recur(x)
if out is not None:
Expand Down