added wine runner install,remove,list options

This commit is contained in:
Ahmed Al Balochi 2021-10-20 20:20:35 +05:00 committed by Mathieu Comandon
parent 89b4ccf947
commit 361473ca3a
3 changed files with 84 additions and 2 deletions

View file

@ -95,6 +95,8 @@ The following command line arguments are available::
-s, --list-steam-games List available Steam games
--list-steam-folders List all known Steam library folders
--list-runners List all known runners
--list-wine-runners List all known Wine runners
-w, --install-wine-runner Install a Wine Runner
-r, --install-runner Install a Runner
-u, --uninstall-runner Uninstall a Runner
-j, --json Display the list of games in JSON format

View file

@ -32,10 +32,11 @@ gi.require_version("GnomeDesktop", "3.0")
from gi.repository import Gio, GLib, Gtk, GObject
from lutris.util.wine.wine import get_wine_versions
from lutris.runners import get_runner_names
from lutris.runners.runner import Runner
from lutris import settings
from lutris.api import parse_installer_url
from lutris.api import parse_installer_url, get_runners
from lutris.command import exec_command
from lutris.database import games as games_db
from lutris.game import Game
@ -185,6 +186,22 @@ class Application(Gtk.Application):
_("List all known runners"),
None,
)
self.add_main_option(
"list-wine-runners",
0,
GLib.OptionFlags.NONE,
GLib.OptionArg.NONE,
_("List all known Wine runners"),
None,
)
self.add_main_option(
"install-wine-runner",
ord("w"),
GLib.OptionFlags.NONE,
GLib.OptionArg.STRING,
_("Install a Wine Runner"),
None,
)
self.add_main_option(
"install-runner",
ord("r"),
@ -395,6 +412,17 @@ class Application(Gtk.Application):
self.print_runners(command_line)
return 0
# List Runners
if options.contains("list-wine-runners"):
self.print_wine_runners(command_line)
return 0
# install Runner
if options.contains("install-wine-runner"):
version = options.lookup_value("install-wine-runner").get_string()
self.install_wine_runner(version, command_line)
return 0
# install Runner
if options.contains("install-runner"):
command = options.lookup_value("install-runner").get_string()
@ -723,11 +751,36 @@ class Application(Gtk.Application):
for name in runnersName:
print(name)
def print_wine_runners(self, command_line):
runnersName = get_runners("wine")
for i in runnersName["versions"]:
if i ["version"]:
print(i)
def install_wine_runner(self, version, command_line):
installed = get_wine_versions()
for i in installed:
if i.startswith(version):
print("This Wine version is already installed")
exit()
else:
Runner.prepare_wine_runner_cli(version)
def install_runner(self, command, command_line):
Runner.prepare_runner_cli(command)
def uninstall_runner(self, command, command_line):
Runner.uninstall_runner_cli(command)
if command == "wine":
print("Are sure you want to delete Wine and all of the installed runners?[Y/N]")
ans = input()
if ans == "y" or ans == "Y":
Runner.uninstall_runner_cli(command)
elif ans == "n" or ans == "N":
exit()
elif command.startswith("lutris"):
Runner.wine_runner_uninstall(command)
else:
Runner.uninstall_runner_cli(command)
def do_shutdown(self): # pylint: disable=arguments-differ
logger.info("Shutting down Lutris")

View file

@ -306,6 +306,30 @@ class Runner: # pylint: disable=too-many-public-methods
return self.is_installed()
return False
def prepare_wine_runner_cli(version):
"""
import and save the runner given in application file located in lutris/gui/application.py
provided using lutris -r <runner>
"""
Runner = import_runner("wine")
return Runner().install_wine_cli(version)
def install_wine_cli(self, version):
"""
install the runner provided in prepare_runner_cli()
"""
from lutris.gui.dialogs.download import simple_downloader
self.install(version=version, downloader=simple_downloader, callback=None)
print("Wine Runner '"+ version + "' is now installed :)")
def wine_runner_uninstall(version):
version = version+"-x86_64"
WINE_DIR = os.path.join(settings.RUNNER_DIR, "wine")
runner_path = os.path.join(WINE_DIR, version)
if os.path.isdir(runner_path):
system.remove_folder(runner_path)
print("Wine Runner is Removed")
def prepare_runner_cli(runner_name):
"""
import and save the runner given in application file located in lutris/gui/application.py
@ -318,6 +342,9 @@ class Runner: # pylint: disable=too-many-public-methods
"""
install the runner provided in prepare_runner_cli()
"""
if self.name == "wine":
print("Please use the Wine flag To install a wine Runner")
exit()
runner_path = os.path.join(settings.RUNNER_DIR, self.name)
if os.path.isdir(runner_path):
print(self.name + " is already installed!")