Skip to content

Commit

Permalink
fix: 🐛 refactor server_api.py and software_lifecycle.py for better ex…
Browse files Browse the repository at this point in the history
…ception handling
  • Loading branch information
realashleybailey committed Nov 21, 2023
1 parent 2ed6641 commit 8cf2b32
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get(self):
"requests": loads(dumps(get_requests(disallowed=["api_key"]), indent=4, sort_keys=True, default=str)),
"version": str(get_current_version()),
"update_available": need_update(),
"debug": True if app.debug else False,
"debug": bool(app.debug),
"setup_required": is_setup_required(),
"is_beta": is_beta(),
"latest_version": str(get_latest_version()),
Expand Down
31 changes: 23 additions & 8 deletions apps/wizarr-backend/wizarr_backend/app/utils/software_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,35 @@ def get_latest_beta_version():
return None

def get_current_version():
with open(LATEST_FILE, "r", encoding="utf-8") as f:
current_version = str(f.read())
return parse(current_version)
try:
with open(LATEST_FILE, "r", encoding="utf-8") as f:
current_version = str(f.read())
return parse(current_version)
except Exception:
return None

def is_beta():
return search(r"\d\.\d\.\d\w\d", str(get_current_version())) is not None
try:
return search(r"\d\.\d\.\d\w\d", str(get_current_version())) is not None
except Exception:
return False

def is_latest():
if str(get_current_version()) == str(is_beta() and get_latest_beta_version() or get_latest_version()):
try:
if str(get_current_version()) == str(is_beta() and get_latest_beta_version() or get_latest_version()):
return True
return compare_versions(get_current_version(), is_beta() and get_latest_beta_version() or get_latest_version())
except Exception:
return True
return compare_versions(get_current_version(), is_beta() and get_latest_beta_version() or get_latest_version())

def is_stable():
return not is_beta()
try:
return not is_beta()
except Exception:
return True

def need_update():
return not is_latest()
try:
return not is_latest()
except Exception:
return False

0 comments on commit 8cf2b32

Please sign in to comment.