Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest openaps-contrib fails to rezone due to date = array #6

Open
scottleibrand opened this issue Jul 17, 2016 · 5 comments
Open

Latest openaps-contrib fails to rezone due to date = array #6

scottleibrand opened this issue Jul 17, 2016 · 5 comments

Comments

@scottleibrand
Copy link

I just upgraded openaps-contrib, and ran openaps report add settings/pumphistory-24h-zoned.json JSON tz rezone settings/pumphistory-24h.json (the command I normally use to create that report). With the new openaps-contrib, it fails to zone the pumphistory-24h.json when run, and instead gives me unzoned output like "timestamp": "2016-07-17T08:37:32",. Looks like this is due to a change in the way the date = string is represented in the ini, from date = timestamp dateString start_at end_at created_at to date = ['timestamp', 'dateString', 'start_at', 'end_at', 'created_at']. When I change it back to date = timestamp dateString start_at end_at created_at and invoke the report again, it zones the output properly.

@moomoobloo had this same issue last night: https://gitter.im/nightscout/intend-to-bolus?at=578b07d7196179690ef215bf

@bewest
Copy link
Member

bewest commented Jul 17, 2016

Seems fine to me. Is it possible you have an older version?

openaps report show junk-test-append-args-cli.json --cli
openaps use tz rezone --date system_time --date created_at --date timestamp --date created_at --date end_at --date start_at --date dateString --date timestamp monitor/pump-history.json
bewest@bewest-MacBookPro:~/Documents/loop-new-style$ ^C
bewest@bewest-MacBookPro:~/Documents/loop-new-style$ openaps report show junk-test-append-args-cli.json --ini
[report "junk-test-append-args-cli.json"]
use = rezone
reporter = JSON
astimezone = False
date = timestamp dateString start_at end_at created_at timestamp created_at system_time
adjust = missing
input = monitor/pump-history.json
device = tz
timezone = 





 openaps report add  junk-test-append-args-cli.json JSON  tz rezone --date dateString --date timestamp monitor/pump-history.json
added tz://JSON/rezone/junk-test-append-args-cli.json
bewest@bewest-MacBookPro:~/Documents/loop-new-style$ openaps report show junk-test-append-args-cli.json --ini
[report "junk-test-append-args-cli.json"]
use = rezone
reporter = JSON
astimezone = False
date = dateString timestamp
adjust = missing
input = monitor/pump-history.json
device = tz
timezone = 


bewest@bewest-MacBookPro:~/Documents/loop-new-style$ openaps report show junk-test-append-args-cli.json --ini
[report "junk-test-append-args-cli.json"]
use = rezone
reporter = JSON
astimezone = False
date = dateString timestamp
adjust = missing
input = monitor/pump-history.json
device = tz
timezone = 



@scottleibrand
Copy link
Author

Can you try without all the additional arguments? Just openaps report add settings/pumphistory-24h-zoned.json JSON tz rezone settings/pumphistory-24h.json?

@scottleibrand
Copy link
Author

If I do openaps report add settings/pumphistory-24h-zoned.json JSON tz rezone --date dateString --date timestamp settings/pumphistory-24h.json I get date = dateString timestamp correctly. It seems to be a problem just with the defaults if --date is not specified explicitly.

@bewest
Copy link
Member

bewest commented Jul 18, 2016

I see what's happening. This is a good opportunity to try a full release using python tools. I haven't used a dev branch on this repo because so far I've been the only contributor, and the code base has been small enough to just use master. Once repos mature to the point where multiple people are maintaining it, following git flow makes a lot more sense.

This patch seems to fix, I'd be happy to walk people through git-flow and doing a proper python release. This ensures that the thing that gets stored in the ini is actually a string with "tokens" separated by a single space.

diff --git a/openapscontrib/timezones/__init__.py b/openapscontrib/timezones/__init__.py
index e789eb6..d455482 100644
--- a/openapscontrib/timezones/__init__.py
+++ b/openapscontrib/timezones/__init__.py
@@ -31,8 +31,7 @@ class ConvertInput (Use):
     if args.timezone._filename == '/etc/localtime':
       params['timezone'] = ''

-    if args.date:
-      params['date'] = ' '.join(args.date)
+    params.update(date=' '.join(params.get('date')))
     return params
   def from_ini (self, fields):
     fields['date'] = fields['date'].split(' ')
@@ -94,7 +93,7 @@ class clock (ConvertInput):
   """
     Manage timezones of device clock.
   """
-  FIELDNAME = None
+  FIELDNAME = [ ]
   def get_date_value (self, record):
     return parse(record)
   def convert (self, program):

@scottleibrand
Copy link
Author

@bewest do I have pypi perms to do a release of openaps-contrib? Can you write down (or point me to) the basic steps I'd follow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants