def create_prefix(prefix, wine_path=None, arch='win32'): """Create a new Wine prefix.""" logger.debug("Creating a %s prefix in %s", arch, prefix) # Avoid issue of 64bit Wine refusing to create win32 prefix # over an existing empty folder. if os.path.isdir(prefix) and not os.listdir(prefix): os.rmdir(prefix) if not wine_path: wine_path = wine().get_executable() wineboot_path = os.path.join(os.path.dirname(wine_path), 'wineboot') if not system.path_exists(wineboot_path): logger.error("No wineboot executable found in %s, your wine installation is most likely broken", wine_path) return env = { 'WINEARCH': arch, 'WINEPREFIX': prefix } system.execute([wineboot_path], env=env) for i in range(20): time.sleep(.25) if os.path.exists(os.path.join(prefix, 'user.reg')): break if not os.path.exists(os.path.join(prefix, 'user.reg')): logger.error('No user.reg found after prefix creation. ' 'Prefix might not be valid') return logger.info('%s Prefix created in %s', arch, prefix) prefix_manager = WinePrefixManager(prefix) prefix_manager.setup_defaults()
def set_regedit_keys(self): """Reset regedit keys according to config.""" prefix = self.prefix_path enable_wine_desktop = False prefix_manager = WinePrefixManager(prefix) for key, path in self.reg_keys.items(): value = self.runner_config.get(key) or 'auto' if not value or value == 'auto' and key != 'ShowCrashDialog': delete_registry_key(path, wine_path=self.get_executable(), prefix=prefix, arch=self.wine_arch) elif key in self.runner_config: if key == 'Desktop' and value is True: enable_wine_desktop = True continue elif key == 'ShowCrashDialog': prefix_manager.set_crash_dialogs(value) continue else: type = 'REG_SZ' set_regedit(path, key, value, type=type, wine_path=self.get_executable(), prefix=prefix, arch=self.wine_arch) self.set_wine_desktop(enable_wine_desktop)
def create_prefix(prefix, wine_path=None, arch='win32'): """Create a new Wine prefix.""" logger.debug("Creating a %s prefix in %s", arch, prefix) # Avoid issue of 64bit Wine refusing to create win32 prefix # over an existing empty folder. if os.path.isdir(prefix) and not os.listdir(prefix): os.rmdir(prefix) if not wine_path: wine_path = wine().get_executable() wineboot_path = os.path.join(os.path.dirname(wine_path), 'wineboot') env = { 'WINEARCH': arch, 'WINEPREFIX': prefix } system.execute([wineboot_path], env=env) for i in range(20): time.sleep(.25) if os.path.exists(os.path.join(prefix, 'user.reg')): break if not os.path.exists(os.path.join(prefix, 'user.reg')): logger.error('No user.reg found after prefix creation. ' 'Prefix might not be valid') logger.info('%s Prefix created in %s', arch, prefix) prefix_manager = WinePrefixManager(prefix) prefix_manager.setup_defaults()
def set_regedit_keys(self): """Reset regedit keys according to config.""" prefix = self.prefix_path enable_wine_desktop = False prefix_manager = WinePrefixManager(prefix) for key, path in self.reg_keys.items(): value = self.runner_config.get(key) or 'auto' if not value or value == 'auto' and key != 'ShowCrashDialog': delete_registry_key(path, wine_path=self.get_executable(), prefix=prefix, arch=self.wine_arch) elif key in self.runner_config: if key == 'Desktop' and value is True: enable_wine_desktop = True continue elif key == 'ShowCrashDialog': prefix_manager.set_crash_dialogs(value) continue else: type = 'REG_SZ' set_regedit(path, key, value, type=type, wine_path=self.get_executable(), prefix=prefix, arch=self.wine_arch) self.set_wine_desktop(enable_wine_desktop) overrides = self.runner_config.get('overrides') or {} for dll, value in overrides.items(): prefix_manager.override_dll(dll, value)
def prelaunch(self): if not os.path.exists(os.path.join(self.prefix_path, 'user.reg')): create_prefix(self.prefix_path, arch=self.wine_arch) prefix_manager = WinePrefixManager(self.prefix_path) prefix_manager.setup_defaults() prefix_manager.configure_joypads() self.set_regedit_keys() return True
def prelaunch(self): if not os.path.exists(os.path.join(self.prefix_path, 'user.reg')): create_prefix(self.prefix_path, arch=self.wine_arch) prefix_manager = WinePrefixManager(self.prefix_path) prefix_manager.configure_joypads() self.sandbox(prefix_manager) self.set_regedit_keys() return True
def prelaunch(self): if not os.path.exists(os.path.join(self.prefix_path, 'user.reg')): create_prefix(self.prefix_path, arch=self.wine_arch) prefix_manager = WinePrefixManager(self.prefix_path) prefix_manager.configure_joypads() self.sandbox(prefix_manager) self.set_regedit_keys() self.setup_x360ce(self.runner_config.get('x360ce-path')) self.toggle_dxvk(bool(self.runner_config.get('dxvk')), version=self.runner_config.get('dxvk_version')) return True
def create_prefix(prefix, wine_path=None, arch='win32', overrides={}, install_gecko=None, install_mono=None): """Create a new Wine prefix.""" logger.debug("Creating a %s prefix in %s", arch, prefix) # Avoid issue of 64bit Wine refusing to create win32 prefix # over an existing empty folder. if os.path.isdir(prefix) and not os.listdir(prefix): os.rmdir(prefix) if not wine_path: wine = import_runner('wine') wine_path = wine().get_executable() if not wine_path: logger.error("Wine not found, can't create prefix") return wineboot_path = os.path.join(os.path.dirname(wine_path), 'wineboot') if not system.path_exists(wineboot_path): logger.error( "No wineboot executable found in %s, " "your wine installation is most likely broken", wine_path) return if install_gecko == 'False': overrides['mshtml'] = 'disabled' if install_mono == 'False': overrides['mscoree'] = 'disabled' wineenv = { 'WINEARCH': arch, 'WINEPREFIX': prefix, 'WINEDLLOVERRIDES': get_overrides_env(overrides) } system.execute([wineboot_path], env=wineenv) for loop_index in range(50): time.sleep(.25) if system.path_exists(os.path.join(prefix, 'user.reg')): break if loop_index == 20: logger.warning( "Wine prefix creation is taking longer than expected...") if not os.path.exists(os.path.join(prefix, 'user.reg')): logger.error('No user.reg found after prefix creation. ' 'Prefix might not be valid') return logger.info('%s Prefix created in %s', arch, prefix) prefix_manager = WinePrefixManager(prefix) prefix_manager.setup_defaults()
def set_regedit_keys(self): """Reset regedit keys according to config.""" prefix = self.prefix_path enable_wine_desktop = False prefix_manager = WinePrefixManager(prefix) # Those options are directly changed with the prefix manager and skip # any calls to regedit. managed_keys = { 'ShowCrashDialog': prefix_manager.set_crash_dialogs, 'UseXVidMode': prefix_manager.use_xvid_mode } for key, path in self.reg_keys.items(): value = self.runner_config.get(key) or 'auto' if not value or value == 'auto' and key not in managed_keys.keys(): delete_registry_key(path, wine_path=self.get_executable(), prefix=prefix, arch=self.wine_arch) elif key in self.runner_config: if key == 'Desktop' and value is True: enable_wine_desktop = True continue elif key in managed_keys.keys(): managed_keys[key](value) continue set_regedit(path, key, value, type='REG_SZ', wine_path=self.get_executable(), prefix=prefix, arch=self.wine_arch) self.set_wine_desktop(enable_wine_desktop)
def create_prefix(prefix, wine_path=None, arch='win32', overrides={}, install_gecko=None, install_mono=None): """Create a new Wine prefix.""" logger.debug("Creating a %s prefix in %s", arch, prefix) # Avoid issue of 64bit Wine refusing to create win32 prefix # over an existing empty folder. if os.path.isdir(prefix) and not os.listdir(prefix): os.rmdir(prefix) if not wine_path: wine_path = wine().get_executable() wineboot_path = os.path.join(os.path.dirname(wine_path), 'wineboot') if not system.path_exists(wineboot_path): logger.error("No wineboot executable found in %s, " "your wine installation is most likely broken", wine_path) return if install_gecko is 'False': overrides['mshtml'] = 'disabled' if install_mono is 'False': overrides['mscoree'] = 'disabled' wineenv = { 'WINEARCH': arch, 'WINEPREFIX': prefix, 'WINEDLLOVERRIDES': get_overrides_env(overrides) } system.execute([wineboot_path], env=wineenv) for i in range(20): time.sleep(.25) if os.path.exists(os.path.join(prefix, 'user.reg')): break if not os.path.exists(os.path.join(prefix, 'user.reg')): logger.error('No user.reg found after prefix creation. ' 'Prefix might not be valid') return logger.info('%s Prefix created in %s', arch, prefix) prefix_manager = WinePrefixManager(prefix) prefix_manager.setup_defaults()
def set_regedit_keys(self): """Reset regedit keys according to config.""" prefix = self.prefix_path prefix_manager = WinePrefixManager(prefix) # Those options are directly changed with the prefix manager and skip # any calls to regedit. managed_keys = { 'ShowCrashDialog': prefix_manager.set_crash_dialogs, 'UseXVidMode': prefix_manager.use_xvid_mode, 'Desktop': prefix_manager.set_virtual_desktop, 'WineDesktop': prefix_manager.set_desktop_size } for key, path in self.reg_keys.items(): value = self.runner_config.get(key) or 'auto' if not value or value == 'auto' and key not in managed_keys.keys(): prefix_manager.clear_registry_key(path) elif key in self.runner_config: if key in managed_keys.keys(): # Do not pass fallback 'auto' value to managed keys if value == 'auto': value = None managed_keys[key](value) continue prefix_manager.set_registry_key(path, key, value)
def set_wine_desktop(self, enable_desktop=False): prefix = self.prefix_path prefix_manager = WinePrefixManager(prefix) path = self.reg_keys['Desktop'] if enable_desktop: prefix_manager.set_registry_key(path, 'Desktop', 'WineDesktop') else: prefix_manager.clear_registry_key(path)
def prelaunch(self): prefix_manager = WinePrefixManager(self.prefix_path) prefix_manager.setup_defaults() prefix_manager.configure_joypads() self.set_regedit_keys() return True