Skip to content
This repository has been archived by the owner on May 25, 2019. It is now read-only.

Commit

Permalink
Update documentation based on feedback
Browse files Browse the repository at this point in the history
- Further usability in 2.2.4
- More test data in 2.3.1.1.1 & 2.3.2.2.1
- Code commenting discussed and explained in 3.32
- Further development ideas given own section in 4.3.13
- Further development for usability covered in 4.3.13.4
  • Loading branch information
MattIPv4 committed May 9, 2019
1 parent daafa80 commit 649dbc4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Binary file modified documentation/FINAL SLST Duty Rota System.pdf
Binary file not shown.
Binary file modified documentation/SLST Duty Rota System.docx
Binary file not shown.
7 changes: 7 additions & 0 deletions slst-rota/app/utils.py
Expand Up @@ -19,22 +19,29 @@ def absolute_path(relative: str) -> str:
def fetch_status_messages():
# Try from the API to get latest (and save locally)
try:
# Log attempt
Utils.log("Utils.fetch_status_messages", "Attempting to load from API...")
# Fetch JSON data
resp = requests.get(url="https://status.js.org/codes.json", timeout=5)
data = resp.json()
if data:
# If valid data, store to variable & to file
Utils.statusMessageData = data
with open(Utils.absolute_path("assets/statusMsg.json"), "w") as file:
json.dump(data, file, sort_keys=True, indent=4)
Utils.log("Utils.fetch_status_messages", "Loaded from API")
except Exception as e:
# If error gets raised by requests, assume failure and log
Utils.log("Utils.fetch_status_messages", "Failed to load from API... '{}'".format(str(e)))
pass

# If API failed, use latest local copy
if not Utils.statusMessageData:
# If the local fallback file exists
if os.path.isfile(Utils.absolute_path("assets/statusMsg.json")):
# Open the file
with open(Utils.absolute_path("assets/statusMsg.json")) as file:
# Load JSON contents into variable and log as such
Utils.statusMessageData = json.load(file)
Utils.log("Utils.fetch_status_messages", "Loaded from local file")

Expand Down

0 comments on commit 649dbc4

Please sign in to comment.