1
0
Fork 0
mirror of synced 2024-06-02 18:54:41 +12:00

Catch error, if re-login fails

This commit is contained in:
Dummerle 2022-04-13 01:07:48 +02:00
parent 613de928a6
commit bea6311df5
No known key found for this signature in database
GPG key ID: AB68CC59CA39F2F1

View file

@ -9,6 +9,7 @@ import traceback
from argparse import Namespace
from datetime import datetime
import requests.exceptions
from PyQt5.QtCore import Qt, QThreadPool, QSettings, QTranslator, QTimer
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, QSystemTrayIcon, QMessageBox
@ -165,13 +166,19 @@ class App(QApplication):
td = abs(dt_exp - dt_now)
self.timer = QTimer()
self.timer.timeout.connect(self.re_login)
self.timer.start(int(td.total_seconds() - 60))
self.timer.start(int(td.total_seconds() - 60) * 1000)
def re_login(self):
logger.info("Session expires shortly. Renew session")
self.core.login()
self.timer.stop()
self.timer.deleteLater()
try:
self.core.login()
except requests.exceptions.ConnectionError:
self.timer.start(3000) # try again if no connection
return
dt_exp = datetime.fromisoformat(self.core.lgd.userdata['expires_at'][:-1])
dt_now = datetime.utcnow()
td = abs(dt_exp - dt_now)
self.timer.start(int(td.total_seconds() - 60) * 1000)
def show_mainwindow(self):
if self.window_launched: