summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2016-12-26 17:21:19 -0500
committerAndrew Cady <d@jerkface.net>2016-12-26 18:56:06 -0500
commit32c099956e275acaaeca1b0da7957f18322ff558 (patch)
tree0077d3284e949539ed9e3ac60ba5dab93fdbae7d
parentecc267c230251ccbb19e421caddb7866d83451a1 (diff)
new command: dexcom_dumper.py
-rw-r--r--dexcom_reader/dexcom_dumper.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/dexcom_reader/dexcom_dumper.py b/dexcom_reader/dexcom_dumper.py
new file mode 100644
index 0000000..f0bac36
--- /dev/null
+++ b/dexcom_reader/dexcom_dumper.py
@@ -0,0 +1,44 @@
1import constants
2import readdata
3
4from optparse import OptionParser
5
6G5_IS_DEFAULT = True
7DEFAULT_PAGE_COUNT = 2
8
9parser = OptionParser()
10parser.add_option("--g4", action="store_false", dest="g5", default=G5_IS_DEFAULT, help="use Dexcom G4 instead of Dexcom G5")
11parser.add_option("--g5", action="store_true", dest="g5", default=G5_IS_DEFAULT, help="use Dexcom G5 instead of Dexcom G4")
12parser.add_option("-a", "--all", action="store_true", dest="dump_everything", default=False, help="dump all available records")
13parser.add_option("-n", type="int", dest="num_records", default=DEFAULT_PAGE_COUNT, help="number of pages of CGM records to display")
14
15(options, args) = parser.parse_args()
16
17def get_dexcom_reader():
18 if options.g5:
19 dd = readdata.DexcomG5.FindDevice()
20 return readdata.DexcomG5(dd)
21 else:
22 dd = readdata.Dexcom.FindDevice()
23 return readdata.Dexcom(dd)
24
25dr = get_dexcom_reader()
26
27if options.dump_everything:
28
29# record_types = ['METER_DATA', 'INSERTION_TIME', 'USER_EVENT_DATA', 'CAL_SET', 'SENSOR_DATA']
30
31 unparseable = ['FIRMWARE_PARAMETER_DATA', 'RECEIVER_LOG_DATA', 'USER_SETTING_DATA', 'MAX_VALUE']
32 parsed_to_xml = ['MANUFACTURING_DATA', 'PC_SOFTWARE_PARAMETER']
33 skip = unparseable + parsed_to_xml + ['EGV_DATA']
34 record_types = filter(lambda v: not v in skip, constants.RECORD_TYPES)
35
36 for t in record_types:
37 print t + ":"
38 for r in dr.ReadRecords(t):
39 print r
40
41cgm_records = dr.ReadRecords('EGV_DATA', 0 if options.dump_everything else options.num_records)
42for cr in cgm_records:
43 if not cr.display_only:
44 print cr