Skip to content

Commit

Permalink
Update Exception Management In API
Browse files Browse the repository at this point in the history
Correct the exception management in order to pass back to the update
worker properly
  • Loading branch information
ChuckMac committed Sep 21, 2022
1 parent 5b99a9d commit ca3b5fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/test-only.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
name: ADRFinder Test

# Triggers the workflow on push or pull request events
on: [push, pull_request]
on:
push:
pull_request:
schedule:
- cron: '30 04 * * *'

jobs:
test-build:
Expand Down
2 changes: 1 addition & 1 deletion adrfinder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from flask_login import login_required
from adrfinder.restaurants import Restaurants

__version__ = '0.2.2'
__version__ = '0.2.3'

datastore = None

Expand Down
10 changes: 5 additions & 5 deletions adrfinder/fetch_site_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ def get_auth_cookie(self):
self.connection.request("POST", "/finder/api/v1/authz/public", payload, headers)
except Exception as e:
print(">> Request failed, Unable to get AUTH cookie: {}".format(e))
raise SystemExit(e)
raise Exception("Request failed, Unable to get AUTH cookie: {}".format(e))

response = self.connection.getresponse()
if response.status != 200:
print(">> Request failed, Non-200 received getting AUTH cookie: {}".format(response.status))
raise SystemExit(response.status)
raise Exception("Request failed, Non-200 received getting AUTH cookie: {}".format(response.status))

response.read()
headers['Cookie'] = response.getheader('set-cookie')
Expand Down Expand Up @@ -60,13 +60,13 @@ def run(self, uuid):
self.connection.request("GET", endpoint, headers=self.headers)
except Exception as e:
print(">> Request failed, Unable to get reservation data: {}".format(e))
raise SystemExit(e)
raise Exception("Request failed, Unable to get reservation data: {}".format(e))

response = self.connection.getresponse()
if response.status != 200:
print(">> Request failed, Non-200 received getting reservation data: {}".format(response.status))
print(">> Request url: https://disneyworld.disney.go.com{}".format(endpoint))
raise SystemExit(response.status)
raise Exception("Request failed, Non-200 received getting reservation data: {}".format(response.status))

data = response.read()
json_reservations = json.loads(data.decode("utf-8"))
Expand All @@ -80,6 +80,6 @@ def run(self, uuid):
offer_link = base_link + offer['url'] + base_suffix
offers.append({'time': offer['label'], 'url': offer_link})
else:
print(">> Restaurant not found") # Maybe should throw hard error here
raise Exception("Restaurant ID not found in data: {}".format(restaurant))

return available_detected, offers

0 comments on commit ca3b5fb

Please sign in to comment.