Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

53 linhas
1.4 KiB

  1. """
  2. Deprecate archived_sites folder for consistency. This change is
  3. only for Xhiveframework v14 benches. If not a v14 bench yet, skip this
  4. patch and try again later.
  5. 1. Rename folder `./archived_sites` to `./archived/sites`
  6. 2. Create a symlink `./archived_sites` => `./archived/sites`
  7. Corresponding changes in xhiveframework/xhiveframework via https://lab.membtech.com/xhiveframework/xhiveframework15/pull/15060
  8. """
  9. import os
  10. from pathlib import Path
  11. import click
  12. from bench.utils.app import get_current_version
  13. from semantic_version import Version
  14. def execute(bench_path):
  15. xhiveframework_version = Version(get_current_version("xhiveframework"))
  16. if xhiveframework_version.major < 14 or os.name != "posix":
  17. # Returning False means patch has been skipped
  18. return False
  19. pre_patch_dir = os.getcwd()
  20. old_directory = Path(bench_path, "archived_sites")
  21. new_directory = Path(bench_path, "archived", "sites")
  22. if not old_directory.exists():
  23. return False
  24. if old_directory.is_symlink():
  25. return True
  26. os.chdir(bench_path)
  27. if not os.path.exists(new_directory):
  28. os.makedirs(new_directory)
  29. old_directory.rename(new_directory)
  30. click.secho(f"Archived sites are now stored under {new_directory}")
  31. if not os.listdir(old_directory):
  32. os.rmdir(old_directory)
  33. os.symlink(new_directory, old_directory)
  34. click.secho(f"Symlink {old_directory} that points to {new_directory}")
  35. os.chdir(pre_patch_dir)