misc2.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import os
  2. import typer
  3. import config
  4. from misc import apache_ldap
  5. from misc.convert_mail_csv import convert_folder_to_combined_csv
  6. from misc.csv_cleanup import csv_cleanup
  7. from misc.csv_trim import csv_trim
  8. from misc.datev_status import print_all_mdb_files
  9. from misc.headers import create_headerfiles
  10. app = typer.Typer()
  11. cfg = config.Config()
  12. @app.command()
  13. def headers():
  14. create_headerfiles(f"{cfg.system_dir}\\Export")
  15. @app.command()
  16. def ldap_backup():
  17. cred = cfg.cognos11.credentials
  18. apache_ldap.ldap_backup(cred.username, cred.password, f"{cfg.cognos11.config_dir}\\apacheds_backup.ldif")
  19. @app.command()
  20. def ldap_restore(backup_file: str):
  21. cred = cfg.cognos11.credentials
  22. apache_ldap.restore_ldap(cred.username, cred.password, backup_file)
  23. @app.command()
  24. def ldap_password(old_password: str, new_password: str) -> bool:
  25. return apache_ldap.ldap_change_admin_password(old_password, new_password)
  26. @app.command()
  27. def ldap_admin():
  28. if ldap_password("gc01gapsC$", ""):
  29. print("Passwort ist bereits aktuell.")
  30. for p in ["Cognos#11Cognos#11", "mEn$q3b%P9p1j!A-ku", "Never4getpw#!!##"]:
  31. if ldap_password(p, "gc01gapsC$"):
  32. break
  33. @app.command()
  34. def csv_check(path: str = ""):
  35. if path == "":
  36. path = f"{cfg.system_dir}\\export"
  37. csv_cleanup(path)
  38. @app.command()
  39. def bcp_csv_trim(path: str = ""):
  40. if path == "":
  41. path = f"{cfg.system_dir}\\SQL\\temp"
  42. csv_trim(path)
  43. @app.command()
  44. def combine_csv(path: str = ""):
  45. if path == "":
  46. path = f"{cfg.xml_dir}"
  47. os.makedirs(path + "\\info", exist_ok=True)
  48. os.makedirs(path + "\\backup", exist_ok=True)
  49. convert_folder_to_combined_csv(path)
  50. @app.command()
  51. def datev_details(path: str = ""):
  52. if path == "":
  53. path = cfg.system_dir
  54. print_all_mdb_files(path)