diff options
author | Andrew Cady <d@jerkface.net> | 2016-12-26 17:21:19 -0500 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2016-12-26 18:56:06 -0500 |
commit | 32c099956e275acaaeca1b0da7957f18322ff558 (patch) | |
tree | 0077d3284e949539ed9e3ac60ba5dab93fdbae7d | |
parent | ecc267c230251ccbb19e421caddb7866d83451a1 (diff) |
new command: dexcom_dumper.py
-rw-r--r-- | dexcom_reader/dexcom_dumper.py | 44 |
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 @@ | |||
1 | import constants | ||
2 | import readdata | ||
3 | |||
4 | from optparse import OptionParser | ||
5 | |||
6 | G5_IS_DEFAULT = True | ||
7 | DEFAULT_PAGE_COUNT = 2 | ||
8 | |||
9 | parser = OptionParser() | ||
10 | parser.add_option("--g4", action="store_false", dest="g5", default=G5_IS_DEFAULT, help="use Dexcom G4 instead of Dexcom G5") | ||
11 | parser.add_option("--g5", action="store_true", dest="g5", default=G5_IS_DEFAULT, help="use Dexcom G5 instead of Dexcom G4") | ||
12 | parser.add_option("-a", "--all", action="store_true", dest="dump_everything", default=False, help="dump all available records") | ||
13 | parser.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 | |||
17 | def 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 | |||
25 | dr = get_dexcom_reader() | ||
26 | |||
27 | if 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 | |||
41 | cgm_records = dr.ReadRecords('EGV_DATA', 0 if options.dump_everything else options.num_records) | ||
42 | for cr in cgm_records: | ||
43 | if not cr.display_only: | ||
44 | print cr | ||