misc2.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. return
  31. for p in ["Cognos#11Cognos#11", "mEn$q3b%P9p1j!A-ku", "Never4getpw#!!##", "Cognos#11"]:
  32. if ldap_password(p, "gc01gapsC$"):
  33. print("Passwort erfolgreich geaendert.")
  34. break
  35. @app.command()
  36. def csv_check(path: str = ""):
  37. if path == "":
  38. path = f"{cfg.system_dir}\\export"
  39. csv_cleanup(path)
  40. @app.command()
  41. def bcp_csv_trim(path: str = ""):
  42. if path == "":
  43. path = f"{cfg.system_dir}\\SQL\\temp"
  44. csv_trim(path)
  45. @app.command()
  46. def combine_csv(path: str = ""):
  47. if path == "":
  48. path = f"{cfg.xml_dir}"
  49. os.makedirs(path + "\\info", exist_ok=True)
  50. os.makedirs(path + "\\backup", exist_ok=True)
  51. convert_folder_to_combined_csv(path)
  52. @app.command()
  53. def datev_details(path: str = ""):
  54. if path == "":
  55. path = cfg.system_dir
  56. print_all_mdb_files(path)