diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index fc1e88c6..8e0ac7b4 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -328,7 +328,8 @@ def interactive_forcecurve(theworkouts,workstrokesonly=False): 'peakforceangle','peakforce','spm','distance', 'workoutstate','driveenergy'] - rowdata = dataprep.getsmallrowdata_db(columns,ids=ids) + rowdata = dataprep.getsmallrowdata_db(columns,ids=ids, + workstrokesonly=workstrokesonly) rowdata.dropna(axis=1,how='all',inplace=True) rowdata.dropna(axis=0,how='any',inplace=True) @@ -2214,16 +2215,18 @@ def interactive_chart(id=0,promember=0,intervaldata = {}): intervaldf = pd.DataFrame(intervaldata) intervaldf['itime'] = intervaldf['itime']*1.e3 intervaldf['time'] = intervaldf['itime'].cumsum() - intervaldf['time_r'] = intervaldf['time'] +intervaldf['itime'].shift(-1) - intervaldf['value'] = 10 + intervaldf['time'] = intervaldf['time'].shift(1) + intervaldf.ix[0,'time'] = 0 + intervaldf['time_r'] = intervaldf['time'] +intervaldf['itime'] + intervaldf['value'] = 100 mask = intervaldf['itype'] == 3 - intervaldf.loc[mask,'value'] = 45 + intervaldf.loc[mask,'value'] = 0 intervaldf['bottom'] = 10 intervalsource = ColumnDataSource( intervaldf ) - + plot.quad(left='time',top='value',bottom='bottom', right='time_r',source=intervalsource,color='mediumvioletred', y_range_name='spmax',fill_alpha=0.2,line_alpha=0.2) diff --git a/rowers/stravastuff.py b/rowers/stravastuff.py index c78fbd9c..05e58427 100644 --- a/rowers/stravastuff.py +++ b/rowers/stravastuff.py @@ -41,6 +41,11 @@ from stravalib.exc import ActivityUploadFailed,TimeoutExceeded from rowsandall_app.settings import C2_CLIENT_ID, C2_REDIRECT_URI, C2_CLIENT_SECRET, STRAVA_CLIENT_ID, STRAVA_REDIRECT_URI, STRAVA_CLIENT_SECRET +try: + from json.decoder import JSONDecodeError +except ImportError: + JSONDecodeError = ValueError + # Exponentially weighted moving average # Used for data smoothing of the jagged data obtained by Strava # See bitbucket issue 72 @@ -109,7 +114,7 @@ def get_token(code): try: token_json = response.json() thetoken = token_json['access_token'] - except KeyError: + except (KeyError,JSONDecodeError): thetoken = 0 return [thetoken] diff --git a/rowers/views.py b/rowers/views.py index c6e5b1e9..33c72f47 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -1409,8 +1409,11 @@ def add_workout_from_runkeeperdata(user,importid,data): unixtime = cum_time+starttimeunix - unixtime[0] = starttimeunix - + try: + unixtime[0] = starttimeunix + except IndexError: + return (0,'No data to import') + df['TimeStamp (sec)'] = unixtime @@ -3365,7 +3368,7 @@ def workout_forcecurve_view(request,id=0,workstrokesonly=False): workstrokesonly = True else: workstrokesonly = False - + script,div,js_resources,css_resources = interactive_forcecurve([row], workstrokesonly=workstrokesonly) @@ -11138,7 +11141,7 @@ def workout_split_view(request,id=id): r,row,splitsecond,splitmode ) except IndexError: - messages.error("Something went wrong in Split") + messages.error(request,"Something went wrong in Split") for message in mesgs: messages.info(request,message)