04/24 Migrated info which stored in .ini to database and keyring

This commit is contained in:
2026-04-24 15:37:58 -04:00
parent f2a8d3f15b
commit 5d6ca5a039
9 changed files with 479 additions and 299 deletions
+9 -21
View File
@@ -167,35 +167,23 @@ class AiSummaryView(ttk.Frame):
def _load_config(self):
try:
import configparser
from config import CONFIG_FILE
from config import get_setting
from utils.config_crypto import decrypt_value
cfg = configparser.ConfigParser()
cfg.read(CONFIG_FILE, encoding="utf-8")
if cfg.has_section(_CFG_SECTION):
raw_key = cfg.get(_CFG_SECTION, _CFG_KEY_KEY, fallback="")
raw_key = get_setting("groq.api_key", "")
if raw_key:
self._api_key_var.set(decrypt_value(raw_key))
model = cfg.get(_CFG_SECTION, _CFG_KEY_MODEL,
fallback=GROQ_MODELS[0])
if model in GROQ_MODELS:
self._model_var.set(model)
model = get_setting("groq.model", GROQ_MODELS[0])
if model in GROQ_MODELS:
self._model_var.set(model)
except Exception as e:
logger.warning(f"Could not load Groq config: {e}")
def _save_config(self):
try:
import configparser
from config import CONFIG_FILE
from config import set_setting
from utils.config_crypto import encrypt_value
cfg = configparser.ConfigParser()
cfg.read(CONFIG_FILE, encoding="utf-8")
if not cfg.has_section(_CFG_SECTION):
cfg.add_section(_CFG_SECTION)
cfg.set(_CFG_SECTION, _CFG_KEY_KEY,
encrypt_value(self._api_key_var.get().strip()))
cfg.set(_CFG_SECTION, _CFG_KEY_MODEL, self._model_var.get())
with open(CONFIG_FILE, "w", encoding="utf-8") as fh:
cfg.write(fh)
set_setting("groq.api_key", encrypt_value(self._api_key_var.get().strip()))
set_setting("groq.model", self._model_var.get())
except Exception as e:
logger.warning(f"Could not save Groq config: {e}")