def load_regs(s: [str], patches: dict = None): prepare() target_filename = str(int(time.time())) + ".reg" target_path = os.path.join(variables.wine_temp(), target_filename) with open(target_path, "w+") as fp: if patches is None: fp.write("\r\n".join(s)) else: out_lines = [] for line in s: for k, v in patches.items(): varkey = "$" + k if varkey in line: line = line.replace(varkey, v) out_lines.append(line) fp.writelines(out_lines) winreg = "C:\\windows\\temp\\{}".format(target_filename) os.spawnlp(os.P_WAIT, variables.wine_binary(), variables.wine_binary(), "regedit", "/S", winreg) os.spawnlp(os.P_WAIT, variables.wine_binary_64(), variables.wine_binary_64(), "regedit", "/S", winreg) os.remove(target_path)
def load_reg(srcfile): LOG.info(f"Loading registry file {srcfile} into the wineprefix") prepare() target_filename = str(int(time.time())) + ".reg" target_path = os.path.join(variables.wine_temp(), target_filename) shutil.copyfile(srcfile, target_path) winreg = "C:\\windows\\temp\\{}".format(target_filename) os.spawnlp(os.P_WAIT, variables.wine_binary(), variables.wine_binary(), "regedit", "/S", winreg) os.spawnlp(os.P_WAIT, variables.wine_binary_64(), variables.wine_binary_64(), "regedit", "/S", winreg) os.remove(target_path)
def run_exe_nowait(exe_path, *args) -> ProcessWrapper: prepare() command = [variables.wine_binary(), exe_path, *args] p = subprocess.Popen(command, stdin=DEVNULL, stdout=sys.stdout, stderr=sys.stderr, close_fds=True) wrapper = ProcessWrapper(p) processes.append(wrapper) poll_processes() return wrapper
def run_roblox_installer(self, *_): def no_wine_dialog() -> None: dialog("Grapejuice could not find a working Wine binary, please install Wine using your operating " "system's package manager in order to install and use Roblox.") return None try: wine_bin = variables.wine_binary() if not os.path.exists(wine_bin): return no_wine_dialog() except NoWineError: return no_wine_dialog() if not wine_ok(): return run_task_once(InstallRoblox, generic_already_running)
def explorer(): prepare() os.spawnlp(os.P_NOWAIT, variables.wine_binary(), variables.wine_binary(), "explorer")
def regedit(): prepare() os.spawnlp(os.P_NOWAIT, variables.wine_binary(), variables.wine_binary(), "regedit")
def winecfg(): prepare() os.spawnlp(os.P_NOWAIT, variables.wine_binary(), variables.wine_binary(), "winecfg")
def run_exe(exe_path, *args): prepare() if len(args) > 0: os.spawnlp(os.P_NOWAIT, variables.wine_binary(), variables.wine_binary(), exe_path, *args) else: os.spawnlp(os.P_NOWAIT, variables.wine_binary(), variables.wine_binary(), exe_path)
def WineVersion(self): v = subprocess.check_output([variables.wine_binary(), "--version"]) if not v: return "wine-0.0.0" return v