1
0
Fork 0
mirror of synced 2024-06-02 10:44:40 +12:00
Rare/Rare/Main.py
2021-02-10 11:48:25 +01:00

72 lines
1.8 KiB
Python

import logging
import os
import sys
import requests
from PyQt5.QtCore import QTranslator
from PyQt5.QtWidgets import QApplication, QMessageBox
from legendary.core import LegendaryCore
from Rare import style_path, lang_path
from Rare.Components.MainWindow import MainWindow
# from Rare.Start.Launch import LaunchDialog
# from Rare.Start.Login import LoginWindow
# from Rare.utils.RareUtils import get_lang
logging.basicConfig(
format='[%(name)s] %(levelname)s: %(message)s',
level=logging.INFO
)
logger = logging.getLogger("Rare")
core = LegendaryCore()
def main():
app = QApplication(sys.argv)
translator = QTranslator()
# lang = get_lang()
lang = "de"
if os.path.exists(lang_path + lang + ".qm"):
translator.load(lang_path + lang + ".qm")
else:
logger.info("Your language is not supported")
app.installTranslator(translator)
app.setStyleSheet(open(style_path + "RareStyle.qss").read())
offline = True
logger.info("Try if you are logged in")
try:
if core.login():
logger.info("You are logged in")
offline = False
else:
logger.error("Login Failed")
main()
except ValueError:
logger.info("You are not logged in. Open Login Window")
login_window = LoginWindow(core)
if not login_window.login():
return
# Start Offline mode
except requests.exceptions.ConnectionError:
offline = True
QMessageBox.information(None, "Offline", "You are offline. Launching Rare in offline mode")
# Launch Offlienmode
if not offline:
# launch_dialog = LaunchDialog(core)
# launch_dialog.exec_()
pass
# mainwindow = MainWindow(core)
mainwindow = MainWindow(core)
app.exec_()
if __name__ == '__main__':
main()