1
0
Fork 0
mirror of synced 2024-06-23 08:40:45 +12:00

Restart app on logout, set logging to file

This commit is contained in:
Dummerle 2021-04-07 11:50:35 +02:00
parent e89772b5fd
commit 95f075bfe1
2 changed files with 23 additions and 8 deletions

View file

@ -20,7 +20,8 @@ class MiniWidget(QWidget):
self.layout.addWidget(QLabel(self.tr("Logged in as ") + username))
self.open_browser = QPushButton(self.tr("Account settings"))
self.open_browser.clicked.connect(lambda: webbrowser.open("https://www.epicgames.com/account/personal?productName=epicgames"))
self.open_browser.clicked.connect(
lambda: webbrowser.open("https://www.epicgames.com/account/personal?productName=epicgames"))
self.layout.addWidget(self.open_browser)
self.logout_button = QPushButton(self.tr("Logout"))
@ -35,6 +36,5 @@ class MiniWidget(QWidget):
if reply == QMessageBox.Yes:
self.core.lgd.invalidate_userdata()
QCoreApplication.exit()
# restart app
QCoreApplication.instance().exit(-133742) # restart exit code

View file

@ -2,6 +2,7 @@ import configparser
import logging
import os
import sys
import time
from PyQt5.QtCore import QSettings, QTranslator
from PyQt5.QtGui import QIcon
@ -13,10 +14,17 @@ from Rare.Components.MainWindow import MainWindow
from Rare.utils.utils import get_lang
from custom_legendary.core import LegendaryCore
start_time = time.strftime('%y-%m-%d--%H:%M') # year-month-day-hour-minute
file_name = os.path.expanduser(f"~/.cache/rare/logs/Rare_{start_time}.log")
if not os.path.exists(os.path.dirname(file_name)):
os.makedirs(os.path.dirname(file_name))
logging.basicConfig(
format='[%(name)s] %(levelname)s: %(message)s',
level=logging.INFO
)
level=logging.INFO,
filename=file_name,
filemode="w"
)
logger = logging.getLogger("Rare")
@ -40,6 +48,7 @@ class App(QApplication):
self.core.lgd.save_config()
# set Application name for settings
self.mainwindow = None
self.setApplicationName("Rare")
self.setOrganizationName("Rare")
settings = QSettings()
@ -70,5 +79,11 @@ class App(QApplication):
def start():
app = App()
app.exec_()
while True:
app = App()
exit_code = app.exec_()
# if not restart
if exit_code != -133742:
break
# restart app
del app