nice format for printing weight data
This commit is contained in:
+11
-2
@@ -1,6 +1,6 @@
|
|||||||
import httplib2
|
import httplib2
|
||||||
import sys
|
import sys
|
||||||
from time import time as now
|
import time
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
import fitbit
|
import fitbit
|
||||||
@@ -12,6 +12,8 @@ from googleapiclient.errors import HttpError
|
|||||||
|
|
||||||
POUNDS_PER_KILOGRAM = 2.20462
|
POUNDS_PER_KILOGRAM = 2.20462
|
||||||
|
|
||||||
|
TIME_FORMAT = "%a, %d %b %Y %H:%M:%S"
|
||||||
|
|
||||||
|
|
||||||
def GetFitbitClient():
|
def GetFitbitClient():
|
||||||
credentials = yaml.load(open('fitbit.yaml'))
|
credentials = yaml.load(open('fitbit.yaml'))
|
||||||
@@ -111,10 +113,17 @@ def main():
|
|||||||
|
|
||||||
# Get weight dataset.
|
# Get weight dataset.
|
||||||
if command == 'get':
|
if command == 'get':
|
||||||
print googleClient.users().dataSources().datasets().get(
|
data = googleClient.users().dataSources().datasets().get(
|
||||||
userId='me',
|
userId='me',
|
||||||
dataSourceId=dataSourceId,
|
dataSourceId=dataSourceId,
|
||||||
datasetId=datasetId).execute()
|
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.
|
# Delete weight dataset.
|
||||||
elif command == 'delete':
|
elif command == 'delete':
|
||||||
|
|||||||
Reference in New Issue
Block a user