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
            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
        else:
            workout.sport = int(workout_type)

    workout.name = raw_input('Workout name [%s]: ' % sports[workout.sport])
    while not workout.duration:
        duration = raw_input('Workout duration in seconds [300]: ')
        if duration is '':
            print "Using 5 minutes as duration"
            duration = 300

        elif not duration.isdigit():
            print "Please insert digit for duration"
            continue

        workout.duration = int(duration)
        workout.start_time = datetime.utcnow() - timedelta(
            seconds=workout.duration)

        workout.distance = workout.duration * 0.0027777778
        # Calories is calculated on server side too.
        #workout.calories = int(workout.duration*0.26666667)

    #workout = endomondoapi.get_workout(w_id)
Ejemplo n.º 3
0
			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
		else:
			workout.sport = int(workout_type)


	workout.name = raw_input('Workout name [%s]: ' % sports[workout.sport])
	while not workout.duration:
		duration = raw_input('Workout duration in seconds [300]: ')
		if duration is '':
			print "Using 5 minutes as duration"
			duration = 300
	
		elif not duration.isdigit():
			print "Please insert digit for duration"
			continue
	
		workout.duration = int(duration)
		workout.start_time = datetime.utcnow() - timedelta(seconds=workout.duration)

		workout.distance = workout.duration*0.0027777778
		# Calories is calculated on server side too.
		#workout.calories = int(workout.duration*0.26666667)

	#workout = endomondoapi.get_workout(w_id)