🎨 Various code style / behaviour fixes
- Merged platform sources when possible - Added URLExecutableSource class - Moved replaced_by_schema_key to utils/decorators - Better retryable exception handling in some managers - Split SteamHelper into SteamFileHelper and SteamAPIHelper - Delegated SteamRateLimiter creation to SteamAPIManager init - Using additional_data for appid in SteamAPIManager - Added Windows support for Legendary - Stylistic changed suggested by pylint
This commit is contained in:
@@ -34,7 +34,7 @@ class AsyncManager(Manager):
|
||||
task.set_task_data((game, additional_data))
|
||||
task.run_in_thread(self._task_thread_func)
|
||||
|
||||
def _task_thread_func(self, _task, _source_object, data, cancellable):
|
||||
def _task_thread_func(self, _task, _source_object, data, _cancellable):
|
||||
"""Task thread entry point"""
|
||||
game, additional_data, *_rest = data
|
||||
self.execute_resilient_manager_logic(game, additional_data)
|
||||
|
||||
@@ -2,13 +2,12 @@ from pathlib import Path
|
||||
|
||||
import requests
|
||||
from gi.repository import GdkPixbuf, Gio
|
||||
from requests import HTTPError
|
||||
from urllib3.exceptions import SSLError
|
||||
from requests.exceptions import HTTPError, SSLError
|
||||
|
||||
from src import shared
|
||||
from src.game import Game
|
||||
from src.store.managers.manager import Manager
|
||||
from src.store.managers.local_cover_manager import LocalCoverManager
|
||||
from src.store.managers.manager import Manager
|
||||
from src.utils.save_cover import resize_cover, save_cover
|
||||
|
||||
|
||||
@@ -45,7 +44,7 @@ class ItchCoverManager(Manager):
|
||||
GdkPixbuf.InterpType.BILINEAR,
|
||||
)
|
||||
|
||||
# Composite
|
||||
# Composite
|
||||
itch_pixbuf.composite(
|
||||
game_cover,
|
||||
0,
|
||||
|
||||
@@ -64,7 +64,7 @@ class Manager:
|
||||
"""Execute the manager logic and handle its errors by reporting them or retrying"""
|
||||
try:
|
||||
self.manager_logic(game, additional_data)
|
||||
except Exception as error:
|
||||
except Exception as error: # pylint: disable=broad-exception-caught
|
||||
logging_args = (
|
||||
type(error).__name__,
|
||||
self.name,
|
||||
|
||||
@@ -2,12 +2,11 @@ from pathlib import Path
|
||||
|
||||
import requests
|
||||
from gi.repository import Gio
|
||||
from requests import HTTPError
|
||||
from urllib3.exceptions import SSLError
|
||||
from requests.exceptions import HTTPError, SSLError
|
||||
|
||||
from src.game import Game
|
||||
from src.store.managers.manager import Manager
|
||||
from src.store.managers.local_cover_manager import LocalCoverManager
|
||||
from src.store.managers.manager import Manager
|
||||
from src.utils.save_cover import resize_cover, save_cover
|
||||
|
||||
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
from urllib3.exceptions import SSLError
|
||||
from json import JSONDecodeError
|
||||
|
||||
from requests.exceptions import HTTPError, SSLError
|
||||
|
||||
from src.game import Game
|
||||
from src.store.managers.async_manager import AsyncManager
|
||||
from src.store.managers.itch_cover_manager import ItchCoverManager
|
||||
from src.store.managers.local_cover_manager import LocalCoverManager
|
||||
from src.store.managers.steam_api_manager import SteamAPIManager
|
||||
from src.utils.steamgriddb import HTTPError, SGDBAuthError, SGDBHelper
|
||||
from src.utils.steamgriddb import SGDBAuthError, SGDBHelper
|
||||
|
||||
|
||||
class SGDBManager(AsyncManager):
|
||||
"""Manager in charge of downloading a game's cover from steamgriddb"""
|
||||
|
||||
run_after = set((SteamAPIManager, LocalCoverManager, ItchCoverManager))
|
||||
retryable_on = set((HTTPError, SSLError))
|
||||
retryable_on = set((HTTPError, SSLError, ConnectionError, JSONDecodeError))
|
||||
|
||||
def manager_logic(self, game: Game, _additional_data: dict) -> None:
|
||||
try:
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
from urllib3.exceptions import SSLError
|
||||
from requests.exceptions import HTTPError, SSLError
|
||||
|
||||
from src.game import Game
|
||||
from src.store.managers.async_manager import AsyncManager
|
||||
from src.utils.steam import (
|
||||
HTTPError,
|
||||
SteamGameNotFoundError,
|
||||
SteamHelper,
|
||||
SteamAPIHelper,
|
||||
SteamNotAGameError,
|
||||
SteamRateLimiter,
|
||||
)
|
||||
|
||||
|
||||
@@ -15,15 +15,22 @@ class SteamAPIManager(AsyncManager):
|
||||
|
||||
retryable_on = set((HTTPError, SSLError))
|
||||
|
||||
def manager_logic(self, game: Game, _additional_data: dict) -> None:
|
||||
steam_api_helper: SteamAPIHelper = None
|
||||
steam_rate_limiter: SteamRateLimiter = None
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.steam_rate_limiter = SteamRateLimiter()
|
||||
self.steam_api_helper = SteamAPIHelper(self.steam_rate_limiter)
|
||||
|
||||
def manager_logic(self, game: Game, additional_data: dict) -> None:
|
||||
# Skip non-steam games
|
||||
if not game.source.startswith("steam_"):
|
||||
appid = additional_data.get("steam_appid", None)
|
||||
if appid is None:
|
||||
return
|
||||
# Get online metadata
|
||||
appid = str(game.game_id).split("_")[-1]
|
||||
steam = SteamHelper()
|
||||
try:
|
||||
online_data = steam.get_api_data(appid=appid)
|
||||
online_data = self.steam_api_helper.get_api_data(appid=appid)
|
||||
except (SteamNotAGameError, SteamGameNotFoundError):
|
||||
game.update_values({"blacklisted": True})
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user