mirror of
https://github.com/lutris/lutris
synced 2024-10-14 11:42:36 +00:00
Various cleanup
This commit is contained in:
parent
1472820218
commit
001cbd4d0c
|
@ -29,9 +29,7 @@ from lutris.thread import LutrisThread
|
|||
from lutris.services import get_services_synced_at_startup, steam
|
||||
|
||||
from lutris.gui import dialogs
|
||||
from lutris.gui.sidebar import (
|
||||
SidebarListBox,
|
||||
) # NOQA FIXME Removing this unused import causes a crash
|
||||
from lutris.gui.sidebar import SidebarListBox # NOQA FIXME Removing this unused import causes a crash
|
||||
from lutris.gui.logdialog import LogDialog
|
||||
from lutris.gui.sync import SyncServiceWindow
|
||||
from lutris.gui.gi_composites import GtkTemplate
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
"""Sidebar for the main window"""
|
||||
import os
|
||||
from gi.repository import Gtk, Pango, GObject, GdkPixbuf
|
||||
from gi.repository import Gtk, Pango, GObject
|
||||
|
||||
from lutris import runners
|
||||
from lutris import platforms
|
||||
from lutris import pga
|
||||
from lutris.util import datapath
|
||||
from lutris.util.log import logger
|
||||
from lutris.gui.runnerinstalldialog import RunnerInstallDialog
|
||||
from lutris.gui.config_dialogs import RunnerConfigDialog
|
||||
from lutris.gui.runnersdialog import RunnersDialog
|
||||
|
|
|
@ -309,7 +309,7 @@ class ScriptInterpreter(CommandsMixin):
|
|||
os.makedirs(self.target_path)
|
||||
except PermissionError:
|
||||
raise ScriptingError(
|
||||
"Lutris does not have necessary permissions to install to choosen game dir:",
|
||||
"Lutris does not have the necessary permissions to install to path:",
|
||||
self.target_path,
|
||||
)
|
||||
self.reversion_data["created_main_dir"] = True
|
||||
|
@ -750,9 +750,8 @@ class ScriptInterpreter(CommandsMixin):
|
|||
return self.user_inputs[-1]["value"] if self.user_inputs else ""
|
||||
|
||||
def eject_wine_disc(self):
|
||||
prefix = self.target_path
|
||||
wine_path = wine.get_wine_version_exe(self._get_runner_version())
|
||||
wine.eject_disc(wine_path, prefix)
|
||||
wine_path = get_wine_version_exe(self._get_runner_version())
|
||||
wine.eject_disc(wine_path, self.target_path)
|
||||
|
||||
# -----------
|
||||
# Steam stuff
|
||||
|
@ -927,8 +926,3 @@ class ScriptInterpreter(CommandsMixin):
|
|||
if installer["id"] == self.gog_data["installerid"]:
|
||||
return (True, installer)
|
||||
return (False, "")
|
||||
|
||||
def eject_wine_disc(self):
|
||||
prefix = self.target_path
|
||||
wine_path = get_wine_version_exe(self._get_runner_version())
|
||||
wine.eject_disc(wine_path, prefix)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Dolphin runner"""
|
||||
from lutris.runners.runner import Runner
|
||||
from lutris.util import system
|
||||
import os
|
||||
|
||||
|
||||
class dolphin(Runner):
|
||||
|
|
|
@ -140,7 +140,7 @@ class mednafen(Runner):
|
|||
|
||||
for joy in joy_list:
|
||||
index = joy.find("Unique ID:")
|
||||
joy_id = joy[index + 11 :]
|
||||
joy_id = joy[index + 11:]
|
||||
logger.debug("Joystick found id %s ", joy_id)
|
||||
joy_ids.append(joy_id)
|
||||
return joy_ids
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
"""ResidualVM runner"""
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
|
@ -104,7 +105,7 @@ class residualvm(Runner):
|
|||
dir_limit = None
|
||||
if dir_limit is not None:
|
||||
game_dir = game[0:dir_limit]
|
||||
game_name = game[dir_limit + 1 : len(game)].strip()
|
||||
game_name = game[dir_limit + 1:len(game)].strip()
|
||||
game_array.append([game_dir, game_name])
|
||||
# The actual list is below a separator
|
||||
if game.startswith("-----"):
|
||||
|
|
|
@ -134,7 +134,7 @@ class scummvm(Runner):
|
|||
dir_limit = None
|
||||
if dir_limit is not None:
|
||||
game_dir = game[0:dir_limit]
|
||||
game_name = game[dir_limit + 1 : len(game)].strip()
|
||||
game_name = game[dir_limit + 1:len(game)].strip()
|
||||
game_array.append([game_dir, game_name])
|
||||
# The actual list is below a separator
|
||||
if game.startswith("-----"):
|
||||
|
|
|
@ -17,6 +17,7 @@ from lutris.services import ServiceGame
|
|||
NAME = "GOG"
|
||||
ICON = "gog"
|
||||
|
||||
|
||||
class GogService:
|
||||
"""Service class for GOG"""
|
||||
|
||||
|
@ -174,10 +175,13 @@ def connect(parent=None):
|
|||
|
||||
|
||||
def disconnect():
|
||||
"""Disconnect from GOG"""
|
||||
service = GogService()
|
||||
service.disconnect()
|
||||
|
||||
|
||||
def load_games():
|
||||
"""Load the user game library from the GOG API"""
|
||||
service = GogService()
|
||||
game_list = service.get_library()
|
||||
games = []
|
||||
|
@ -204,8 +208,8 @@ def load_games():
|
|||
|
||||
def sync_with_lutris(games):
|
||||
"""Sync GOG library"""
|
||||
with open(os.path.expanduser("~/game-list"), "w") as f:
|
||||
f.write(json.dumps(games, indent=2))
|
||||
with open(os.path.expanduser("~/game-list"), "w") as list_file:
|
||||
list_file.write(json.dumps(games, indent=2))
|
||||
|
||||
|
||||
def get_games():
|
||||
|
@ -214,7 +218,6 @@ def get_games():
|
|||
|
||||
game_list = service.get_library()
|
||||
print(json.dumps(game_list, indent=2))
|
||||
return
|
||||
|
||||
game_details = service.get_game_details("1430740694")
|
||||
done = False
|
||||
|
|
|
@ -51,7 +51,7 @@ def get_scummvm_games():
|
|||
if section == "scummvm":
|
||||
continue
|
||||
scummvm_id = section
|
||||
name = re.split(" \(.*\)$", config[section]["description"])[0]
|
||||
name = re.split(r" \(.*\)$", config[section]["description"])[0]
|
||||
path = config[section]["path"]
|
||||
yield (scummvm_id, name, path)
|
||||
|
||||
|
|
|
@ -1,79 +1,17 @@
|
|||
"""Steam service"""
|
||||
import os
|
||||
import re
|
||||
from collections import defaultdict
|
||||
|
||||
from lutris import pga
|
||||
from lutris.util.log import logger
|
||||
from lutris.util.system import path_exists
|
||||
from lutris.config import make_game_config_id, LutrisConfig
|
||||
from lutris.util.steam.appmanifest import AppManifest
|
||||
from lutris.util.steam.appmanifest import AppManifest, get_appmanifests
|
||||
from lutris.util.steam.config import get_steamapps_paths
|
||||
|
||||
NAME = "Steam"
|
||||
ICON = "steam"
|
||||
|
||||
|
||||
def get_appmanifests(steamapps_path):
|
||||
"""Return the list for all appmanifest files in a Steam library folder"""
|
||||
return [
|
||||
f for f in os.listdir(steamapps_path) if re.match(r"^appmanifest_\d+.acf$", f)
|
||||
]
|
||||
|
||||
|
||||
def get_steamapps_paths_for_platform(platform_name):
|
||||
from lutris.runners import winesteam, steam
|
||||
|
||||
runners = {"linux": steam.steam, "windows": winesteam.winesteam}
|
||||
runner = runners[platform_name]()
|
||||
return runner.get_steamapps_dirs()
|
||||
|
||||
|
||||
def get_steamapps_paths(flat=False, platform=None):
|
||||
base_platforms = ["linux", "windows"]
|
||||
if flat:
|
||||
steamapps_paths = []
|
||||
else:
|
||||
steamapps_paths = defaultdict(list)
|
||||
|
||||
if platform:
|
||||
if platform not in base_platforms:
|
||||
raise ValueError("Illegal value for Steam platform: %s" % platform)
|
||||
platforms = [platform]
|
||||
else:
|
||||
platforms = base_platforms
|
||||
|
||||
for _platform in platforms:
|
||||
folders = get_steamapps_paths_for_platform(_platform)
|
||||
if flat:
|
||||
steamapps_paths += folders
|
||||
else:
|
||||
steamapps_paths[_platform] = folders
|
||||
|
||||
return steamapps_paths
|
||||
|
||||
|
||||
def get_appmanifest_from_appid(steamapps_path, appid):
|
||||
"""Given the steam apps path and appid, return the corresponding appmanifest"""
|
||||
if not steamapps_path:
|
||||
raise ValueError("steamapps_path is mandatory")
|
||||
if not path_exists(steamapps_path):
|
||||
raise IOError("steamapps_path must be a valid directory")
|
||||
if not appid:
|
||||
raise ValueError("Missing mandatory appid")
|
||||
appmanifest_path = os.path.join(steamapps_path, "appmanifest_%s.acf" % appid)
|
||||
if not path_exists(appmanifest_path):
|
||||
return None
|
||||
return AppManifest(appmanifest_path)
|
||||
|
||||
|
||||
def get_path_from_appmanifest(steamapps_path, appid):
|
||||
"""Return the path where a Steam game is installed."""
|
||||
appmanifest = get_appmanifest_from_appid(steamapps_path, appid)
|
||||
if not appmanifest:
|
||||
return None
|
||||
return appmanifest.get_install_path()
|
||||
|
||||
|
||||
def mark_as_installed(steamid, runner_name, game_info):
|
||||
"""Sets a Steam game as installed"""
|
||||
for key in ["name", "slug"]:
|
||||
|
@ -165,7 +103,6 @@ def sync_with_lutris(games, platform="linux"):
|
|||
if pga_entry:
|
||||
sync_appmanifest_state(appmanifest_path, update=pga_entry)
|
||||
|
||||
|
||||
unavailable_ids = steamids_in_lutris.difference(seen_ids)
|
||||
for steamid in unavailable_ids:
|
||||
for game in steam_games_in_lutris:
|
||||
|
|
|
@ -239,9 +239,9 @@ def get_games_from_words(words):
|
|||
tag = None
|
||||
for word in words:
|
||||
if last_path != "" and path == "":
|
||||
if "game" in game:
|
||||
if game.get("game"):
|
||||
games.append(game["game"])
|
||||
elif "clrmamepro" in game:
|
||||
elif game.get("clrmamepro"):
|
||||
clrmamepro = game["clrmamepro"]
|
||||
game = {}
|
||||
else:
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Utility module to handle media resources"""
|
||||
import shutil
|
||||
import os
|
||||
import concurrent.futures
|
||||
from urllib.parse import urlparse, parse_qsl
|
||||
|
|
|
@ -5,6 +5,7 @@ from lutris.util.steam.vdf import vdf_parse
|
|||
from lutris.util.strings import slugify
|
||||
from lutris.util.log import logger
|
||||
from lutris.util.system import fix_path_case, path_exists
|
||||
from lutris.util.steam.config import get_steamapps_paths
|
||||
|
||||
APP_STATE_FLAGS = [
|
||||
"Invalid",
|
||||
|
@ -113,3 +114,25 @@ class AppManifest:
|
|||
return "steam"
|
||||
else:
|
||||
return "winesteam"
|
||||
|
||||
|
||||
def get_appmanifest_from_appid(steamapps_path, appid):
|
||||
"""Given the steam apps path and appid, return the corresponding appmanifest"""
|
||||
if not steamapps_path:
|
||||
raise ValueError("steamapps_path is mandatory")
|
||||
if not path_exists(steamapps_path):
|
||||
raise IOError("steamapps_path must be a valid directory")
|
||||
if not appid:
|
||||
raise ValueError("Missing mandatory appid")
|
||||
appmanifest_path = os.path.join(steamapps_path, "appmanifest_%s.acf" % appid)
|
||||
if not path_exists(appmanifest_path):
|
||||
return None
|
||||
return AppManifest(appmanifest_path)
|
||||
|
||||
|
||||
def get_path_from_appmanifest(steamapps_path, appid):
|
||||
"""Return the path where a Steam game is installed."""
|
||||
appmanifest = get_appmanifest_from_appid(steamapps_path, appid)
|
||||
if not appmanifest:
|
||||
return None
|
||||
return appmanifest.get_install_path()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Handle Steam configuration"""
|
||||
import os
|
||||
from collections import OrderedDict
|
||||
import re
|
||||
from collections import OrderedDict, defaultdict
|
||||
|
||||
from lutris.util import system
|
||||
from lutris.util.log import logger
|
||||
|
@ -38,3 +39,42 @@ def read_config(steam_data_dir):
|
|||
return None
|
||||
else:
|
||||
return config
|
||||
|
||||
|
||||
def get_appmanifests(steamapps_path):
|
||||
"""Return the list for all appmanifest files in a Steam library folder"""
|
||||
return [
|
||||
f for f in os.listdir(steamapps_path) if re.match(r"^appmanifest_\d+.acf$", f)
|
||||
]
|
||||
|
||||
|
||||
def get_steamapps_paths_for_platform(platform_name):
|
||||
from lutris.runners import winesteam, steam
|
||||
|
||||
runners = {"linux": steam.steam, "windows": winesteam.winesteam}
|
||||
runner = runners[platform_name]()
|
||||
return runner.get_steamapps_dirs()
|
||||
|
||||
|
||||
def get_steamapps_paths(flat=False, platform=None):
|
||||
base_platforms = ["linux", "windows"]
|
||||
if flat:
|
||||
steamapps_paths = []
|
||||
else:
|
||||
steamapps_paths = defaultdict(list)
|
||||
|
||||
if platform:
|
||||
if platform not in base_platforms:
|
||||
raise ValueError("Illegal value for Steam platform: %s" % platform)
|
||||
platforms = [platform]
|
||||
else:
|
||||
platforms = base_platforms
|
||||
|
||||
for _platform in platforms:
|
||||
folders = get_steamapps_paths_for_platform(_platform)
|
||||
if flat:
|
||||
steamapps_paths += folders
|
||||
else:
|
||||
steamapps_paths[_platform] = folders
|
||||
|
||||
return steamapps_paths
|
||||
|
|
|
@ -21,16 +21,14 @@ class WinePrefixManager:
|
|||
def get_registry_path(self, key):
|
||||
if key.startswith(self.hkcu_prefix):
|
||||
return os.path.join(self.path, "user.reg")
|
||||
else:
|
||||
raise ValueError("Unsupported key '{}'".format(key))
|
||||
raise ValueError("Unsupported key '{}'".format(key))
|
||||
|
||||
def get_key_path(self, key):
|
||||
if key.startswith(self.hkcu_prefix):
|
||||
return key[len(self.hkcu_prefix) + 1 :]
|
||||
else:
|
||||
raise ValueError(
|
||||
"The key {} is currently not supported by WinePrefixManager".format(key)
|
||||
)
|
||||
return key[len(self.hkcu_prefix) + 1:]
|
||||
raise ValueError(
|
||||
"The key {} is currently not supported by WinePrefixManager".format(key)
|
||||
)
|
||||
|
||||
def set_registry_key(self, key, subkey, value):
|
||||
registry = WineRegistry(self.get_registry_path(key))
|
||||
|
|
|
@ -104,11 +104,11 @@ class WineRegistry:
|
|||
line = line.rstrip("\n") # Remove trailing newlines
|
||||
|
||||
if line.startswith(self.version_header):
|
||||
self.version = int(line[len(self.version_header) :])
|
||||
self.version = int(line[len(self.version_header):])
|
||||
continue
|
||||
|
||||
if line.startswith(self.relative_to_header):
|
||||
self.relative_to = line[len(self.relative_to_header) :]
|
||||
self.relative_to = line[len(self.relative_to_header):]
|
||||
continue
|
||||
|
||||
if line.startswith("#arch"):
|
||||
|
@ -272,10 +272,9 @@ class WineRegistryKey:
|
|||
def render_value(self, value):
|
||||
if isinstance(value, int):
|
||||
return "dword:{:08x}".format(value)
|
||||
elif isinstance(value, str):
|
||||
if isinstance(value, str):
|
||||
return '"{}"'.format(value)
|
||||
else:
|
||||
raise NotImplementedError("TODO")
|
||||
raise NotImplementedError("TODO")
|
||||
|
||||
def add_meta(self, meta_line):
|
||||
if not meta_line.startswith("#"):
|
||||
|
@ -304,7 +303,6 @@ class WineRegistryKey:
|
|||
value = self.subkeys[name]
|
||||
if value.startswith('"') and value.endswith('"'):
|
||||
return value[1:-1]
|
||||
elif value.startswith("dword:"):
|
||||
if value.startswith("dword:"):
|
||||
return int(value[6:], 16)
|
||||
else:
|
||||
raise ValueError("Handle %s" % value)
|
||||
raise ValueError("Handle %s" % value)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
"""Module to setup and interact with X360CE"""
|
||||
from collections import OrderedDict
|
||||
from configparser import RawConfigParser
|
||||
from lutris.util import system
|
||||
|
@ -16,7 +17,7 @@ class X360ce:
|
|||
("InternetFeatures", 1),
|
||||
("InternetAutoload", 1),
|
||||
("AllowOnlyOneCopy", 1),
|
||||
("ProgramScanLocations", "C:\Program Files"),
|
||||
("ProgramScanLocations", "C:\\Program Files"),
|
||||
("Version", 2),
|
||||
("CombineEnabled", 0),
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue