diff options
author | Andrew Cady <d@jerkface.net> | 2017-01-25 15:58:46 +0000 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2017-01-25 15:58:46 +0000 |
commit | ffbfee060e96104c3e9164316bb6a2e74040ab63 (patch) | |
tree | 6a5f7b3dcd7dab66a33ad0545296bb48cad7aae4 /dexcom_reader | |
parent | 1cdd4d1d8a1407ac92ae77d50283a4f3c23191d9 (diff) |
dexcom_dumper: new option --human
Diffstat (limited to 'dexcom_reader')
-rw-r--r-- | dexcom_reader/dexcom_dumper.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/dexcom_reader/dexcom_dumper.py b/dexcom_reader/dexcom_dumper.py index 9708f36..b579818 100644 --- a/dexcom_reader/dexcom_dumper.py +++ b/dexcom_reader/dexcom_dumper.py | |||
@@ -19,11 +19,13 @@ parser.add_option("-p", "--poll", action="store_const", dest="command", const="p | |||
19 | 19 | ||
20 | parser.add_option("-n", type="int", dest="num_records", default=DEFAULT_PAGE_COUNT, help="number of pages of CGM records to display") | 20 | parser.add_option("-n", type="int", dest="num_records", default=DEFAULT_PAGE_COUNT, help="number of pages of CGM records to display") |
21 | parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help="verbosity (currently for debugging)") | 21 | parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help="verbosity (currently for debugging)") |
22 | parser.add_option("-H", "--human", action="store_true", dest="human", help="print human-readable times") | ||
22 | 23 | ||
23 | (options, args) = parser.parse_args() | 24 | (options, args) = parser.parse_args() |
24 | 25 | ||
25 | command = options.command or "dump_cgm" | 26 | command = options.command or "dump_cgm" |
26 | VERBOSE = options.verbose | 27 | VERBOSE = options.verbose |
28 | HUMAN = options.human | ||
27 | 29 | ||
28 | def get_dexcom_reader(): | 30 | def get_dexcom_reader(): |
29 | if options.g5: | 31 | if options.g5: |
@@ -81,13 +83,17 @@ def read_recent_egv_data(): | |||
81 | print_verbose(sys.exc_info) | 83 | print_verbose(sys.exc_info) |
82 | return None | 84 | return None |
83 | 85 | ||
86 | def time_fmt(t): | ||
87 | global HUMAN | ||
88 | return t.strftime('%c' if HUMAN else '%s') | ||
89 | |||
84 | def format_times(now, stamp): | 90 | def format_times(now, stamp): |
85 | diff = (stamp - now).total_seconds() | 91 | diff = (stamp - now).total_seconds() |
86 | operand = '-' if diff < 0 else '+' # should always be - | 92 | operand = '-' if diff < 0 else '+' # should always be - |
87 | return '%s %s %d' % (now.strftime('%s'), operand, abs(diff)) | 93 | return '%s %s %d' % (time_fmt(now), operand, abs(diff)) |
88 | 94 | ||
89 | def print_localtime(str): | 95 | def print_localtime(str): |
90 | print '%s (system): %s' % (datetime.now().strftime('%s'), str) | 96 | print '%s (system): %s' % (time_fmt(datetime.now()), str) |
91 | 97 | ||
92 | CONNECTED = None | 98 | CONNECTED = None |
93 | def connected(state): | 99 | def connected(state): |