Change get_command() to throw, not return an empty list, if the runner exe can't be found and flatpak has not got the runner.

[] is no better than None here; all calls try to form command lines and run them, which only works for the Linux runner.
This commit is contained in:
Daniel Johnson 2023-12-16 10:58:48 -05:00
parent 73e17e7af1
commit 3e38cfdfd8
2 changed files with 12 additions and 10 deletions

View file

@ -218,9 +218,9 @@ class InstallerWindow(ModelessDialog,
remove_checkbox = Gtk.CheckButton.new_with_label(_("Remove game files"))
if self.interpreter and self.interpreter.target_path and \
self.interpreter.game_dir_created and \
self.installation_kind == InstallationKind.INSTALL and \
is_removeable(self.interpreter.target_path, LutrisConfig().system_config):
self.interpreter.game_dir_created and \
self.installation_kind == InstallationKind.INSTALL and \
is_removeable(self.interpreter.target_path, LutrisConfig().system_config):
remove_checkbox.set_active(self.interpreter.game_dir_created)
remove_checkbox.show()
widgets.append(remove_checkbox)
@ -932,7 +932,7 @@ class InstallerWindow(ModelessDialog,
"""Displays the continue button, but labels it 'Install'."""
self.display_continue_button(handler, continue_button_label=_(
"_Install"), sensitive=sensitive,
extra_buttons=[self.source_button])
extra_buttons=[self.source_button])
def display_cancel_button(self, extra_buttons=None):
self.display_buttons(extra_buttons or [])

View file

@ -196,16 +196,18 @@ class Runner: # pylint: disable=too-many-public-methods
return exe
def get_command(self):
"""Returns the command line to run the runner itself; generally a game
will be appended to this by play()."""
try:
exe = self.get_executable()
if system.path_exists(exe):
return [exe]
if not system.path_exists(exe):
raise MissingExecutableError(_("The executable '%s' could not be found.") % exe)
return [exe]
except MisconfigurationError:
pass
if flatpak.is_app_installed(self.flatpak_id):
return flatpak.get_run_command(self.flatpak_id)
if flatpak.is_app_installed(self.flatpak_id):
return flatpak.get_run_command(self.flatpak_id)
return []
raise
def get_env(self, os_env=False, disable_runtime=False):
"""Return environment variables used for a game."""