1
0
Fork 0
mirror of synced 2024-06-02 02:34:40 +12:00

added MANIFEST.in,

some small fixes
This commit is contained in:
Dummerle 2021-01-12 15:36:14 +01:00
parent f73e85e078
commit 752e0859ed
5 changed files with 59 additions and 30 deletions

2
MANIFEST.in Normal file
View file

@ -0,0 +1,2 @@
include Rare/Styles/dark.qss
include README.md

View file

@ -1,8 +1,7 @@
import logging
import os
import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import QApplication, QMessageBox
from legendary.core import LegendaryCore
from Rare import style_path
@ -38,6 +37,9 @@ def main():
login_window = LoginWindow(core)
if not login_window.login():
return
except ConnectionError:
QMessageBox.warning(app, "No Internet", "Connection Error, Failed to login. The offine mode is not implemented")
# Start Offline mode
launch_dialog = LaunchDialog(core)
if RareConfig.THEME == "dark":
launch_dialog.setStyleSheet(open(style_path).read())

View file

@ -37,7 +37,7 @@ class RareSettingsForm(QGroupBox):
logger.info("Update Rare settings")
config = {"Rare": {}}
if self.style_combo_box.currentIndex() == 1:
self.parent().parent().parent().setStyleSheet(open(os.path.join(style_path, "Styles/dark.qss")).read())
self.parent().parent().parent().parent().parent().setStyleSheet(open(style_path).read())
config["Rare"]["theme"] = "default"
else:
self.parent().parent().parent().setStyleSheet("")

View file

@ -1,33 +1,49 @@
import time
from logging import getLogger
from PyQt5.QtCore import QThread, QProcess
from PyQt5.QtWidgets import QVBoxLayout, QProgressBar, QPushButton, QLabel, QWidget, QHBoxLayout
from PyQt5.QtCore import QThread, QProcess, pyqtSignal
from PyQt5.QtWidgets import QVBoxLayout, QMessageBox, QProgressBar, QPushButton, QLabel, QWidget, QHBoxLayout
from legendary.core import LegendaryCore
from legendary.models.game import InstalledGame
from multiprocessing import Queue as MPQueue
logger = getLogger("Updates")
class UpdateThread(QThread):
def __init__(self, dlm):
finish = pyqtSignal(str)
def __init__(self, dlm, core: LegendaryCore, igame):
super(UpdateThread, self).__init__()
self.dlm = dlm
logging_queue = MPQueue(-1)
self.dlm.logging_queue = logging_queue
self.core = core
self.igame = igame
def run(self):
self.dlm.start()
self.dlm.join()
try:
start_time = time.time()
self.dlm.start()
self.dlm.join()
except:
self.finish.emit("Fail")
else:
end_time = time.time()
self.core.install_game(self.igame)
class UpdateProc(QProcess):
def __init__(self):
super(UpdateProc, self).__init__()
old_igame = self.core.get_installed_game(self.igame.app_name)
print(old_igame.__dict__)
"""
if old_igame and old_igame.install_tags != self.igame.install_tags:
old_igame.install_tags = self.igame.install_tags
logger.info('Deleting now untagged files.')
self.core.uninstall_tag(old_igame)
self.core.install_game(old_igame)
"""
self.finish.emit(str(start_time - end_time))
class UpdateWidget(QWidget):
installed = pyqtSignal()
def __init__(self, game: InstalledGame, core: LegendaryCore):
super(UpdateWidget, self).__init__()
@ -38,7 +54,7 @@ class UpdateWidget(QWidget):
self.childlayout = QHBoxLayout()
self.label = QLabel("Update available for " + self.game.title)
self.button = QPushButton("Update")
self.button.clicked.connect(self.update_game)
self.button.clicked.connect(self.update_game2)
self.childlayout.addWidget(self.label)
self.childlayout.addWidget(self.button)
@ -54,23 +70,24 @@ class UpdateWidget(QWidget):
logger.info("Update " + self.game.title)
game = self.core.get_game(self.game.app_name)
logger.info("Prepare Download")
dlm, analysis, manifest = self.core.prepare_download(game=game, base_game=game)
dlm, analysis, igame = self.core.prepare_download(game=game, base_game=game)
if not analysis.dl_size:
logger.info("Game is up to date, sorry")
logger.info(f"Install size: {round(analysis.install_size / (1024 ** 3),2)} GB")
logger.info(f"Download size: {round(analysis.dl_size/(1024**3), 2)} GB")
logger.info(f"Install size: {round(analysis.install_size / (1024 ** 3), 2)} GB")
logger.info(f"Download size: {round(analysis.dl_size / (1024 ** 3), 2)} GB")
installed_game = self.core.get_installed_game(self.game.app_name)
res = self.core.check_installation_conditions(analysis, installed_game, self.core.get_game(self.game.app_name), True)
res = self.core.check_installation_conditions(analysis, installed_game,
self.core.get_game(self.game.app_name), True)
if res.failures:
logger.error("Fail")
if res.warnings:
for warn in sorted(res.warnings):
logger.warning(warn)
start_time = time.time()
self.update_thread = UpdateThread(dlm)
self.update_thread.finished.connect(self.finished)
self.update_thread = UpdateThread(dlm, core=self.core, igame=igame)
self.update_thread.finish.connect(self.finished)
self.update_thread.start()
self.button.setDisabled(True)
# TODO Wird 1000% nicht funktionieren
@ -85,8 +102,13 @@ class UpdateWidget(QWidget):
self.proc = QProcess()
self.proc.start("legendary", ["-y", "update", self.game.app_name])
def finished(self):
def finished(self, text: str):
if text == "Fail":
QMessageBox.warning(self, "Update Failed", "Update failed")
else:
QMessageBox.information(self, "Update finished", f"Update finished in {time} ")
self.setVisible(False)
self.installed.emit()
def start(self):
self.button.setText("Cancel")
@ -95,6 +117,7 @@ class UpdateWidget(QWidget):
def get_update_info(self):
shit, infos, game = self.core.prepare_download(self.core.get_game(self.game.app_name),
self.core.get_game(self.game.app_name))
logger.info(f"Download size: {infos.dl_size}")
def dataReady(self):
bytes = self.thread.readAllStandardOutput()
@ -116,10 +139,11 @@ class UpdateTab(QWidget):
self.layout = QVBoxLayout()
update_games = self.get_updates()
if update_games:
for game in self.get_updates():
self.layout.addWidget(UpdateWidget(game, core))
else:
for game in update_games:
widget = UpdateWidget(game, core)
widget.installed.connect(lambda: self.__init__(self.core))
self.layout.addWidget(widget)
if len(update_games) == 0:
self.layout.addWidget(QLabel("No updates available"))
self.layout.addStretch(1)
self.setLayout(self.layout)
@ -127,8 +151,8 @@ class UpdateTab(QWidget):
def get_updates(self):
self.core.get_assets(True)
update_games = []
games=sorted(self.core.get_installed_list(), key=lambda x: x.title)
versions={}
games = sorted(self.core.get_installed_list(), key=lambda x: x.title)
versions = {}
for game in games:
try:
versions[game.app_name] = self.core.get_asset(game.app_name).build_version

View file

@ -13,6 +13,7 @@ setuptools.setup(
license="GPL-3",
long_description=long_description,
long_description_content_type="text/markdown",
include_package_data=True,
url="https://github.com/Dummerle/Rare",
packages=setuptools.find_packages(),
classifiers=[