Files
copydev-imposing-tool/main.py
Jules 785a7d183a Compilation .exe PyInstaller + fix chemins resources
- L'installation compile maintenant un vrai .exe autonome
- Les raccourcis Bureau/Menu Demarrer pointent vers le .exe
- Support PyInstaller pour les chemins resources (logo, icone)
- La mise a jour recompile aussi le .exe
- Fallback lanceur .vbs si compilation echoue

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 11:24:12 +01:00

69 lines
1.9 KiB
Python

#!/usr/bin/env python3
"""Copydev Imposing Tool — Point d'entree."""
import sys
import os
import hashlib
# Support PyInstaller (chemin des resources)
if getattr(sys, 'frozen', False):
BASE_DIR = os.path.dirname(sys.executable)
BUNDLE_DIR = sys._MEIPASS
else:
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
BUNDLE_DIR = BASE_DIR
sys.path.insert(0, BUNDLE_DIR)
from PyQt6.QtWidgets import QApplication, QInputDialog, QMessageBox, QLineEdit
# Hash SHA-256 du mot de passe — jamais en clair dans le code
_PASSWORD_HASH = "f3dd6962a99a2fe2e03cd8e5cfa7dafb12570bdcca1b6590e27d95dcccdf1f58"
def _hash_password(pwd):
return hashlib.sha256(pwd.encode("utf-8")).hexdigest()
def _check_auth():
"""Demander le mot de passe au lancement."""
max_attempts = 3
for attempt in range(max_attempts):
pwd, ok = QInputDialog.getText(
None,
"Copydev Imposing Tool",
f"Mot de passe requis ({max_attempts - attempt} essai(s) restant(s)) :",
QLineEdit.EchoMode.Password,
)
if not ok:
return False
if _hash_password(pwd) == _PASSWORD_HASH:
return True
if attempt < max_attempts - 1:
QMessageBox.warning(None, "Erreur", "Mot de passe incorrect.")
QMessageBox.critical(None, "Acces refuse", "Trop de tentatives. L'application va se fermer.")
return False
def main():
app = QApplication(sys.argv)
app.setApplicationName("Copydev Imposing Tool")
app.setOrganizationName("Copydev")
# Icone application
from PyQt6.QtGui import QIcon
icon_path = os.path.join(BUNDLE_DIR, "resources", "logo.png")
if os.path.exists(icon_path):
app.setWindowIcon(QIcon(icon_path))
if not _check_auth():
sys.exit(1)
from app.main_window import MainWindow
window = MainWindow()
window.show()
sys.exit(app.exec())
if __name__ == "__main__":
main()