determining the version of Wine used
This commit is contained in:
@@ -2012,12 +2012,40 @@ class WineHelperGUI(QMainWindow):
|
|||||||
QMessageBox.critical(self, "Ошибка", f"Каталог префикса не найден:\n{prefix_path}")
|
QMessageBox.critical(self, "Ошибка", f"Каталог префикса не найден:\n{prefix_path}")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# --- Определение используемой версии Wine ---
|
||||||
|
wine_executable = 'wine' # По умолчанию системный wine
|
||||||
|
last_conf_path = os.path.join(prefix_path, "last.conf")
|
||||||
|
wh_wine_use = None
|
||||||
|
|
||||||
|
if os.path.exists(last_conf_path):
|
||||||
|
try:
|
||||||
|
with open(last_conf_path, 'r', encoding='utf-8') as f:
|
||||||
|
for line in f:
|
||||||
|
if 'WH_WINE_USE=' in line:
|
||||||
|
# Извлекаем значение из строки вида: export WH_WINE_USE="wine_ver"
|
||||||
|
value = line.split('=', 1)[1].strip().strip('"\'')
|
||||||
|
if value:
|
||||||
|
wh_wine_use = value
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Предупреждение: не удалось прочитать или обработать {last_conf_path}: {e}")
|
||||||
|
|
||||||
|
if wh_wine_use and not wh_wine_use.startswith('system'):
|
||||||
|
local_wine_path = os.path.join(Var.USER_WORK_PATH, "dist", wh_wine_use, "bin", "wine")
|
||||||
|
if os.path.exists(local_wine_path):
|
||||||
|
wine_executable = local_wine_path
|
||||||
|
else:
|
||||||
|
QMessageBox.warning(self, "Предупреждение",
|
||||||
|
f"Локальная версия Wine '{wh_wine_use}' не найдена по пути:\n{local_wine_path}\n\n"
|
||||||
|
"Будет использована системная версия Wine.")
|
||||||
|
# --- Конец определения версии Wine ---
|
||||||
|
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env["WINEPREFIX"] = prefix_path
|
env["WINEPREFIX"] = prefix_path
|
||||||
|
|
||||||
# 'wine cmd' - особый случай, требует запуска в терминале
|
# 'wine cmd' - особый случай, требует запуска в терминале
|
||||||
if util_name == 'cmd':
|
if util_name == 'cmd':
|
||||||
terminal_command = f"env WINEPREFIX='{prefix_path}' wine cmd"
|
terminal_command = f"env WINEPREFIX='{prefix_path}' {shlex.quote(wine_executable)} cmd"
|
||||||
try:
|
try:
|
||||||
# x-terminal-emulator - стандартный способ вызова терминала по умолчанию
|
# x-terminal-emulator - стандартный способ вызова терминала по умолчанию
|
||||||
subprocess.Popen(['x-terminal-emulator', '-e', terminal_command])
|
subprocess.Popen(['x-terminal-emulator', '-e', terminal_command])
|
||||||
@@ -2028,7 +2056,7 @@ class WineHelperGUI(QMainWindow):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Для остальных утилит
|
# Для остальных утилит
|
||||||
command = ['wine', util_name]
|
command = [wine_executable, util_name]
|
||||||
try:
|
try:
|
||||||
subprocess.Popen(command, env=env)
|
subprocess.Popen(command, env=env)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Reference in New Issue
Block a user