forked from rommapp/romm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Georges-Antoine Assi
committed
Sep 15, 2023
1 parent
0dd2511
commit 5019961
Showing
14 changed files
with
159 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,3 +55,4 @@ frontend/dev-dist | |
|
||
# outside data | ||
switch_titledb.json | ||
mame.xml |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
from typing import Final | ||
from config import ( | ||
ENABLE_SCHEDULED_UPDATE_MAME_XML, | ||
SCHEDULED_UPDATE_MAME_XML_CRON, | ||
) | ||
from .utils import RemoteFilePullTask | ||
|
||
FIXTURE_FILE_PATH: Final = ( | ||
Path(os.path.dirname(__file__)).parent / "handler" / "fixtures" / "mame.xml" | ||
) | ||
|
||
|
||
class UpdateMAMEXMLTask(RemoteFilePullTask): | ||
def __init__(self): | ||
super().__init__( | ||
func="tasks.update_mame_xml.update_mame_xml_task.run", | ||
description="mame xml update", | ||
enabled=ENABLE_SCHEDULED_UPDATE_MAME_XML, | ||
cron_string=SCHEDULED_UPDATE_MAME_XML_CRON, | ||
url="https://hyperlist.hyperspin-fe.com/genall.php?system=6", | ||
file_path=FIXTURE_FILE_PATH, | ||
) | ||
|
||
|
||
update_mame_xml_task = UpdateMAMEXMLTask() |
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 |
---|---|---|
@@ -1,52 +1,31 @@ | ||
import requests | ||
import os | ||
from pathlib import Path | ||
|
||
from logger.logger import log | ||
from typing import Final | ||
from config import ( | ||
ENABLE_SCHEDULED_UPDATE_SWITCH_TITLEDB, | ||
SCHEDULED_UPDATE_SWITCH_TITLEDB_CRON, | ||
) | ||
from .utils import PeriodicTask | ||
from .utils import RemoteFilePullTask | ||
|
||
RAW_URL: Final = "https://raw.githubusercontent.com/blawar/titledb/master/US.en.json" | ||
FIXTURE_FILE_PATH = ( | ||
FIXTURE_FILE_PATH: Final = ( | ||
Path(os.path.dirname(__file__)).parent | ||
/ "handler" | ||
/ "fixtures" | ||
/ "switch_titledb.json" | ||
) | ||
|
||
|
||
class UpdateSwitchTitleDBTask(PeriodicTask): | ||
class UpdateSwitchTitleDBTask(RemoteFilePullTask): | ||
def __init__(self): | ||
super().__init__( | ||
func="tasks.update_switch_titledb.update_switch_titledb_task.run", | ||
description="switch titledb update", | ||
enabled=ENABLE_SCHEDULED_UPDATE_SWITCH_TITLEDB, | ||
cron_string=SCHEDULED_UPDATE_SWITCH_TITLEDB_CRON, | ||
url="https://raw.githubusercontent.com/blawar/titledb/master/US.en.json", | ||
file_path=FIXTURE_FILE_PATH, | ||
) | ||
|
||
async def run(self, force: bool = False): | ||
if not ENABLE_SCHEDULED_UPDATE_SWITCH_TITLEDB and not force: | ||
log.info("Scheduled switch titledb update not enabled, unscheduling...") | ||
self.unschedule() | ||
return | ||
|
||
log.info("Scheduled switch titledb update started...") | ||
|
||
try: | ||
response = requests.get(RAW_URL) | ||
response.raise_for_status() | ||
|
||
with open(FIXTURE_FILE_PATH, "wb") as fixture: | ||
fixture.write(response.content) | ||
|
||
log.info("Scheduled switch titledb update done") | ||
except requests.exceptions.RequestException as e: | ||
log.error("Scheduled switch titledb update failed", exc_info=True) | ||
log.error(e) | ||
|
||
|
||
update_switch_titledb_task = UpdateSwitchTitleDBTask() |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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