transformer7.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import plac
  2. import subprocess
  3. import config
  4. import re
  5. cfg = config.Config()
  6. models_dir = cfg.portal_dir + "\\System\\Models"
  7. cube_out = cfg.portal_dir + "\\System\\Cube_out"
  8. cube_temp = cube_out + "\\temp"
  9. @plac.pos("model_file", "", type=str)
  10. def create(model_file):
  11. cube = cube_name(model_file)
  12. cmd = f'"{cfg.cognos_dir}\\runmac32.exe" "{cfg.tools_dir}\\VBS\\create-cube.mac" "{models_dir}","{model_file}","{cube_temp}"'
  13. print(f"Erstelle Cube '{cube}' fuer '{model_file}'...", end="")
  14. p = subprocess.Popen(cmd)
  15. p.wait()
  16. # temp_file = f"{cube_temp}\\{model_file}.mdc"
  17. # cube_file = f"{cube_out}\\{cube}.mdc"
  18. print("erfolgreich.")
  19. def cube_name(model_file):
  20. p = re.compile(r"cube_out\\([^\.]+)\.mdc", re.IGNORECASE)
  21. with open(models_dir + "\\" + model_file, "r", errors="ignore") as f:
  22. for line in f.readlines():
  23. m = p.search(line)
  24. if m:
  25. return p.match(m.group()).groups()[0].lower()
  26. if __name__ == "__main__":
  27. plac.call(create)