init_var.py 917 B

12345678910111213141516171819202122232425262728293031
  1. import os
  2. import sys
  3. import appdirs
  4. from dotenv import load_dotenv
  5. from window.DialogCustomVariables import DialogCustomVariables
  6. DEFAULT_PATH = os.path.join(appdirs.user_data_dir(), "propusk")
  7. DEFAULT_PATH_PHOTO = os.path.join(DEFAULT_PATH, "photo")
  8. no_media = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'image', 'no_media_main.jpg')
  9. os.environ.update({
  10. 'VERSION': "ver 0.5 beta",
  11. 'ABSOLUTE_PATH': os.path.dirname(os.path.abspath(__file__)),
  12. 'NO_MEDIA_IMAGE': no_media,
  13. 'INDEX_PHOTO': '0',
  14. 'INDEX_CAMERA': '1',
  15. 'DEFAULT_PATH': DEFAULT_PATH
  16. })
  17. def load_variables():
  18. # Load variable from .env
  19. dotenv_path = os.path.join(appdirs.user_config_dir(), 'propusk.env')
  20. if not os.path.exists(dotenv_path):
  21. DialogCustomVariables(dotenv_path).exec_()
  22. if not os.path.exists(dotenv_path):
  23. sys.exit()
  24. load_dotenv(dotenv_path=dotenv_path)