summaryrefslogtreecommitdiffstats
path: root/core/config.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-05-05 10:51:56 +0200
committerDanilo M. <danix@danix.xyz>2026-05-05 10:51:56 +0200
commit54ad3e37c6e9d2242f932c192119dd6de64966cf (patch)
tree84c7018152825a63c2f6b009f18634a8585d996a /core/config.py
parent48b84da95d0736124f8be6849aa32df31bdb29aa (diff)
downloadpublisher-54ad3e37c6e9d2242f932c192119dd6de64966cf.tar.gz
publisher-54ad3e37c6e9d2242f932c192119dd6de64966cf.zip
feat: check OLLAMA_HOST reachability before starting translationv1.6
Non-blocking QThread check hits /api/tags on the resolved ollama host before launching TranslationWorker. Shows QMessageBox.warning() if unreachable; proceeds silently if reachable. Adds ollama_host field to Config with env-var fallback to http://localhost:11434. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'core/config.py')
-rw-r--r--core/config.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/config.py b/core/config.py
index 68a8b87..6b8662c 100644
--- a/core/config.py
+++ b/core/config.py
@@ -12,10 +12,15 @@ class Config:
typora_bin: str = "typora"
typora_args: str = ""
font_size: int = 10
+ ollama_host: str = ""
def is_complete(self) -> bool:
return bool(self.blog_repo)
+ def resolved_ollama_host(self) -> str:
+ import os
+ return self.ollama_host or os.environ.get("OLLAMA_HOST", "http://localhost:11434")
+
def save(self, path: Path = DEFAULT_CONFIG_PATH) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
doc = tomlkit.document()
@@ -24,6 +29,7 @@ class Config:
doc.add("typora_bin", self.typora_bin)
doc.add("typora_args", self.typora_args)
doc.add("font_size", self.font_size)
+ doc.add("ollama_host", self.ollama_host)
path.write_text(tomlkit.dumps(doc))
@classmethod
@@ -38,4 +44,5 @@ class Config:
typora_bin=str(data.get("typora_bin", defaults.typora_bin)),
typora_args=str(data.get("typora_args", defaults.typora_args)),
font_size=int(data.get("font_size", defaults.font_size)),
+ ollama_host=str(data.get("ollama_host", defaults.ollama_host)),
)