Wine,WineResolver: Add more logging
This commit is contained in:
parent
9a941e3001
commit
ba65ffa905
2 changed files with 39 additions and 19 deletions
|
@ -98,17 +98,23 @@ class OriginWineWorker(QRunnable):
|
||||||
# lk: this is the alternative way of getting the path by using wine itself
|
# lk: this is the alternative way of getting the path by using wine itself
|
||||||
install_dir = wine.query_reg_key(wine_exec, wine_env, f"HKLM\\{reg_path}", reg_key)
|
install_dir = wine.query_reg_key(wine_exec, wine_env, f"HKLM\\{reg_path}", reg_key)
|
||||||
|
|
||||||
logger.debug("Found Wine install directory %s", install_dir)
|
|
||||||
|
|
||||||
if install_dir:
|
if install_dir:
|
||||||
|
logger.debug("Found Wine install directory %s", install_dir)
|
||||||
install_dir = wine.convert_to_unix_path(wine_exec, wine_env, install_dir)
|
install_dir = wine.convert_to_unix_path(wine_exec, wine_env, install_dir)
|
||||||
|
if install_dir:
|
||||||
logger.debug("Found Unix install directory %s", install_dir)
|
logger.debug("Found Unix install directory %s", install_dir)
|
||||||
|
else:
|
||||||
|
logger.info("Could not find Unix install directory for %s", rgame.title)
|
||||||
|
else:
|
||||||
|
logger.info("Could not find Wine install directory for %s", rgame.title)
|
||||||
|
|
||||||
if install_dir:
|
if install_dir:
|
||||||
if os.path.isdir(install_dir):
|
if os.path.isdir(install_dir):
|
||||||
install_size = path_size(install_dir)
|
install_size = path_size(install_dir)
|
||||||
rgame.set_origin_attributes(install_dir, install_size)
|
rgame.set_origin_attributes(install_dir, install_size)
|
||||||
logger.debug(f"Origin game {rgame.title} ({install_dir}, {format_size(install_size)})")
|
logger.info("Origin game %s (%s, %s)", rgame.title, install_dir, format_size(install_size))
|
||||||
else:
|
else:
|
||||||
logger.warning(f"Origin game {rgame.title} ({install_dir} does not exist)")
|
logger.warning("Origin game %s (%s does not exist)", rgame.title, install_dir)
|
||||||
logger.info(f"Origin worker finished in {time.time() - t}s")
|
else:
|
||||||
|
logger.info("Origin game %s is not installed", rgame.title)
|
||||||
|
logger.info("Origin worker finished in %ss", time.time() - t)
|
||||||
|
|
|
@ -28,6 +28,7 @@ def execute(cmd: List, wine_env: Mapping) -> Tuple[str, str]:
|
||||||
for name, value in wine_env.items():
|
for name, value in wine_env.items():
|
||||||
flatpak_cmd.append(f"--env={name}={value}")
|
flatpak_cmd.append(f"--env={name}={value}")
|
||||||
cmd = flatpak_cmd + cmd
|
cmd = flatpak_cmd + cmd
|
||||||
|
try:
|
||||||
proc = subprocess.Popen(
|
proc = subprocess.Popen(
|
||||||
cmd,
|
cmd,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
|
@ -39,6 +40,8 @@ def execute(cmd: List, wine_env: Mapping) -> Tuple[str, str]:
|
||||||
text=True,
|
text=True,
|
||||||
)
|
)
|
||||||
res = proc.communicate()
|
res = proc.communicate()
|
||||||
|
except (FileNotFoundError, PermissionError) as e:
|
||||||
|
res = ("", str(e))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +52,11 @@ def resolve_path(wine_exec: str, wine_env: Mapping, path: str) -> str:
|
||||||
# lk: if path exists and needs a case-sensitive interpretation form
|
# lk: if path exists and needs a case-sensitive interpretation form
|
||||||
# cmd = [wine_cmd, 'cmd', '/c', f'cd {path} & cd']
|
# cmd = [wine_cmd, 'cmd', '/c', f'cd {path} & cd']
|
||||||
out, err = execute(cmd, wine_env)
|
out, err = execute(cmd, wine_env)
|
||||||
return out.strip().strip('"')
|
out, err = out.strip(), err.strip()
|
||||||
|
if not out:
|
||||||
|
logger.error("Failed to resolve wine path due to \"%s\"", err)
|
||||||
|
return out
|
||||||
|
return out.strip('"')
|
||||||
|
|
||||||
|
|
||||||
def query_reg_path(wine_exec: str, wine_env: Mapping, reg_path: str):
|
def query_reg_path(wine_exec: str, wine_env: Mapping, reg_path: str):
|
||||||
|
@ -59,6 +66,10 @@ def query_reg_path(wine_exec: str, wine_env: Mapping, reg_path: str):
|
||||||
def query_reg_key(wine_exec: str, wine_env: Mapping, reg_path: str, reg_key) -> str:
|
def query_reg_key(wine_exec: str, wine_env: Mapping, reg_path: str, reg_key) -> str:
|
||||||
cmd = [wine_exec, "reg", "query", reg_path, "/v", reg_key]
|
cmd = [wine_exec, "reg", "query", reg_path, "/v", reg_key]
|
||||||
out, err = execute(cmd, wine_env)
|
out, err = execute(cmd, wine_env)
|
||||||
|
out, err = out.strip(), err.strip()
|
||||||
|
if not out:
|
||||||
|
logger.error("Failed to query registry key due to \"%s\"", err)
|
||||||
|
return out
|
||||||
lines = out.split("\n")
|
lines = out.split("\n")
|
||||||
keys: Dict = {}
|
keys: Dict = {}
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
@ -76,7 +87,10 @@ def convert_to_unix_path(wine_exec: str, wine_env: Mapping, path: str) -> str:
|
||||||
path = path.strip().strip('"')
|
path = path.strip().strip('"')
|
||||||
cmd = [wine_exec, "winepath.exe", "-u", path]
|
cmd = [wine_exec, "winepath.exe", "-u", path]
|
||||||
out, err = execute(cmd, wine_env)
|
out, err = execute(cmd, wine_env)
|
||||||
return os.path.realpath(out.strip())
|
out, err = out.strip(), err.strip()
|
||||||
|
if not out:
|
||||||
|
logger.error("Failed to convert to unix path due to \"%s\"", err)
|
||||||
|
return os.path.realpath(out) if (out := out.strip()) else out
|
||||||
|
|
||||||
|
|
||||||
def wine(core: LegendaryCore, app_name: str = "default") -> str:
|
def wine(core: LegendaryCore, app_name: str = "default") -> str:
|
||||||
|
|
Loading…
Reference in a new issue