Quellcode durchsuchen

fix bug create pdf

Alex Sidorov vor 1 Jahr
Ursprung
Commit
7a7b9fc586
1 geänderte Dateien mit 11 neuen und 21 gelöschten Zeilen
  1. 11 21
      module/__init__.py

+ 11 - 21
module/__init__.py

@@ -1,28 +1,18 @@
 from datetime import datetime
 import os
-import platform
-import subprocess
-from module.MyMessageBox import show_dialog
-from PySide6.QtWidgets import QMessageBox
+# from PySide6.QtWidgets import QMessageBox
 
 
 
 def create_filename(prefix: str = "propusk") -> str:
-    return os.path.join(os.environ.get('PHOTO_DIR'), F"{prefix}_{datetime.now().timestamp()}.jpg")
-
-def get_path_wkhtmltopdf() -> str:
-    match platform.system():
-        case 'Linux':
-            result = subprocess.Popen(['whereis wkhtmltopdf'], shell=True, stdout=subprocess.PIPE).stdout.read()
-            return str(result).split(' ')[1]
-        case 'Windows':
-            path_window_programm = "C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe"
-            if os.path.exists(path_window_programm):
-                return path_window_programm
-            else:
-                show_dialog(QMessageBox.Icon.Critical, 
-                            "Не найдено ПО",
-                            "Не установлена программа wkhtmltopdf")
-        case _: ...
-    
+    file_name = os.path.join(os.environ.get('PHOTO_DIR'), F"{prefix}_{datetime.now().timestamp()}")
     
+    match prefix:
+        case 'pdf':
+            file_name = F"{file_name}.pdf"
+        case _ :
+            file_name = F"{file_name}.jpg"
+        
+    return file_name
+
+