system_utils.py 785 B

12345678910111213141516171819202122232425262728
  1. #
  2. # Copyright (C) 2023, Inria
  3. # GRAPHDECO research group, https://team.inria.fr/graphdeco
  4. # All rights reserved.
  5. #
  6. # This software is free for non-commercial, research and evaluation use
  7. # under the terms of the LICENSE.md file.
  8. #
  9. # For inquiries contact george.drettakis@inria.fr
  10. #
  11. from errno import EEXIST
  12. from os import makedirs, path
  13. import os
  14. def mkdir_p(folder_path):
  15. # Creates a directory. equivalent to using mkdir -p on the command line
  16. try:
  17. makedirs(folder_path)
  18. except OSError as exc: # Python >2.5
  19. if exc.errno == EEXIST and path.isdir(folder_path):
  20. pass
  21. else:
  22. raise
  23. def searchForMaxIteration(folder):
  24. saved_iters = [int(fname.split("_")[-1]) for fname in os.listdir(folder)]
  25. return max(saved_iters)