mirror of
https://github.com/lutris/lutris
synced 2024-10-14 19:53:53 +00:00
Fixes for ScriptingError; it should still have a message even if the repr(self.fault_data) is falsey. It should be a LutrisError for sure, too.
Remove FileNotAvailable; it's never used. Rename MissingDependency to MissingGameDependencyError and ensure it has a message. We do put that message in the logs at least! It should be a LutrisError too.
This commit is contained in:
parent
657cefedac
commit
b6615b68d9
|
@ -17,7 +17,7 @@ from lutris.gui.widgets.common import FileChooserEntry
|
|||
from lutris.gui.widgets.log_text_view import LogTextView
|
||||
from lutris.gui.widgets.navigation_stack import NavigationStack
|
||||
from lutris.installer import InstallationKind, get_installers, interpreter
|
||||
from lutris.installer.errors import MissingGameDependency, ScriptingError
|
||||
from lutris.installer.errors import MissingGameDependencyError, ScriptingError
|
||||
from lutris.installer.interpreter import ScriptInterpreter
|
||||
from lutris.util import xdgshortcuts
|
||||
from lutris.util.jobs import AsyncCall
|
||||
|
@ -352,7 +352,7 @@ class InstallerWindow(ModelessDialog,
|
|||
script = _script
|
||||
self.interpreter = interpreter.ScriptInterpreter(script, self)
|
||||
self.interpreter.connect("runners-installed", self.on_runners_ready)
|
||||
except MissingGameDependency as ex:
|
||||
except MissingGameDependencyError as ex:
|
||||
dlg = QuestionDialog(
|
||||
{
|
||||
"parent": self,
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
"""Installer specific exceptions"""
|
||||
import sys
|
||||
from gettext import gettext as _
|
||||
|
||||
from lutris.exceptions import LutrisError
|
||||
from lutris.gui.dialogs import ErrorDialog
|
||||
from lutris.util.log import logger
|
||||
from lutris.util.strings import gtk_safe
|
||||
|
||||
|
||||
class ScriptingError(Exception):
|
||||
|
||||
class ScriptingError(LutrisError):
|
||||
"""Custom exception for scripting errors, can be caught by modifying
|
||||
excepthook."""
|
||||
|
||||
def __init__(self, message, faulty_data=None):
|
||||
self.message = message
|
||||
self.faulty_data = faulty_data
|
||||
super().__init__()
|
||||
super().__init__(message)
|
||||
logger.error(self.__str__())
|
||||
|
||||
def __str__(self):
|
||||
|
@ -22,24 +22,24 @@ class ScriptingError(Exception):
|
|||
return self.message
|
||||
|
||||
faulty_data = repr(self.faulty_data)
|
||||
return self.message + "\n%s" % faulty_data if faulty_data else ""
|
||||
if not faulty_data:
|
||||
return faulty_data
|
||||
|
||||
return self.message + "\n%s" % faulty_data
|
||||
|
||||
def __repr__(self):
|
||||
return self.message
|
||||
|
||||
|
||||
class FileNotAvailable(Exception):
|
||||
|
||||
"""Raised when a file has to be provided by the user"""
|
||||
|
||||
|
||||
class MissingGameDependency(Exception):
|
||||
|
||||
class MissingGameDependencyError(LutrisError):
|
||||
"""Raise when a game requires another game that isn't installed"""
|
||||
|
||||
def __init__(self, slug=None):
|
||||
def __init__(self, *args, message=None, slug=None, **kwargs):
|
||||
self.slug = slug
|
||||
super().__init__()
|
||||
|
||||
if not message:
|
||||
message = _("This game requires %s.") % slug
|
||||
super().__init__(message, *args, **kwargs)
|
||||
|
||||
|
||||
_excepthook = sys.excepthook # pylint: disable=invalid-name
|
||||
|
|
|
@ -10,7 +10,7 @@ from lutris.database.games import get_game_by_field
|
|||
from lutris.exceptions import MisconfigurationError
|
||||
from lutris.installer import AUTO_EXE_PREFIX
|
||||
from lutris.installer.commands import CommandsMixin
|
||||
from lutris.installer.errors import MissingGameDependency, ScriptingError
|
||||
from lutris.installer.errors import MissingGameDependencyError, ScriptingError
|
||||
from lutris.installer.installer import LutrisInstaller
|
||||
from lutris.installer.legacy import get_game_launcher
|
||||
from lutris.runners import NonInstallableRunnerError, RunnerInstallationError, steam, wine
|
||||
|
@ -187,7 +187,7 @@ class ScriptInterpreter(GObject.Object, CommandsMixin):
|
|||
installed_games = [dep for dep in [self._get_game_dependency(dep) for dep in dependency] if dep]
|
||||
if not installed_games:
|
||||
if len(dependency) == 1:
|
||||
raise MissingGameDependency(slug=dependency)
|
||||
raise MissingGameDependencyError(slug=dependency)
|
||||
raise ScriptingError(error_message.format(_(" or ").join(dependency)))
|
||||
if index == 0:
|
||||
self.target_path = installed_games[0]["directory"]
|
||||
|
@ -195,7 +195,7 @@ class ScriptInterpreter(GObject.Object, CommandsMixin):
|
|||
else:
|
||||
game = self._get_game_dependency(dependency)
|
||||
if not game:
|
||||
raise MissingGameDependency(slug=dependency)
|
||||
raise MissingGameDependencyError(slug=dependency)
|
||||
if index == 0:
|
||||
self.target_path = game["directory"]
|
||||
self.requires = game["installer_slug"]
|
||||
|
|
|
@ -6,7 +6,7 @@ from lutris import settings
|
|||
from lutris.api import get_api_games, get_game_installers
|
||||
from lutris.database.games import get_games
|
||||
from lutris.game import Game
|
||||
from lutris.installer.errors import MissingGameDependency
|
||||
from lutris.installer.errors import MissingGameDependencyError
|
||||
from lutris.installer.interpreter import ScriptInterpreter
|
||||
from lutris.services.lutris import download_lutris_media
|
||||
from lutris.util import cache_single
|
||||
|
@ -94,7 +94,7 @@ def scan_directory(dirname):
|
|||
logger.info("Found %s in %s", api_game["name"], full_path)
|
||||
try:
|
||||
install_game(installer, game_folder)
|
||||
except MissingGameDependency as ex:
|
||||
except MissingGameDependencyError as ex:
|
||||
logger.error("Skipped %s: %s", api_game["name"], ex)
|
||||
download_lutris_media(installer["game_slug"])
|
||||
slugs_installed.add(api_game["slug"])
|
||||
|
|
Loading…
Reference in a new issue