コード例 #1
0
ファイル: db2csv.py プロジェクト: danecollins/fitbit
def dump_data(fp, debug):
    stats = cache.write_as_csv(fp)
    if debug:
        print(stats, file=sys.stderr)


if __name__ == '__main__':
    (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)
        else:
            cache.read()
        if options.verbose:
            debug = True
        else:
            debug = False

        if options.filename:
            fp = open(options.filename, 'w')
            if debug:
                print('Writing data to file: {}'.format(options.filename))
        else:
コード例 #2
0
allowed_spm_error = 500
steps_per_mile = 2000
step_total = 0
dist_total = 0

if args.distance:
    print('will check distance values')
else:
    print('will NOT check distance values')

user_name = args.user_name

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
コード例 #3
0
                  action="store_true", dest="commit",
                  help="commit changes to database")


(options, args) = parser.parse_args()


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


cache = FitbitCache(user_name)
if cache.data_exists():
    cache.read()
else:
    parser.print_help()
    print('\n   ERROR: user {} does not have any data'.format(user_name))
    exit(1)

print("-------------- User: {} ----------------------".format(user_name))
print("\nDatabase contains %d entries" % len(cache.daylist()))

empty_days = cache.remove_days_without_steps()
print("\nRemoving days with zero steps")
for x in empty_days:
    print("    %s" % x)

コード例 #4
0
ファイル: add_csv_to_user.py プロジェクト: danecollins/fitbit
            try:
                value = float(value)
            except:
                pass
            cache.add_item(day, name, value)
            item_count += 1

    return item_count


if __name__ == '__main__':
    if len(sys.argv) != 3:
        print('Usage: python add_csv_to_user.py user_name csv_file.csv')
        exit(1)

    user_name = sys.argv[1]
    fbcache = FitbitCache(user_name)

    if fbcache.data_exists():
        fbcache.read()

    fn = sys.argv[2]
    if not os.path.exists(fn):
        print('Filename {} does not exist'.format(fn))
        print('Usage: python add_csv_to_user.py user_name csv_file.csv')
        exit(1)

    count = add_csv_data(fbcache, fn)
    fbcache.write()
    print('Items added = {}'.format(count))
コード例 #5
0
ファイル: add_csv_to_user.py プロジェクト: danecollins/fitbit
            try:
                value = float(value)
            except:
                pass
            cache.add_item(day, name, value)
            item_count += 1

    return item_count


if __name__ == '__main__':
    if len(sys.argv) != 3:
        print('Usage: python add_csv_to_user.py user_name csv_file.csv')
        exit(1)

    user_name = sys.argv[1]
    fbcache = FitbitCache(user_name)

    if fbcache.data_exists():
        fbcache.read()

    fn = sys.argv[2]
    if not os.path.exists(fn):
        print('Filename {} does not exist'.format(fn))
        print('Usage: python add_csv_to_user.py user_name csv_file.csv')
        exit(1)

    count = add_csv_data(fbcache, fn)
    fbcache.write()
    print('Items added = {}'.format(count))