Ejemplo n.º 1
0
def upload_file(endomondoapi, file):
    points = reduce(lambda memo, lap: memo + lap['samples'], file['laps'], [])
    map(endo_conv_point, points)

    points[0]['inst'] = 2
    points[-1]['inst'] = 3

    workout = Workout()
    workout.sport = 0
    workout.points = points
    workout.start_time = datetime.datetime.utcfromtimestamp(file['start'])
    workout.distance = points[-1]['dist'] 
    workout.ascent = file['ascent']
    workout.descent = file['descent']
    workout.duration = file['duration']

    endomondoapi.post_workout(workout=workout, properties={'audioMessage': 'false'})
    if workout.id:
        print "Saved! %d"%workout.id
Ejemplo n.º 2
0
	##
	user_data = endomondoapi.get_account_info()['data']
	print "Hello {first_name} {last_name}".format(**user_data)

	##
	## * Retrieve last workouts.
	##
	print "Your last 5 workouts:"
	for workout in endomondoapi.get_workouts( maxResults=5 ):
		print "[%s] %s at %s" % (workout.id, workout.name, workout.start_time)

	##
	## * Create new workout.
	##

	workout = Workout()

	workout_type = False
	while workout_type == False:
		# Ask for a workout type
		workout_type = raw_input('Workout type (p to print) [0]:')
		if workout_type == '':
			workout_type = '0'

		if workout_type == 'p':	
			for i in sports:
				print "%s:\t%s" % (i, sports[i])
			workout_type = False
		elif not workout_type.isdigit() or not sports.has_key(int(workout_type)):
			print "Key not found"
			workout_type = False
Ejemplo n.º 3
0
    ##
    user_data = endomondoapi.get_account_info()['data']
    print "Hello {first_name} {last_name}".format(**user_data)

    ##
    ## * Retrieve last workouts.
    ##
    print "Your last 5 workouts:"
    for workout in endomondoapi.get_workouts(maxResults=5):
        print "[%s] %s at %s" % (workout.id, workout.name, workout.start_time)

    ##
    ## * Create new workout.
    ##

    workout = Workout()

    workout_type = False
    while workout_type == False:
        # Ask for a workout type
        workout_type = raw_input('Workout type (p to print) [0]:')
        if workout_type == '':
            workout_type = '0'

        if workout_type == 'p':
            for i in sports:
                print "%s:\t%s" % (i, sports[i])
            workout_type = False
        elif not workout_type.isdigit() or not sports.has_key(
                int(workout_type)):
            print "Key not found"
Ejemplo n.º 4
0
	def build_workout(self, properties):
		''' Helper to build ``Workout`` model from request response.'''
		workout = Workout(properties)
		return workout