You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.3 KiB

5 years ago
  1. from pathlib import Path
  2. from clishared import cli_connect_rom, cli_read_rom, cli_patch_rom, cli_write_rom, cli_choose_patches
  3. print("ThinkPad X230 Automatic Firmware Extract and Patch v1")
  4. project_name = input("What would you like to name your project? ")
  5. project_name = project_name.replace("\\", "") # Remove backslashes so I can drag and drop folders
  6. project_path = Path(project_name).resolve()
  7. if project_path.exists():
  8. if project_path.is_file():
  9. raise FileExistsError(f"Cannot create project folder {project_path}, a file already exists here.")
  10. elif project_path.is_dir():
  11. response = input("Folder already exists at this location. Proceed and risk overwriting existing files? (y/N): ")
  12. if not response or (response.strip()[0] not in ['y', 'Y']):
  13. raise FileExistsError(f"Cannot create project folder {project_path}, a directory already exists here.")
  14. else:
  15. project_path.mkdir()
  16. clean_path = project_path / "clean"
  17. if not clean_path.exists():
  18. clean_path.mkdir()
  19. patched_path = project_path / "patched"
  20. if not patched_path.exists():
  21. patched_path.mkdir()
  22. patches = cli_choose_patches()
  23. cli_connect_rom("top")
  24. cli_read_rom("top", clean_path)
  25. cli_patch_rom(patches, clean_path, patched_path)
  26. cli_write_rom("top", patched_path)
  27. print("All done.")