Skip to content

Commit

Permalink
stopping warnings from returning 404s
Browse files Browse the repository at this point in the history
  • Loading branch information
PhillipsOwen committed May 22, 2024
1 parent 7c90faf commit 751ccbb
Showing 1 changed file with 4 additions and 30 deletions.
34 changes: 4 additions & 30 deletions src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ async def get_terria_map_catalog_data(grid_type: Union[str, None] = Query(defaul
if 'Error' in ret_val:
# set the status to a server error
status_code = 500
elif 'Warning' in ret_val:
# set the status to a not found
status_code = 404
# elif 'Warning' in ret_val:
# # set the status to a not found
# status_code = 404
else:
# if there was DB error
if ret_val == -1:
Expand All @@ -130,9 +130,6 @@ async def get_terria_map_catalog_data(grid_type: Union[str, None] = Query(defaul
# set a warning message
ret_val = {'Warning': 'No data found using the filter criteria selected.'}

# set the status to a not found
status_code = 404

except Exception:
# return a failure message
ret_val = {'Exception': 'Error detected trying to get the terria map catalog data.'}
Expand Down Expand Up @@ -200,9 +197,6 @@ async def get_catalog_workbench(insertion_date: Union[str, None] = Query(default
# set a warning message
ret_val = {'Warning': 'No data found using the filter criteria selected.'}

# set the status to a not found
status_code = 404

except Exception:
# return a failure message
ret_val = {'Exception': 'Error detected trying to get the terria map catalog workbench data.'}
Expand Down Expand Up @@ -285,13 +279,10 @@ async def get_terria_map_catalog_data_secure(grid_type: Union[str, None] = Query
# set the status to a not found
status_code = 500
# check the return, no data gets a 404 return
elif ret_val['catalog'] is None:
elif 'catalog' not in ret_val:
# set a warning message
ret_val = {'Warning': 'No data found using the filter criteria selected.'}

# set the status to a not found
status_code = 404

except Exception:
# return a failure message
ret_val = {'Exception': 'Error detected trying to get the terria map catalog data.'}
Expand Down Expand Up @@ -392,8 +383,6 @@ async def get_terria_map_catalog_data_file(file_name: Union[str, None] = Query(d
# set a warning message
ret_val = {'Warning': 'No data found using the filter criteria selected.'}

# set the status to a not found
status_code = 404
else:
# make the directory
os.makedirs(temp_file_path)
Expand Down Expand Up @@ -451,16 +440,10 @@ def get_station_data(station_name: Union[str, None] = Query(default=None), time_
if len(ret_val) == 0:
# set the Warning message and the return status
ret_val = 'Warning: No station data found using the criteria selected.'

# set the status to a not found
status_code = 404
else:
# set the error message
ret_val = 'Error Invalid input. Insure that all input fields are populated.'

# set the status to a not found
status_code = 404

except Exception:
# return a failure message
ret_val = 'Exception detected trying to get station data.'
Expand Down Expand Up @@ -526,9 +509,6 @@ async def get_station_data_file(file_name: Union[str, None] = Query(default='sta
# set the Warning message and the return status
ret_val = 'Warning: No station data found using the criteria selected.'

# set the status to a not found
status_code = 404

else:
# make the directory
os.makedirs(temp_file_path)
Expand All @@ -542,9 +522,6 @@ async def get_station_data_file(file_name: Union[str, None] = Query(default='sta
# set the error message
ret_val = 'Error Invalid input. Insure that all input fields are populated.'

# set the status to a not found
status_code = 404

except Exception:
# return a failure message
ret_val = 'Exception detected trying to get station data.'
Expand Down Expand Up @@ -611,9 +588,6 @@ async def get_catalog_member_records(run_id: Union[str, None] = Query(default=No
# return a failure message
ret_val = {'Warning': 'No data found using the filter criteria selected.'}

# set the status to a data not found error
status_code = 404

except Exception:
# return a failure message
ret_val = {'Error': 'Exception detected trying to get the catalog member data.'}
Expand Down

0 comments on commit 751ccbb

Please sign in to comment.