#NEWLINE# def DownloadActivityList( self , serviceRecord , exhaustive = False ) : #NEWLINE# #INDENT# oauthSession = self . _oauthSession ( serviceRecord ) #NEWLINE# activities = [ ] #NEWLINE# exclusions = [ ] #NEWLINE# page_url = 'https://api.endomondo.com/api/1/workouts' #NEWLINE# while True : #NEWLINE# #INDENT# resp = oauthSession . get ( page_url ) #NEWLINE# try : #NEWLINE# #INDENT# respList = resp . json ( ) [ 'data' ] #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# self . _rateLimitBailout ( resp ) #NEWLINE# raise APIException ( ( 'Error decoding activity list resp %s %s' % ( resp . status_code , resp . text ) ) ) #NEWLINE# #UNINDENT# for actInfo in respList : #NEWLINE# #INDENT# activity = UploadedActivity ( ) #NEWLINE# activity . StartTime = self . _parseDate ( actInfo [ 'start_time' ] ) #NEWLINE# logger . debug ( ( 'Activity s/t %s' % activity . StartTime ) ) #NEWLINE# if ( ( 'is_tracking' in actInfo ) and actInfo [ 'is_tracking' ] ) : #NEWLINE# #INDENT# exclusions . append ( APIExcludeActivity ( 'Not complete' , activity_id = actInfo [ 'id' ] , permanent = False , user_exception = UserException ( UserExceptionType . LiveTracking ) ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# if ( 'end_time' in actInfo ) : #NEWLINE# #INDENT# activity . EndTime = self . _parseDate ( actInfo [ 'end_time' ] ) #NEWLINE# #UNINDENT# if ( actInfo [ 'sport' ] in self . _activityMappings ) : #NEWLINE# #INDENT# activity . Type = self . _activityMappings [ actInfo [ 'sport' ] ] #NEWLINE# #UNINDENT# if ( 'duration_total' in actInfo ) : #NEWLINE# #INDENT# activity . Stats . TimerTime = ActivityStatistic ( ActivityStatisticUnit . Seconds , value = float ( actInfo [ 'duration_total' ] ) ) #NEWLINE# #UNINDENT# if ( 'distance_total' in actInfo ) : #NEWLINE# #INDENT# activity . Stats . Distance = ActivityStatistic ( ActivityStatisticUnit . Kilometers , value = float ( actInfo [ 'distance_total' ] ) ) #NEWLINE# #UNINDENT# if ( 'calories_total' in actInfo ) : #NEWLINE# #INDENT# activity . Stats . Energy = ActivityStatistic ( ActivityStatisticUnit . Kilocalories , value = float ( actInfo [ 'calories_total' ] ) ) #NEWLINE# #UNINDENT# activity . Stats . Elevation = ActivityStatistic ( ActivityStatisticUnit . Meters ) #NEWLINE# if ( 'altitude_max' in actInfo ) : #NEWLINE# #INDENT# activity . Stats . Elevation . Max = float ( actInfo [ 'altitude_max' ] ) #NEWLINE# #UNINDENT# if ( 'altitude_min' in self ) : #NEWLINE# #INDENT# activity . Stats . Elevation . Min = float ( actInfo [ 'altitude_min' ] ) #NEWLINE# #UNINDENT# if ( 'total_ascent' in actInfo ) : #NEWLINE# #INDENT# activity . Stats . Elevation . Gain = float ( actInfo [ 'total_ascent' ] ) #NEWLINE# #UNINDENT# if ( 'total_descent' in actInfo ) : #NEWLINE# #INDENT# activity . Stats . Elevation . Loss = float ( actInfo [ 'total_descent' ] ) #NEWLINE# #UNINDENT# activity . Stats . Speed = ActivityStatistic ( ActivityStatisticUnit . KilometersPerHour ) #NEWLINE# if ( 'speed_max' in actInfo ) : #NEWLINE# #INDENT# activity . Stats . Speed . Max = float ( actInfo [ 'speed_max' ] ) #NEWLINE# #UNINDENT# if ( 'heart_rate_avg' in actInfo ) : #NEWLINE# #INDENT# activity . Stats . HR = ActivityStatistic ( ActivityStatisticUnit . BeatsPerMinute , avg = float ( actInfo [ 'heart_rate_avg' ] ) ) #NEWLINE# #UNINDENT# if ( 'heart_rate_max' in actInfo ) : #NEWLINE# #INDENT# activity . Stats . HR . update ( ActivityStatistic ( ActivityStatisticUnit . BeatsPerMinute , max = float ( actInfo [ 'heart_rate_max' ] ) ) ) #NEWLINE# #UNINDENT# if ( 'cadence_avg' in actInfo ) : #NEWLINE# #INDENT# activity . Stats . Cadence = ActivityStatistic ( ActivityStatisticUnit . RevolutionsPerMinute , avg = int ( actInfo [ 'cadence_avg' ] ) ) #NEWLINE# #UNINDENT# if ( 'cadence_max' in actInfo ) : #NEWLINE# #INDENT# activity . Stats . Cadence . update ( ActivityStatistic ( ActivityStatisticUnit . RevolutionsPerMinute , max = int ( actInfo [ 'cadence_max' ] ) ) ) #NEWLINE# #UNINDENT# if ( 'title' in actInfo ) : #NEWLINE# #INDENT# activity . Name = actInfo [ 'title' ] #NEWLINE# #UNINDENT# activity . ServiceData = { #NEWLINE# #INDENT# 'WorkoutID' : int ( actInfo [ 'id' ] ) , #NEWLINE# #UNINDENT# } #NEWLINE# activity . CalculateUID ( ) #NEWLINE# activities . append ( activity ) #NEWLINE# #UNINDENT# paging = resp . json ( ) [ 'paging' ] #NEWLINE# if ( ( 'next' not in paging ) or ( not paging [ 'next' ] ) or ( not exhaustive ) ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# page_url = paging [ 'next' ] #NEWLINE# #UNINDENT# #UNINDENT# return ( activities , exclusions )