Skip to content
Snippets Groups Projects
Commit 8393735d authored by Florian Bruhin's avatar Florian Bruhin
Browse files

git fetcher: Try adding connectivity tracking

parent 14ce7e5d
Branches
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ import logging
from PyQt6.QtCore import pyqtSlot, pyqtSignal, QObject, QTimer, QProcess, Qt
from PyQt6.QtGui import QFont
from PyQt6.QtWidgets import QTableWidget, QTableWidgetItem, QWidget
from PyQt6.QtNetwork import QNetworkInformation
from commander.gui import utils
......@@ -68,8 +69,25 @@ class GitFetcher(QObject):
self.timer.setInterval(self.INTERVAL)
self.timer.timeout.connect(self.on_timeout)
loaded = QNetworkInformation.load(QNetworkInformation.Feature.Reachability)
if loaded:
QNetworkInformation.instance().reachabilityChanged.connect(
self._on_reachability_changed)
self._had_updates = False
def _on_reachability_changed(self, reachability: QNetworkInformation.Reachability) -> None:
is_online = reachability == QNetworkInformation.Reachability.Online
msg = f"Network reachability changed ({reachability})"
if is_online and not self.timer.isActive():
logging.info(f"{msg}, resuming git fetcher")
self.status_message.emit(None)
self.timer.start()
elif not is_online:
logging.info(f"{msg}, pausing git fetcher")
self.status_message.emit("Paused (not online)")
self.timer.stop()
def start(self):
self.on_timeout()
self.timer.start()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment