IOTA2Directory.py 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/usr/bin/python
  2. #-*- coding: utf-8 -*-
  3. # =========================================================================
  4. # Program: iota2
  5. #
  6. # Copyright (c) CESBIO. All rights reserved.
  7. #
  8. # See LICENSE for details.
  9. #
  10. # This software is distributed WITHOUT ANY WARRANTY; without even
  11. # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  12. # PURPOSE. See the above copyright notices for more information.
  13. #
  14. # =========================================================================
  15. import os
  16. import shutil
  17. from Common import ServiceConfigFile as SCF
  18. def GenerateDirectories(cfg):
  19. """
  20. generate IOTA2 output directories
  21. """
  22. if not isinstance(cfg, SCF.serviceConfigFile):
  23. cfg = SCF.serviceConfigFile(cfg)
  24. root = cfg.getParam('chain', 'outputPath')
  25. rm_PathTEST = cfg.getParam("chain", "remove_outputPath")
  26. start_step = cfg.getParam("chain", "firstStep")
  27. if os.path.exists(root) and root != "/" and rm_PathTEST and start_step == "init":
  28. shutil.rmtree(root,ignore_errors=False)
  29. os.mkdir(root)
  30. if os.path.exists(root+"/logs"):
  31. shutil.rmtree(root+"/logs")
  32. os.mkdir(root+"/logs")
  33. if os.path.exists(root+"/samplesSelection"):
  34. shutil.rmtree(root+"/samplesSelection")
  35. os.mkdir(root+"/samplesSelection")
  36. if os.path.exists(root+"/model"):
  37. shutil.rmtree(root+"/model")
  38. os.mkdir(root+"/model")
  39. if os.path.exists(root+"/formattingVectors"):
  40. shutil.rmtree(root+"/formattingVectors")
  41. os.mkdir(root+"/formattingVectors")
  42. if os.path.exists(root+"/config_model"):
  43. shutil.rmtree(root+"/config_model")
  44. os.mkdir(root+"/config_model")
  45. if os.path.exists(root+"/envelope"):
  46. shutil.rmtree(root+"/envelope")
  47. os.mkdir(root+"/envelope")
  48. if os.path.exists(root+"/classif"):
  49. shutil.rmtree(root+"/classif")
  50. os.mkdir(root+"/classif")
  51. if os.path.exists(root+"/shapeRegion"):
  52. shutil.rmtree(root+"/shapeRegion")
  53. os.mkdir(root+"/shapeRegion")
  54. if os.path.exists(root+"/final"):
  55. shutil.rmtree(root+"/final")
  56. os.mkdir(root+"/final")
  57. os.mkdir(root+"/final/simplification")
  58. os.mkdir(root+"/final/simplification/tiles")
  59. os.mkdir(root+"/final/simplification/vectors")
  60. os.mkdir(root+"/final/simplification/tmp")
  61. if os.path.exists(root+"/features"):
  62. shutil.rmtree(root+"/features")
  63. os.mkdir(root+"/features")
  64. if os.path.exists(root+"/dataRegion"):
  65. shutil.rmtree(root+"/dataRegion")
  66. os.mkdir(root+"/dataRegion")
  67. if os.path.exists(root+"/learningSamples"):
  68. shutil.rmtree(root+"/learningSamples")
  69. os.mkdir(root+"/learningSamples")
  70. if os.path.exists(root+"/dataAppVal"):
  71. shutil.rmtree(root+"/dataAppVal")
  72. os.mkdir(root+"/dataAppVal")
  73. if os.path.exists(root+"/stats"):
  74. shutil.rmtree(root+"/stats")
  75. os.mkdir(root+"/stats")
  76. if os.path.exists(root+"/cmd"):
  77. shutil.rmtree(root+"/cmd")
  78. os.mkdir(root+"/cmd")
  79. os.mkdir(root+"/cmd/stats")
  80. os.mkdir(root+"/cmd/train")
  81. os.mkdir(root+"/cmd/cla")
  82. os.mkdir(root+"/cmd/confusion")
  83. os.mkdir(root+"/cmd/features")
  84. os.mkdir(root+"/cmd/fusion")
  85. os.mkdir(root+"/cmd/splitShape")
  86. merge_final_classifications = cfg.getParam('chain', 'merge_final_classifications')
  87. if merge_final_classifications:
  88. if os.path.exists(root+"/final/merge_final_classifications"):
  89. shutil.rmtree(root+"/final/merge_final_classifications")