コード例 #1
0
cache = FitbitCache(user_name)

if not cache.data_exists():
    print("ERROR: Could not open data for user '{}'\n".format(user_name))
    parser.print_help()
    exit(1)

cache.read()
days = cache.daylist()

current_date = days[0]
end_date = days[-1]

print('Start    = {}'.format(days[0]))
print('End      = {}'.format(days[-1]))
print('Num Days = {}'.format(cache.num_days()))

i = 0
while current_date <= end_date:
    s = ''
    day_data = cache[current_date]
    if 'date' not in day_data:
        day_data['date'] = current_date.strftime(dt_format)

    valid = True

    if not (('steps' in day_data) and ('distance' in day_data) and
            ('calories' in day_data)):
        print('Illegal day data for {}'.format(current_date))
        print('    {}'.format(day_data))
    else:
コード例 #2
0
ファイル: days.py プロジェクト: danecollins/fitbit
from __future__ import print_function
from __future__ import unicode_literals
from fbcache import FitbitCache
from optparse import OptionParser


usage = "usage: %prog user-name"
parser = OptionParser(usage)

(options, args) = parser.parse_args()

if len(args) != 1:
    parser.print_help()
    exit(1)
else:
    user_name = args[0]

cache = FitbitCache(user_name)

if not cache.data_exists():
    print("ERROR: Could not open data for user '{}'\n".format(user_name))
    parser.print_help()
    exit(1)

cache.read()
days = cache.daylist()

print('Start    = {}'.format(days[0]))
print('End      = {}'.format(days[-1]))
print('Num Days = {}'.format(cache.num_days()))
コード例 #3
0
ファイル: test_fbcache.py プロジェクト: danecollins/fitbit
 def test_num_days(self):
     fb = FitbitCache('test_user')
     (dates, items) = populate_fb_object(fb)
     self.assertEqual(fb.num_days(), dates)
コード例 #4
0
ファイル: test_fbcache.py プロジェクト: danecollins/fitbit
 def test_num_days(self):
     fb = FitbitCache('test_user')
     (dates, items) = populate_fb_object(fb)
     self.assertEqual(fb.num_days(), dates)