示例#1
0
    def unpack_game_hard_drives(self, file_list):
        drives_added = set()
        dir_path = self.drives_dir.path
        for file_entry in file_list:
            # if self.stop_flag:
            #     return

            name = file_entry["name"]
            name = name.upper()

            drives_added.add(name[0])

            # Extract relative path and convert each path component
            # to host file name (where needed).

            rel_path = name
            print("rel_path", rel_path)
            rel_parts = rel_path.split("/")
            # for i, part in enumerate(rel_parts):
            #     # part can be blank if rel_parts is a directory
            #     # (ending with /)
            #     if part:
            #         rel_parts[i] = amiga_filename_to_host_filename(part)
            rel_path = "/".join(rel_parts)

            dst_file = os.path.join(dir_path, rel_path)
            print(repr(dst_file))
            if name.endswith("/"):
                os.makedirs(str_path(dst_file))
                continue
            sha1 = file_entry["sha1"]
            src_file = self.fsgc.file.find_by_sha1(sha1)
            if not os.path.exists(os.path.dirname(dst_file)):
                os.makedirs(os.path.dirname(dst_file))
            stream = self.fsgc.file.open(src_file)
            # archive = Archive(src_file)
            # f = archive.open(src_file)
            data = stream.read()
            assert hashlib.sha1(data).hexdigest() == sha1

            with open(dst_file, "wb") as out_file:
                out_file.write(data)
            if dst_file.endswith(".CUE"):
                with open(dst_file, "r", encoding="ISO-8859-1") as f:
                    data = f.read()
                data = data.upper()
                with open(dst_file, "w", encoding="ISO-8859-1") as f:
                    f.write(data)

        for drive in sorted(drives_added):
            self.drives.append((drive, os.path.join(dir_path, drive)))
示例#2
0
    def unpack_game_hard_drives(self, file_list):
        drives_added = set()
        dir_path = self.drives_dir.path
        for file_entry in file_list:
            # if self.stop_flag:
            #     return

            name = file_entry["name"]
            name = name.upper()

            drives_added.add(name[0])

            # Extract relative path and convert each path component
            # to host file name (where needed).

            rel_path = name
            print("rel_path", rel_path)
            rel_parts = rel_path.split("/")
            # for i, part in enumerate(rel_parts):
            #     # part can be blank if rel_parts is a directory
            #     # (ending with /)
            #     if part:
            #         rel_parts[i] = amiga_filename_to_host_filename(part)
            rel_path = "/".join(rel_parts)

            dst_file = os.path.join(dir_path, rel_path)
            print(repr(dst_file))
            if name.endswith("/"):
                os.makedirs(str_path(dst_file))
                continue
            sha1 = file_entry["sha1"]
            src_file = self.fsgc.file.find_by_sha1(sha1)
            if not os.path.exists(os.path.dirname(dst_file)):
                os.makedirs(os.path.dirname(dst_file))
            stream = self.fsgc.file.open(src_file)
            # archive = Archive(src_file)
            # f = archive.open(src_file)
            data = stream.read()
            assert hashlib.sha1(data).hexdigest() == sha1

            with open(dst_file, "wb") as out_file:
                out_file.write(data)
            if dst_file.endswith(".CUE"):
                with open(dst_file, "r", encoding="ISO-8859-1") as f:
                    data = f.read()
                data = data.upper()
                with open(dst_file, "w", encoding="ISO-8859-1") as f:
                    f.write(data)

        for drive in sorted(drives_added):
            self.drives.append((drive, os.path.join(dir_path, drive)))
 def run_program(cls, name, **kwargs):
     path = cls.get_program_path(name)
     if not path:
         raise Exception("Could not find program {0}".format(name))
     print("program", name, "at", path)
     path = os.path.join(os.getcwd(), path)
     path = os.path.normpath(path)
     print("program path (normalized):", path)
     dir_name = os.path.dirname(path)
     kwargs["env"]["LD_LIBRARY_PATH"] = str_path(dir_name)
     kwargs["args"].insert(0, path)
     print("run:", kwargs["args"])
     print("cwd:", kwargs.get("cwd", ""))
     return subprocess.Popen(**kwargs)
示例#4
0
 def run_program(cls, name, **kwargs):
     path = cls.get_program_path(name)
     if not path:
         raise Exception("Could not find program {0}".format(name))
     print("program", name, "at", path)
     path = os.path.join(os.getcwd(), path)
     path = os.path.normpath(path)
     print("program path (normalized):", path)
     dir_name = os.path.dirname(path)
     kwargs["env"]["LD_LIBRARY_PATH"] = str_path(dir_name)
     kwargs["args"].insert(0, path)
     print("run:", kwargs["args"])
     print("cwd:", kwargs.get("cwd", ""))
     return subprocess.Popen(**kwargs)