1
0
Fork 0
mirror of synced 2024-06-26 10:11:19 +12:00

Move appdata paths to utils/paths.py to avoid crashes, if PyQt5 does not exist (deb workflow)

This commit is contained in:
Dummerle 2022-02-17 00:04:53 +01:00
parent 5ea799bcdd
commit 2e6890bfd9
No known key found for this signature in database
GPG key ID: AB68CC59CA39F2F1
12 changed files with 42 additions and 31 deletions

View file

@ -1,17 +1,3 @@
import os
__version__ = "1.8.7"
from PyQt5.QtCore import QStandardPaths
code_name = "Stellula Kakopo"
resources_path = os.path.join(os.path.dirname(__file__), "resources")
data_dir = os.path.join(QStandardPaths.writableLocation(QStandardPaths.DataLocation), "rare")
cache_dir = os.path.join(QStandardPaths.writableLocation(QStandardPaths.CacheLocation), "rare")
image_dir = os.path.join(data_dir, "images")
tmp_dir = os.path.join(cache_dir, "tmp")
for path in (resources_path, data_dir, cache_dir, image_dir, tmp_dir):
if not os.path.exists(path):
os.makedirs(path)

View file

@ -80,7 +80,7 @@ def main():
me = singleton.SingleInstance()
except singleton.SingleInstanceException:
print("Rare is already running")
from rare import data_dir
from rare.utils.paths import data_dir
with open(os.path.join(data_dir, "lockfile"), "w") as file:
if args.subparser == "launch":

View file

@ -16,7 +16,7 @@ import legendary
# noinspection PyUnresolvedReferences
import rare.resources.resources
import rare.shared as shared
from rare import cache_dir, resources_path, tmp_dir
from rare.utils.paths import cache_dir, resources_path, tmp_dir
from rare.components.dialogs.launch_dialog import LaunchDialog
from rare.components.main_window import MainWindow
from rare.components.tray_icon import TrayIcon

View file

@ -4,13 +4,14 @@ from logging import getLogger
from PyQt5.QtCore import Qt, pyqtSignal, QRunnable, QObject, QThreadPool
from PyQt5.QtWidgets import QDialog, QApplication
from legendary.core import LegendaryCore
from requests.exceptions import ConnectionError, HTTPError
from legendary.core import LegendaryCore
from rare import image_dir, shared
from rare import shared
from rare.components.dialogs.login import LoginDialog
from rare.ui.components.dialogs.launch_dialog import Ui_LaunchDialog
from rare.utils.models import ApiResults
from rare.utils.paths import image_dir
from rare.utils.utils import download_images, CloudWorker
logger = getLogger("Login")

View file

@ -5,8 +5,9 @@ from PyQt5.QtCore import Qt, QSettings, QTimer, QSize
from PyQt5.QtGui import QCloseEvent, QCursor
from PyQt5.QtWidgets import QMainWindow, QApplication, QStatusBar
from rare import data_dir, shared
from rare import shared
from rare.components.tabs import TabWidget
from rare.utils.paths import data_dir
logger = getLogger("Window")

View file

@ -7,10 +7,12 @@ from logging import getLogger
from PyQt5.QtCore import QSettings, Qt
from PyQt5.QtWidgets import QWidget, QMessageBox
from rare import cache_dir, shared
from rare import shared
from rare.components.tabs.settings.rpc import RPCSettings
from rare.ui.components.tabs.settings.rare import Ui_RareSettings
from rare.utils import utils
from rare.utils.paths import cache_dir
from rare.utils.utils import (
get_translations,
get_color_schemes,

View file

@ -1,12 +1,13 @@
from PyQt5.QtWidgets import QStackedWidget, QTabWidget
from legendary.core import LegendaryCore
from rare import cache_dir, shared
from rare.components.tabs.shop.game_info import ShopGameInfo
from rare.components.tabs.shop.search_results import SearchResults
from rare.components.tabs.shop.shop_api_core import ShopApiCore
from rare.components.tabs.shop.shop_widget import ShopWidget
from rare.components.tabs.shop.wishlist import WishlistWidget, Wishlist
from rare import shared
from rare.utils.paths import cache_dir
from .game_info import ShopGameInfo
from .search_results import SearchResults
from .shop_api_core import ShopApiCore
from .shop_widget import ShopWidget
from .wishlist import WishlistWidget, Wishlist
class Shop(QStackedWidget):

View file

@ -33,7 +33,7 @@ from PyQt5.QtWidgets import (
QFileIconProvider,
)
from rare import tmp_dir
from rare.utils.paths import tmp_dir
from rare.utils.qt_requests import QtRequestManager
from rare.utils.utils import icon as qta_icon

View file

@ -5,7 +5,7 @@ from datetime import datetime
from logging import getLogger
from typing import Dict
from rare import data_dir
from rare.utils.paths import data_dir
logger = getLogger("GameMeta")

18
rare/utils/paths.py Normal file
View file

@ -0,0 +1,18 @@
import os
__version__ = "1.8.7"
code_name = "Stellula Kakopo"
from PyQt5.QtCore import QStandardPaths
resources_path = os.path.join(os.path.dirname(__file__), "../resources")
data_dir = os.path.join(QStandardPaths.writableLocation(QStandardPaths.DataLocation), "rare")
cache_dir = os.path.join(QStandardPaths.writableLocation(QStandardPaths.CacheLocation), "rare")
image_dir = os.path.join(data_dir, "images")
tmp_dir = os.path.join(cache_dir, "tmp")
for path in (resources_path, data_dir, cache_dir, image_dir, tmp_dir):
if not os.path.exists(path):
os.makedirs(path)

View file

@ -7,7 +7,8 @@ import requests
from PyQt5.QtCore import pyqtSignal, QRunnable, QObject, QCoreApplication
from legendary.core import LegendaryCore
from rare import data_dir, cache_dir, shared
from rare import shared
from rare.utils.paths import data_dir, cache_dir
replace_chars = ",;.:-_ "

View file

@ -22,9 +22,9 @@ from PyQt5.QtCore import (
)
from PyQt5.QtGui import QPalette, QColor, QPixmap, QImage
from PyQt5.QtWidgets import QApplication, QStyleFactory
from legendary.models.game import Game
from requests.exceptions import HTTPError
from legendary.models.game import Game
from .models import PathSpec
# Windows
@ -33,7 +33,8 @@ if platform.system() == "Windows":
# noinspection PyUnresolvedReferences
from win32com.client import Dispatch # pylint: disable=E0401
from rare import image_dir, shared, resources_path
from rare import shared
from rare.utils.paths import image_dir, resources_path
# Mac not supported