diff options
author | Andrew Cady <d@jerkface.net> | 2017-01-28 16:20:38 +0000 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2017-01-28 16:20:38 +0000 |
commit | 4aedf24ada77eb7330e1287a7fdddd3be5018928 (patch) | |
tree | c2cd49664defbba8ec761c42fe8eabcf9a7f6360 | |
parent | faf348b2389cf693569d95983d627ea0b937182b (diff) |
dexcom_dumper: change JSON format again
-rw-r--r-- | dexcom_reader/dexcom_dumper.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/dexcom_reader/dexcom_dumper.py b/dexcom_reader/dexcom_dumper.py index c9624d2..d56dd15 100644 --- a/dexcom_reader/dexcom_dumper.py +++ b/dexcom_reader/dexcom_dumper.py | |||
@@ -248,7 +248,7 @@ def remote_update(rectype): | |||
248 | resp.raise_for_status() | 248 | resp.raise_for_status() |
249 | when = None | 249 | when = None |
250 | if len(resp.json()): | 250 | if len(resp.json()): |
251 | when = parsetime(resp.json()[0][1]['system_time']) | 251 | when = parsetime(resp.json()[0]['system_time']) |
252 | #print_verbose("Latest record on server: %s" % when.isoformat()) | 252 | #print_verbose("Latest record on server: %s" % when.isoformat()) |
253 | 253 | ||
254 | (rs, r) = since_and_first(when, rectype) | 254 | (rs, r) = since_and_first(when, rectype) |
@@ -283,19 +283,25 @@ class JSON_CGM(JSON_Time): | |||
283 | 283 | ||
284 | if isinstance(o, EGVRecord) and o.is_special: | 284 | if isinstance(o, EGVRecord) and o.is_special: |
285 | op={} | 285 | op={} |
286 | for k in o.BASE_FIELDS + ['glucose_special_meaning']: | 286 | record={} |
287 | for k in o.BASE_FIELDS: | ||
287 | op[k] = getattr(o, k) | 288 | op[k] = getattr(o, k) |
288 | return ['BGE_Special', op] | 289 | op['record'] = [getattr(o, 'glucose_special_meaning'), []] |
290 | return op | ||
289 | 291 | ||
290 | elif isinstance(o, GenericTimestampedRecord): | 292 | elif isinstance(o, GenericTimestampedRecord): |
291 | op={} | 293 | op={} |
292 | for k in o.BASE_FIELDS + o.FIELDS: | 294 | record={} |
295 | for k in o.BASE_FIELDS: | ||
293 | op[k] = getattr(o, k) | 296 | op[k] = getattr(o, k) |
297 | for k in o.FIELDS: | ||
298 | record[k] = getattr(o, k) | ||
294 | 299 | ||
295 | if isinstance(o, EGVRecord): | 300 | if isinstance(o, EGVRecord): |
296 | return ['BGE_Normal', op] | 301 | record = ['EGVRecord', record] |
297 | else: | 302 | |
298 | return op | 303 | op['record'] = record |
304 | return op | ||
299 | 305 | ||
300 | else: | 306 | else: |
301 | return JSON_Time.default(self, o) | 307 | return JSON_Time.default(self, o) |