示例#1
0
 def unmount(self, delete=True):
     if self.mount_path.exists():
         _, stderr = cmd_exec(f"sudo umount -f {self.mount_path}")
         # if stderr:
         # raise Exception(f"error umounting memdisk: {stderr}")
         if delete:
             _, stderr = cmd_exec(f"sudo rm -rf {self.mount_path}")
             if stderr:
                 raise Exception(f"error umounting memdisk: {stderr}")
     if delete:
         self.__delete()
示例#2
0
 def mount(self, fs_type="cd9660"):
     self.__create()
     if self.mount_path.exists():
         self.unmount()
     else:
         _, stderr = cmd_exec(f"sudo mkdir -p {self.mount_path}")
         if stderr:
             raise Exception(f"error mounting memdisk: {stderr}")
     _, stderr = cmd_exec(f"sudo mount -t {fs_type} {self.md_path} {self.mount_path}")
     if stderr:
         raise Exception(f"error mounting memdisk: {stderr}")
     return self.mount_path
示例#3
0
    def copy(self):
        images = self.conf.get("images", {})
        for img_name, dst_src in images.items():
            for dst, src_files in dst_src.items():
                dst = eval_path(dst, self.env)
                if isinstance(src_files, list):
                    Path(dst).mkdir(parents=True, exist_ok=True)
                    for s in src_files:
                        src = self.mounts[img_name] / s
                        copy_ex(Path(src), Path(dst))
                else:
                    src = self.mounts[img_name] / src_files
                    copy_ex(src, Path(dst))

            # perform inside a loop to avoid permission issues on copying same files from diff images
            cmd_exec(f"chmod -R 755 {self.game_path}")
示例#4
0
 def __create(self, replace=True):
     stdout, stderr = cmd_exec(f"sudo mdconfig -a -t vnode -f {self.image_path} -u {self.unit}")
     if stderr:
         if replace:
             self.unmount()
             self.__create(replace=False)
             return
         raise Exception(f"error creating memdisk: {stderr}")
示例#5
0
 def __del__(self):
     self.unmount()
     restore_screen_resolution()
     post_cmd = self.conf.get("post_cmd", None)
     if post_cmd:
         _, stderr = cmd_exec(post_cmd)
         if stderr:
             print(f"post_cmd errors: {stderr}")
     super(Wine, self).__del__()
示例#6
0
 def extract(self):
     tmp_path = Path("/tmp") / self.title
     if tmp_path.exists():
         rm_dir(tmp_path)
     installer_path = Path(IMAGES_STORAGE_PATH) / self.title / self.conf["installer"]
     _, stderr = cmd_exec(f"innoextract --extract --exclude-temp --color --progress --gog --output-dir {tmp_path} {installer_path}")
     if stderr:
         print(f"innoextract error: {stderr}")
     for file in self.conf["app_files"]:
         copy_ex(tmp_path / file, self.game_path)
     rm_dir(tmp_path)
示例#7
0
    def run(self):
        cmd_list = []

        cmd_list.append(f"MOUNT C {GAMES_BASE_PATH}")

        cdrom_drive_letter = "D"

        if 'images' in self.conf:
            img_paths = []
            for img in self.conf["images"]:
                img_paths.append(
                    str(Path(IMAGES_STORAGE_PATH) / self.title / img))
            img_paths = " ".join(img_paths)
            cmd_list.append(
                f"IMGMOUNT {cdrom_drive_letter} {img_paths} -t iso")

        if self.cdrom_folder:
            cmd_list.append(
                f"MOUNT {cdrom_drive_letter} {self.cdrom_folder} -t cdrom")

        cmd_list.append("C:")

        dos_folder = self.title.upper()
        if len(dos_folder) > 8:
            dos_folder = dos_folder[:6] + "~1"
        cmd_list.append(f"cd {dos_folder}")

        cmd_list.append(self.conf["exec_file"])

        cmd_list.append("exit")

        cmd_line = ""
        conf_path = Path(DOSBOX_CONF_PATH)
        cmd_line += f"dosbox -conf {conf_path}"
        for c in cmd_list:
            cmd_line += f' -c "{c}"'

        _, stderr = cmd_exec(cmd_line)
        if stderr:
            print(f"dosbox errors: {stderr}")
示例#8
0
    def run(self):
        self.mount()

        screen_resolution = self.conf.get("screen_resolution", None)

        if self.conf.get("emul_virtual_desktop", False):
            assert screen_resolution is not None
            self.emul_virtual_desktop(screen_resolution)
        else:
            self.emul_virtual_desktop()

        if screen_resolution:
            set_screen_resolution(screen_resolution)

        pre_cmd = self.conf.get("pre_cmd", None)
        if pre_cmd:
            _, stderr = cmd_exec(pre_cmd)
            if stderr:
                print(f"pre_cmd errors: {stderr}")

        cwd = eval_path(Path(self.conf.get("cwd", self.game_path)), self.env)

        self.run_wine_cmd(cmd=f'"{self.conf["exec_file"]}"', cwd=str(cwd))
示例#9
0
 def remove_drive(self, path):
     _, stderr = cmd_exec(f"rm {path}")
     if stderr:
         raise Exception(f"error removing drive: {stderr}")
示例#10
0
 def run_wine_cmd(self, cmd, cwd=None):
     env = os.environ.copy()
     env["WINEPREFIX"] = str(self.env_path)
     _, stderr = cmd_exec(f'wine {cmd}', env=env, cwd=cwd)
     if stderr:
         print(f"wine errors: {stderr}")
示例#11
0
 def __delete(self):
     _, stderr = cmd_exec(f"sudo mdconfig -d -u {self.unit}")
     if stderr:
         raise Exception(f"error deleting memdisk: {stderr}")
示例#12
0
 def run(self):
     conf_path = Path(SCUMMVM_CONF_PATH)
     _, stderr = cmd_exec(f"scummvm --config={conf_path} --game={self.conf['scummvm_gameid']} --path={self.game_path} --savepath={self.saves_path} --auto-detect")
     if stderr:
         print(f"scummvm errors: {stderr}")
示例#13
0
 def perform_bspatch(self, target_file, patch_file):
     tmp_file = Path(str(target_file) + ".tmp")
     _, stderr = cmd_exec(f"bspatch {target_file} {tmp_file} {patch_file}")
     if stderr:
         raise Exception(f"error patching file: {stderr}")
     tmp_file.replace(target_file)