From 384007b5cf66971672c20c6d7dc74d1e6b3c8697 Mon Sep 17 00:00:00 2001 From: loathingKernel <142770+loathingKernel@users.noreply.github.com> Date: Mon, 23 Dec 2024 18:54:15 +0200 Subject: [PATCH 1/4] chore: restore compatibility with python 3.9 --- rare/components/__init__.py | 4 +-- .../components/tabs/store/api/models/query.py | 4 +-- rare/components/tabs/store/landing.py | 4 +-- rare/models/game.py | 26 +++++++++---------- rare/models/pathspec.py | 4 +-- rare/models/steam.py | 6 ++--- rare/utils/compat/steam.py | 6 ++--- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/rare/components/__init__.py b/rare/components/__init__.py index 334396824..6f05878e2 100644 --- a/rare/components/__init__.py +++ b/rare/components/__init__.py @@ -1,7 +1,7 @@ import os import shutil from argparse import Namespace -from datetime import datetime, timezone, UTC +from datetime import datetime, timezone from typing import Optional import requests.exceptions @@ -60,7 +60,7 @@ def __init__(self, args: Namespace): def poke_timer(self): dt_exp = datetime.fromisoformat(self.core.lgd.userdata['expires_at'][:-1]).replace(tzinfo=timezone.utc) - dt_now = datetime.now(UTC) + dt_now = datetime.now(timezone.utc) td = abs(dt_exp - dt_now) self.relogin_timer.start(int(td.total_seconds() - 60) * 1000) self.logger.info(f"Renewed session expires at {self.core.lgd.userdata['expires_at']}") diff --git a/rare/components/tabs/store/api/models/query.py b/rare/components/tabs/store/api/models/query.py index 594de18c2..43c74128a 100644 --- a/rare/components/tabs/store/api/models/query.py +++ b/rare/components/tabs/store/api/models/query.py @@ -1,12 +1,12 @@ from dataclasses import dataclass, field -from datetime import datetime, timezone, UTC +from datetime import datetime, timezone from typing import List @dataclass class SearchDateRange: start_date: datetime = datetime(year=1990, month=1, day=1, tzinfo=timezone.utc) - end_date: datetime = datetime.now(UTC) + end_date: datetime = datetime.now(timezone.utc) def __str__(self): def fmt_date(date: datetime) -> str: diff --git a/rare/components/tabs/store/landing.py b/rare/components/tabs/store/landing.py index bee3da064..3c33ff320 100644 --- a/rare/components/tabs/store/landing.py +++ b/rare/components/tabs/store/landing.py @@ -1,5 +1,5 @@ import logging -from datetime import datetime, UTC +from datetime import datetime, timezone from typing import List from PySide6.QtCore import Qt, Slot, Signal, QObject, QEvent @@ -184,7 +184,7 @@ def __update_free_games(self, free_games: List[CatalogOfferModel]): self.free_games_next.layout().removeWidget(w) w.deleteLater() - date = datetime.now(UTC) + date = datetime.now(timezone.utc) free_now = [] free_next = [] for item in free_games: diff --git a/rare/models/game.py b/rare/models/game.py index a2c35d9f4..756bbb238 100644 --- a/rare/models/game.py +++ b/rare/models/game.py @@ -2,7 +2,7 @@ import os import platform from dataclasses import dataclass, field -from datetime import datetime, UTC +from datetime import datetime, timezone from logging import getLogger from threading import Lock from typing import List, Optional, Dict, Set @@ -30,11 +30,11 @@ class RareGame(RareGameSlim): class Metadata: queued: bool = False queue_pos: Optional[int] = None - last_played: datetime = datetime.min.replace(tzinfo=UTC) - grant_date: datetime = datetime.min.replace(tzinfo=UTC) + last_played: datetime = datetime.min.replace(tzinfo=timezone.utc) + grant_date: datetime = datetime.min.replace(tzinfo=timezone.utc) steam_appid: Optional[int] = None steam_grade: Optional[str] = None - steam_date: datetime = datetime.min.replace(tzinfo=UTC) + steam_date: datetime = datetime.min.replace(tzinfo=timezone.utc) steam_shortcut: Optional[int] = None tags: List[str] = field(default_factory=list) @@ -42,7 +42,7 @@ class Metadata: @staticmethod def parse_date(strdate: str): dt = datetime.fromisoformat(strdate) if strdate else datetime.min - return dt.replace(tzinfo=UTC) + return dt.replace(tzinfo=timezone.utc) @classmethod def from_dict(cls, data: Dict): @@ -63,11 +63,11 @@ def __dict__(self): return dict( queued=self.queued, queue_pos=self.queue_pos, - last_played=self.last_played.isoformat() if self.last_played else datetime.min.replace(tzinfo=UTC), - grant_date=self.grant_date.isoformat() if self.grant_date else datetime.min.replace(tzinfo=UTC), + last_played=self.last_played.isoformat() if self.last_played else datetime.min.replace(tzinfo=timezone.utc), + grant_date=self.grant_date.isoformat() if self.grant_date else datetime.min.replace(tzinfo=timezone.utc), steam_appid=self.steam_appid, steam_grade=self.steam_grade, - steam_date=self.steam_date.isoformat() if self.steam_date else datetime.min.replace(tzinfo=UTC), + steam_date=self.steam_date.isoformat() if self.steam_date else datetime.min.replace(tzinfo=timezone.utc), steam_shortcut=self.steam_shortcut, tags=self.tags, ) @@ -128,7 +128,7 @@ def set_worker(self, worker: Optional[QRunnable]): @Slot(int) def __game_launched(self, code: int): self.state = RareGame.State.RUNNING - self.metadata.last_played = datetime.now(UTC) + self.metadata.last_played = datetime.now(timezone.utc) if code == GameProcess.Code.ON_STARTUP: return self.__save_metadata() @@ -440,7 +440,7 @@ def steam_grade(self) -> str: if platform.system() == "Windows" or self.is_unreal: return "na" if self.metadata.steam_grade != "pending": - elapsed_time = abs(datetime.now(UTC) - self.metadata.steam_date) + elapsed_time = abs(datetime.now(timezone.utc) - self.metadata.steam_date) if elapsed_time.days > 3: logger.info("Refreshing ProtonDB grade for %s", self.app_title) worker = QRunnable.create(self.set_steam_grade) @@ -463,20 +463,20 @@ def set_steam_grade(self) -> None: if appid and self.steam_appid is None: self.set_steam_appid(appid) self.metadata.steam_grade = grade - self.metadata.steam_date = datetime.now(UTC) + self.metadata.steam_date = datetime.now(timezone.utc) self.__save_metadata() self.signals.widget.update.emit() def grant_date(self, force=False) -> datetime: if not (entitlements := self.core.lgd.entitlements): return self.metadata.grant_date - if self.metadata.grant_date == datetime.min.replace(tzinfo=UTC) or force: + if self.metadata.grant_date == datetime.min.replace(tzinfo=timezone.utc) or force: logger.debug("Grant date for %s not found in metadata, resolving", self.app_name) matching = filter(lambda ent: ent["namespace"] == self.game.namespace, entitlements) entitlement = next(matching, None) grant_date = datetime.fromisoformat( entitlement["grantDate"].replace("Z", "+00:00") - ) if entitlement else datetime.min.replace(tzinfo=UTC) + ) if entitlement else datetime.min.replace(tzinfo=timezone.utc) self.metadata.grant_date = grant_date self.__save_metadata() return self.metadata.grant_date diff --git a/rare/models/pathspec.py b/rare/models/pathspec.py index 398d65247..ee823ee5f 100644 --- a/rare/models/pathspec.py +++ b/rare/models/pathspec.py @@ -1,5 +1,5 @@ import os -from typing import Union, List, LiteralString +from typing import Union, List from legendary.core import LegendaryCore from legendary.models.game import InstalledGame @@ -65,6 +65,6 @@ def __init__(self, core: LegendaryCore = None, igame: InstalledGame = None): if igame is not None: self.__egl_path_vars["{installdir}"] = igame.install_path - def resolve_egl_path_vars(self, path: str) -> Union[LiteralString, str, bytes]: + def resolve_egl_path_vars(self, path: str) -> Union[str, bytes]: cooked_path = (self.__egl_path_vars.get(p.lower(), p) for p in path.split("/")) return os.path.join(*cooked_path) diff --git a/rare/models/steam.py b/rare/models/steam.py index 2301c926b..cd623bb17 100644 --- a/rare/models/steam.py +++ b/rare/models/steam.py @@ -2,7 +2,7 @@ import binascii import shlex from dataclasses import dataclass, field -from datetime import datetime, UTC +from datetime import datetime, timezone from typing import Dict, List, Type, Any @@ -34,7 +34,7 @@ def most_recent(self) -> bool: @property def last_login(self) -> datetime: - return datetime.fromtimestamp(float(self._user.get("Timestamp", "0")), UTC) + return datetime.fromtimestamp(float(self._user.get("Timestamp", "0")), timezone.utc) @property def __dict__(self): @@ -145,7 +145,7 @@ def game_logo(self) -> str: @property def last_played(self): - return datetime.fromtimestamp(float(self.LastPlayTime), UTC) + return datetime.fromtimestamp(float(self.LastPlayTime), timezone.utc) @property def __dict__(self): diff --git a/rare/utils/compat/steam.py b/rare/utils/compat/steam.py index c159442eb..f5d3137b5 100644 --- a/rare/utils/compat/steam.py +++ b/rare/utils/compat/steam.py @@ -1,7 +1,7 @@ import os import shlex from dataclasses import dataclass -from enum import StrEnum +from enum import Enum from hashlib import md5 from logging import getLogger from typing import Optional, Union, List, Dict, Set @@ -42,7 +42,7 @@ def find_libraries(steam_path: str) -> Set[str]: # is a good trade-off for the amount of complexity supporting everything would ensue. -class SteamVerb(StrEnum): +class SteamVerb(Enum): RUN = "run" WAIT_FOR_EXIT_AND_RUN = "waitforexitandrun" RUN_IN_PREFIX = "runinprefix" @@ -77,7 +77,7 @@ def command(self, verb: SteamVerb = SteamVerb.DEFAULT) -> List[str]: cmd = "".join([shlex.quote(tool_path), self.toolmanifest["commandline"]]) # NOTE: "waitforexitandrun" seems to be the verb used in by steam to execute stuff # `run` is used when setting up the environment, so use that if we are setting up the prefix. - cmd = cmd.replace("%verb%", str(verb)) + cmd = cmd.replace("%verb%", verb.value) return shlex.split(cmd) def as_str(self, verb: SteamVerb = SteamVerb.DEFAULT): From 4d56ec8dd41874bce6067f17c8df72b3e3b28ce7 Mon Sep 17 00:00:00 2001 From: loathingKernel <142770+loathingKernel@users.noreply.github.com> Date: Mon, 23 Dec 2024 18:57:57 +0200 Subject: [PATCH 2/4] chore: update project description --- misc/rare.desktop | 2 +- pyproject.toml | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/misc/rare.desktop b/misc/rare.desktop index 47e1954fd..1034bc0b4 100644 --- a/misc/rare.desktop +++ b/misc/rare.desktop @@ -4,7 +4,7 @@ Type=Application Categories=Game; Icon=rare Exec=rare -Comment=A GUI for legendary, an open source replacement for Epic Games Launcher +Comment=Open source alternative for Epic Games Launcher, using Legendary Terminal=false StartupWMClass=rare Keywords=epic;games;launcher;legendary; diff --git a/pyproject.toml b/pyproject.toml index fada7690a..700bb5268 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ force-exclude = ''' [tool.poetry] name = "rare" version = "1.10.11" -description = "A gui for legendary" +description = "Open source alternative for Epic Games Launcher, using Legendary" authors = ["RareDevs"] license = "GPL3" readme = "README.md" diff --git a/setup.py b/setup.py index b7dc505d6..5906926a8 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ def parse_requirements(filename): use_scm_version={"version_scheme": "only-version", "local_scheme": "no-local-version"}, author="RareDevs", license="GPL-3", - description="A gui for legendary", + description="Open source alternative for Epic Games Launcher, using Legendary", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/Dummerle/Rare", From cc40945bf6506de86d8bee3ce54827d6e65a8511 Mon Sep 17 00:00:00 2001 From: loathingKernel <142770+loathingKernel@users.noreply.github.com> Date: Mon, 23 Dec 2024 18:59:12 +0200 Subject: [PATCH 3/4] chore: move `freeze.py` into `misc` --- freeze.py => misc/freeze_msi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename freeze.py => misc/freeze_msi.py (92%) diff --git a/freeze.py b/misc/freeze_msi.py similarity index 92% rename from freeze.py rename to misc/freeze_msi.py index e5e970364..c3f96911b 100644 --- a/freeze.py +++ b/misc/freeze_msi.py @@ -4,7 +4,7 @@ name = 'Rare' author = 'RareDevs' -description = 'A gui for legendary' +description = 'Open source alternative for Epic Games Launcher, using Legendary' shortcut_table = [ ("DesktopShortcut", # Shortcut From 16ecf4a85cf821286aee3ab0941a0db721bc6fde Mon Sep 17 00:00:00 2001 From: loathingKernel <142770+loathingKernel@users.noreply.github.com> Date: Mon, 23 Dec 2024 18:59:45 +0200 Subject: [PATCH 4/4] workflows: update cx-freeze workflows --- .github/workflows/job_cx-freeze-msi.yml | 2 +- .github/workflows/job_cx-freeze-zip.yml | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/job_cx-freeze-msi.yml b/.github/workflows/job_cx-freeze-msi.yml index 13e07e7f7..0c1a9a2a2 100644 --- a/.github/workflows/job_cx-freeze-msi.yml +++ b/.github/workflows/job_cx-freeze-msi.yml @@ -27,7 +27,7 @@ jobs: pip3 install -r requirements-presence.txt - name: Build run: | - python freeze.py bdist_msi + python misc/freeze.py bdist_msi mv dist/*.msi Rare.msi - name: Upload artifact diff --git a/.github/workflows/job_cx-freeze-zip.yml b/.github/workflows/job_cx-freeze-zip.yml index e028f6724..c64abffaa 100644 --- a/.github/workflows/job_cx-freeze-zip.yml +++ b/.github/workflows/job_cx-freeze-zip.yml @@ -27,7 +27,14 @@ jobs: pip3 install -r requirements-presence.txt pip3 install . - name: Build - run: cxfreeze -c rare/main.py --target-dir dist --target-name rare --icon rare/resources/images/Rare.ico -OO --base-name Win32GUI + run: >- + cxfreeze + -c rare/main.py + --target-dir dist + --target-name rare + --icon rare/resources/images/Rare.ico + -OO + --base-name Win32GUI - name: Compress run: | python -c "import shutil; shutil.make_archive('Rare', 'zip', 'rare.dist')"