Catch error, if re-login fails
This commit is contained in:
parent
613de928a6
commit
bea6311df5
15
rare/app.py
15
rare/app.py
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue