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

Add Dave's fitbit step scripts. #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions fitbit.steps.redis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python

# check usage today. for use in bash shell.

# need to write to file/Redis and read only occasionally.

from oauth import oauth
import calendar
import datetime
import fitbit
import os
import redis
import sys
import time

def main():
# time-handling part
now = datetime.datetime.now() # what time is now?
datestr = now.strftime("%Y-%m-%d") # now in date format
# fitbit part
fb = fitbit.make_class() # connect to Fitbit
fbr = fb.activities_date_json( datestr ) # ask for today's updates
summary = fbr['summary'] # get the summary
steps = summary['steps'] # pull out steps to now
# redis part
rs = redis.Redis() # create Redis object
rs.hset( 'fitbit' , 'steps' , steps ) # put step count into Redis

if __name__ == '__main__':
main()

27 changes: 27 additions & 0 deletions fitbit.steps_prompt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python

# check usage today. for use in bash shell.

# need to write to file/Redis and read only occasionally.

from oauth import oauth
import datetime
import httplib
import os
import pymongo
import simplejson as json
import time
import sys
import fitbit

def main():
now = datetime.datetime.now() # what time is now?
datestr = now.strftime("%Y-%m-%d") # now in date format
fb = fitbit.make_class() # connect to Fitbit
fbr = fb.activities_date_json( datestr ) # get most recent updates
summary = fbr['summary'] # get today's summary
steps = summary['steps'] # pull out steps to now
sys.stdout.write( str( steps ) + ' steps')

if __name__ == '__main__':
main()