setup_testing.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. from PyQt5.QtCore import QSettings
  2. from easygui import diropenbox, ynbox, msgbox
  3. import pathlib as pl
  4. from view.gui.application_settings import get_view_qsettings_manager
  5. def main():
  6. settings = get_view_qsettings_manager()
  7. existing_test_data_path_str = None
  8. if settings.contains("view_test_data_path"):
  9. existing_test_data_path_str = settings.value("view_test_data_path")
  10. existing_test_data_path = pl.Path(existing_test_data_path_str)
  11. if existing_test_data_path.is_dir() and len(list(existing_test_data_path.iterdir())):
  12. ch = ynbox(
  13. title="Test data found!",
  14. msg=f"View has been previously configured to use the folder below for storing test data. "
  15. f"This folder exists and is not empty, hence it most likely contains the correct test data. "
  16. f"What would you like to do?"
  17. f"\n\n{existing_test_data_path_str}",
  18. choices=["Select a new path", "Use the same path as above"],
  19. default_choice="Use the same path as above",
  20. cancel_choice="Use the same path as above"
  21. )
  22. if ch:
  23. existing_test_data_path_str = None
  24. else:
  25. existing_test_data_path_str = None
  26. if existing_test_data_path_str is None:
  27. msgbox(
  28. title="Info",
  29. msg="Please choose a folder in the next dialog for storing VIEW test data. Since it is ~3.3GiB is size, "
  30. "we recommend creating a new folder for it")
  31. file = diropenbox(title="Please choose a folder for storing VIEW test data")
  32. if file is None:
  33. raise IOError("User Abort!")
  34. settings.setValue("view_test_data_path", file)
  35. existing_test_data_path_str = file
  36. # raise NotImplementedError # TODO download view test data to this folder
  37. msgbox(
  38. title="View test data path",
  39. msg=f"View has been configured to use data in the following folder for testing:"
  40. f"\n\n{existing_test_data_path_str}")
  41. if __name__ == '__main__':
  42. main()