blob: 5f47492ef21d2c9d80da42c8637443baafe79cfa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
from __future__ import annotations
import urllib.request
from PyQt6.QtCore import QThread, pyqtSignal
class OllamaCheckWorker(QThread):
reachable = pyqtSignal(bool, str) # (ok, url_tried)
def __init__(self, host_url: str, timeout: int = 4, parent=None):
super().__init__(parent)
self._url = host_url.rstrip("/") + "/api/tags"
self._timeout = timeout
def run(self):
try:
urllib.request.urlopen(self._url, timeout=self._timeout)
self.reachable.emit(True, self._url)
except Exception:
self.reachable.emit(False, self._url)
|