Fix origin stuff on windows
Signed-off-by: loathingKernel <142770+loathingKernel@users.noreply.github.com>
This commit is contained in:
parent
efc07e4645
commit
d399382afd
|
@ -1,4 +1,3 @@
|
|||
import platform
|
||||
from logging import getLogger
|
||||
|
||||
from PyQt5.QtCore import QSettings, Qt, pyqtSlot, QThreadPool
|
||||
|
@ -156,9 +155,8 @@ class GamesTab(QStackedWidget):
|
|||
self.filter_games(self.active_filter)
|
||||
self.update_count_games_label()
|
||||
|
||||
if platform.system() != "Windows":
|
||||
worker = OriginWineWorker(self.core, self.rcore.origin_games)
|
||||
QThreadPool.globalInstance().start(worker)
|
||||
worker = OriginWineWorker(self.core, self.rcore.origin_games)
|
||||
QThreadPool.globalInstance().start(worker)
|
||||
|
||||
def add_library_widget(self, rgame: RareGame):
|
||||
try:
|
||||
|
|
|
@ -245,10 +245,10 @@ class GameInfo(QWidget, SideTabContents):
|
|||
self.rgame.version if not self.rgame.is_non_asset else "N/A"
|
||||
)
|
||||
|
||||
self.ui.lbl_install_size.setEnabled(self.rgame.is_installed and not self.rgame.is_non_asset)
|
||||
self.ui.install_size.setEnabled(self.rgame.is_installed and not self.rgame.is_non_asset)
|
||||
self.ui.lbl_install_size.setEnabled(bool(self.rgame.install_size))
|
||||
self.ui.install_size.setEnabled(bool(self.rgame.install_size))
|
||||
self.ui.install_size.setText(
|
||||
format_size(self.rgame.igame.install_size) if self.rgame.is_installed and not self.rgame.is_non_asset else "N/A"
|
||||
format_size(self.rgame.igame.install_size) if self.rgame.install_size else "N/A"
|
||||
)
|
||||
|
||||
self.ui.lbl_install_path.setEnabled(bool(self.rgame.install_path))
|
||||
|
|
|
@ -9,7 +9,7 @@ from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLab
|
|||
|
||||
from rare.models.game import RareGame
|
||||
from rare.shared import RareCore
|
||||
from rare.utils.misc import format_size
|
||||
from rare.utils.misc import path_size, format_size
|
||||
from rare.widgets.elide_label import ElideLabel
|
||||
from rare.widgets.indicator_edit import PathEdit, IndicatorReasons, IndicatorReasonsCommon
|
||||
|
||||
|
@ -103,15 +103,9 @@ class MoveGamePopUp(QWidget):
|
|||
|
||||
# Get free space on drive and size of game folder
|
||||
_, _, free_space = shutil.disk_usage(dst_path)
|
||||
source_size = sum(
|
||||
os.stat(os.path.join(dp, f)).st_size
|
||||
for dp, dn, filenames in os.walk(src_path)
|
||||
for f in filenames
|
||||
)
|
||||
source_size = path_size(src_path)
|
||||
|
||||
# Calculate from bytes to gigabytes
|
||||
# free_space = round(free_space / 1000 ** 3, 2)
|
||||
# source_size = round(source_size / 1000 ** 3, 2)
|
||||
self.req_space.setText(format_size(source_size))
|
||||
self.avail_space.setText(format_size(free_space))
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ from PyQt5.QtCore import pyqtSignal, QObject, QRunnable
|
|||
from rare.lgndr.core import LegendaryCore
|
||||
from rare.models.game import RareGame
|
||||
from rare.models.pathspec import PathSpec
|
||||
from rare.utils.misc import read_registry
|
||||
from rare.utils.misc import read_registry, path_size, format_size
|
||||
from .worker import Worker
|
||||
|
||||
if platform.system() == "Windows":
|
||||
|
@ -115,12 +115,15 @@ class OriginWineWorker(QRunnable):
|
|||
self.__cache[wine_prefix] = reg
|
||||
|
||||
# TODO: find a better solution
|
||||
reg_path = reg_path.replace("\\", "\\\\")\
|
||||
reg_path = reg_path.replace("\\", "\\\\") \
|
||||
.replace("SOFTWARE", "Software").replace("WOW6432Node", "Wow6432Node")
|
||||
|
||||
install_dir = reg.get(reg_path, '"Install Dir"', fallback=None)
|
||||
if install_dir:
|
||||
size = sum(os.path.getsize(f) for f in os.listdir(install_dir) if os.path.isfile(f))
|
||||
logger.debug(f"Found install path for {rgame.title}: {install_dir}")
|
||||
rgame.set_origin_attributes(install_dir, size)
|
||||
if os.path.exists(install_dir):
|
||||
size = path_size(install_dir)
|
||||
rgame.set_origin_attributes(install_dir, size)
|
||||
logger.debug(f"Found Origin game {rgame.title} ({install_dir}, {format_size(size)})")
|
||||
else:
|
||||
logger.warning(f"Found Origin game {rgame.title} ({install_dir} does not exist)")
|
||||
logger.info(f"Origin registry worker finished in {time.time() - t}s")
|
||||
|
|
|
@ -150,7 +150,7 @@ def get_translations():
|
|||
def get_latest_version():
|
||||
try:
|
||||
resp = requests.get(
|
||||
"https://api.github.com/repos/Dummerle/Rare/releases/latest"
|
||||
"https://api.github.com/repos/Dummerle/Rare/releases/latest", timeout=2,
|
||||
)
|
||||
tag = resp.json()["tag_name"]
|
||||
return tag
|
||||
|
@ -158,6 +158,14 @@ def get_latest_version():
|
|||
return "0.0.0"
|
||||
|
||||
|
||||
def path_size(path: Union[str, os.PathLike]) -> int:
|
||||
return sum(
|
||||
os.stat(os.path.join(dp, f)).st_size
|
||||
for dp, dn, filenames in os.walk(path)
|
||||
for f in filenames
|
||||
)
|
||||
|
||||
|
||||
def format_size(b: Union[int, float]) -> str:
|
||||
for s in ["", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei"]:
|
||||
if b < 1024:
|
||||
|
|
Loading…
Reference in a new issue