__init__.py 1021 B

12345678910111213141516171819202122232425262728
  1. from datetime import datetime
  2. import os
  3. import platform
  4. import subprocess
  5. from module.MyMessageBox import show_dialog
  6. from PySide6.QtWidgets import QMessageBox
  7. def create_filename(prefix: str = "propusk") -> str:
  8. return os.path.join(os.environ.get('PHOTO_DIR'), F"{prefix}_{datetime.now().timestamp()}.jpg")
  9. def get_path_wkhtmltopdf() -> str:
  10. match platform.system():
  11. case 'Linux':
  12. result = subprocess.Popen(['whereis wkhtmltopdf'], shell=True, stdout=subprocess.PIPE).stdout.read()
  13. return str(result).split(' ')[1]
  14. case 'Windows':
  15. path_window_programm = "C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe"
  16. if os.path.exists(path_window_programm):
  17. return path_window_programm
  18. else:
  19. show_dialog(QMessageBox.Icon.Critical,
  20. "Не найдено ПО",
  21. "Не установлена программа wkhtmltopdf")
  22. case _: ...