[FIX] selenium : rendre tkinter optionnel, il ne sert qu'au coffre
tkinter ne sert qu'au sélecteur de fichier du coffre, et seulement quand aucun chemin KDBX n'est configuré. Importé en tête, il rendait tout le pilotage de navigateur inimportable sur un Python bâti sans lui — donc sur tout serveur sans paquet d'interface graphique. Sans tkinter ni chemin configuré, get_kdbx journalise et rend None, comme le fait déjà kdbx_manager. Vérifié : web_login.py --help sort en 0, et le chemin dégradé appelé directement rend None. --- EN --- tkinter is only needed by the vault file picker, and only when no KDBX path is configured. Imported at module level, it made the whole browser automation unimportable on a Python built without it — that is, on any server with no graphical toolkit package. With no tkinter and no configured path, get_kdbx logs and returns None, as kdbx_manager already does. Checked: web_login.py --help exits 0, and the degraded path called directly returns None. Assisted-by: Claude Opus 5
This commit is contained in:
parent
aef98311f5
commit
c15d97f646
1 changed files with 18 additions and 2 deletions
|
|
@ -13,9 +13,7 @@ import subprocess
|
|||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import tkinter as tk
|
||||
from pathlib import Path
|
||||
from tkinter import filedialog
|
||||
from typing import Optional
|
||||
|
||||
from pykeepass import PyKeePass
|
||||
|
|
@ -42,6 +40,18 @@ sys.path.append(new_path)
|
|||
|
||||
from script.config import config_file
|
||||
|
||||
# tkinter ne sert QU'au sélecteur de fichier du coffre, quand aucun chemin
|
||||
# n'est configuré. Importé en tête, il rendait le module entier inimportable
|
||||
# sur toute machine dont le Python est bâti sans lui — c'est-à-dire sur tout
|
||||
# serveur sans paquet d'interface graphique — alors que pas une ligne du
|
||||
# pilotage de navigateur n'en dépend.
|
||||
try:
|
||||
import tkinter as tk
|
||||
from tkinter import filedialog
|
||||
except ModuleNotFoundError:
|
||||
tk = None
|
||||
filedialog = None
|
||||
|
||||
logging.basicConfig(
|
||||
format=(
|
||||
"%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d]"
|
||||
|
|
@ -443,6 +453,12 @@ class SeleniumLib(object):
|
|||
["kdbx", "path"]
|
||||
)
|
||||
if not chemin_fichier_kdbx:
|
||||
if tk is None:
|
||||
_logger.error(
|
||||
"tkinter is not available, please fill"
|
||||
f" {config_file.CONFIG_FILE}"
|
||||
)
|
||||
return
|
||||
root = tk.Tk()
|
||||
root.withdraw() # Hide the main window
|
||||
chemin_fichier_kdbx = filedialog.askopenfilename(
|
||||
|
|
|
|||
Loading…
Reference in a new issue