Move appdata paths to utils/paths.py to avoid crashes, if PyQt5 does not exist (deb workflow)
This commit is contained in:
parent
5ea799bcdd
commit
2e6890bfd9
|
@ -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)
|
||||
|
|
|
@ -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":
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
18
rare/utils/paths.py
Normal 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)
|
|
@ -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 = ",;.:-_ "
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue