nice format for printing weight data

This commit is contained in:
John Tantalo
2014-12-27 11:15:13 -08:00
parent 9913c2c70a
commit a2a316a582
+11 -2
View File
@@ -1,6 +1,6 @@
import httplib2
import sys
from time import time as now
import time
import yaml
import fitbit
@@ -12,6 +12,8 @@ from googleapiclient.errors import HttpError
POUNDS_PER_KILOGRAM = 2.20462
TIME_FORMAT = "%a, %d %b %Y %H:%M:%S"
def GetFitbitClient():
credentials = yaml.load(open('fitbit.yaml'))
@@ -111,10 +113,17 @@ def main():
# Get weight dataset.
if command == 'get':
print googleClient.users().dataSources().datasets().get(
data = googleClient.users().dataSources().datasets().get(
userId='me',
dataSourceId=dataSourceId,
datasetId=datasetId).execute()
for point in data['point']:
startTimeNanos = point['startTimeNanos']
fpVal = point['value'][0]['fpVal']
startTimeSecs = int(startTimeNanos) / 1e9
readableTime = time.strftime(TIME_FORMAT, time.localtime(startTimeSecs))
weightLbs = float(fpVal) * POUNDS_PER_KILOGRAM
print "%.1f lbs, %s" % (weightLbs, readableTime)
# Delete weight dataset.
elif command == 'delete':