from pathlib import Path from clishared import cli_connect_rom, cli_read_rom, cli_patch_rom, cli_write_rom, cli_choose_patches print("ThinkPad X230 Automatic Firmware Extract and Patch v1") project_name = input("What would you like to name your project? ") project_name = project_name.replace("\\", "") # Remove backslashes so I can drag and drop folders project_path = Path(project_name).resolve() if project_path.exists(): if project_path.is_file(): raise FileExistsError(f"Cannot create project folder {project_path}, a file already exists here.") elif project_path.is_dir(): response = input("Folder already exists at this location. Proceed and risk overwriting existing files? (y/N): ") if not response or (response.strip()[0] not in ['y', 'Y']): raise FileExistsError(f"Cannot create project folder {project_path}, a directory already exists here.") else: project_path.mkdir() clean_path = project_path / "clean" if not clean_path.exists(): clean_path.mkdir() patched_path = project_path / "patched" if not patched_path.exists(): patched_path.mkdir() patches = cli_choose_patches() cli_connect_rom("top") cli_read_rom("top", clean_path) cli_patch_rom(patches, clean_path, patched_path) cli_write_rom("top", patched_path) print("All done.")