-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Part of #311. - Check for new releases every 12 hours - Add info message to the Settings page when a new release is available
- Loading branch information
1 parent
e2fa24d
commit 0886816
Showing
8 changed files
with
94 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from requests import get as req_get | ||
from typing import Optional | ||
|
||
from fastapi import HTTPException | ||
|
||
from modules.Debug import log | ||
|
||
def get_latest_version(raise_exc: bool = True) -> Optional[str]: | ||
""" | ||
Get the latest version of TitleCardMaker available. | ||
Args: | ||
raise_exc: Whether to raise an HTTPException if getting the | ||
latest version fails for any reason. | ||
Returns: | ||
The string version number of the latest release. If unable to | ||
determine, and raise_exc is False, then None is returned. | ||
Raises: | ||
HTTPException (500) if raise_exc is True and the version number | ||
cannot be determined. | ||
""" | ||
|
||
try: | ||
response = req_get( | ||
'https://api.github.com/repos/CollinHeist/' | ||
'TitleCardMaker/releases/latest' | ||
) | ||
assert response.ok | ||
except Exception as e: | ||
log.exception(f'Error checking for new release', e) | ||
if raise_exc: | ||
raise HTTPException( | ||
status_code=500, | ||
detail=f'Error checking for new release', | ||
) | ||
return None | ||
|
||
return response.json().get('name', '').strip() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters