mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 17:59:43 +02:00
refactor state.py and add comments to it, add another check to version getter.
This commit is contained in:
@@ -24,7 +24,7 @@ def _get_build_info_path() -> (Path | None):
|
|||||||
def get_version() -> None:
|
def get_version() -> None:
|
||||||
# Get build info filepath
|
# Get build info filepath
|
||||||
build_info_path = _get_build_info_path()
|
build_info_path = _get_build_info_path()
|
||||||
if os.path.exists(build_info_path):
|
if build_info_path and os.path.exists(build_info_path):
|
||||||
with open(build_info_path, "r") as f:
|
with open(build_info_path, "r") as f:
|
||||||
build_info = json.load(f)
|
build_info = json.load(f)
|
||||||
state.version = build_info.get("version")
|
state.version = build_info.get("version")
|
||||||
@@ -46,3 +46,4 @@ class UpdateDialog(QDialog):
|
|||||||
response = msg.exec_()
|
response = msg.exec_()
|
||||||
if response == QMessageBox.StandardButton.Ok:
|
if response == QMessageBox.StandardButton.Ok:
|
||||||
download_update(assets)
|
download_update(assets)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from core.network.libtorrent_int import update_settings
|
from core.network.libtorrent_int import update_settings
|
||||||
from core.utils.logging.logs import consoleLog
|
from core.utils.logging.logs import consoleLog
|
||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
from .config import create_config
|
from core.utils.config.config import create_config
|
||||||
|
|
||||||
|
|
||||||
def save_settings(close=lambda: None, apiurl=None, download_path=None, down_speed_limit=None, up_speed_limit=None, image_path=None, autoresume=None, max_connections=None, max_downloads=None, bound_interface=None):
|
def save_settings(close=lambda: None, apiurl=None, download_path=None, down_speed_limit=None, up_speed_limit=None, image_path=None, autoresume=None, max_connections=None, max_downloads=None, bound_interface=None):
|
||||||
|
|||||||
@@ -9,43 +9,50 @@ class AppState(QObject):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.posts: list[Dict[str,str]] | None = None # titles, urls, author, seederm leecher
|
|
||||||
self.version: str = "dev"
|
|
||||||
self._image_path: str = ""
|
|
||||||
self.ignore_updates: bool = False
|
|
||||||
self.debug: bool = False
|
|
||||||
self.autoresume: bool = True
|
|
||||||
|
|
||||||
self.currenttracker: str = "rutracker"
|
# General
|
||||||
self.trackertable: QTableWidget
|
self.version: str = "Unknown"
|
||||||
self.trackers: Dict[str,Dict[str,Any]] = {} # each tracker should add itself here
|
self.debug: bool = False
|
||||||
'''
|
self.main_window: Any = None
|
||||||
an example:
|
self.loop_running: bool = False
|
||||||
"rutracker" : {
|
self.shutdown_event = threading.Event()
|
||||||
"name" : "rutracker", # name of the tracker
|
self.log_buffer: List[str] = []
|
||||||
"headers" : ["author", "title"], # keys shown in the table
|
|
||||||
"scrapeFunc" : function,
|
# Paths
|
||||||
}
|
self.settings_path: str = ""
|
||||||
'''
|
self._image_path: str = ""
|
||||||
self.api_url: str = "https://api.michijackson.xyz"
|
|
||||||
self.seeded_magnets: set = set()
|
|
||||||
self.download_path: str = str(Path.home() / "Downloads")
|
self.download_path: str = str(Path.home() / "Downloads")
|
||||||
|
|
||||||
|
# GUI
|
||||||
|
self.window_transparency: bool = False
|
||||||
|
self.trackertable: QTableWidget
|
||||||
|
self.interfaces: List = []
|
||||||
|
self.active_interfaces: List = []
|
||||||
|
self.bound_interface: Any = None
|
||||||
|
|
||||||
|
# Trackers / Scraping
|
||||||
|
self.posts: list[Dict[str,str]] | None = None # titles, urls, author, seeders, leechers
|
||||||
|
self.currenttracker: str = "rutracker"
|
||||||
|
self.api_url: str = "https://api.michijackson.xyz"
|
||||||
|
self.trackers: Dict[str,Dict[str,Any]] = {} # each tracker should add itself here
|
||||||
|
# an example:
|
||||||
|
# "rutracker" : {
|
||||||
|
# "name" : "rutracker",
|
||||||
|
# "headers" : ["author", "title"],
|
||||||
|
# "scrapeFunc" : function,
|
||||||
|
# }
|
||||||
|
|
||||||
|
# LibTorrent / Download related stuff
|
||||||
|
self.dl_session: Any = None
|
||||||
|
self.active_downloads: Dict = {}
|
||||||
|
self.seeded_magnets: set = set()
|
||||||
|
self.ignore_updates: bool = False
|
||||||
|
self.autoresume: bool = True
|
||||||
self.up_speed_limit: int = 0
|
self.up_speed_limit: int = 0
|
||||||
self.down_speed_limit: int = 0
|
self.down_speed_limit: int = 0
|
||||||
self.max_connections: int = 200
|
self.max_connections: int = 200
|
||||||
self.max_downloads: int = 10
|
self.max_downloads: int = 10
|
||||||
self.settings_path: str = ""
|
|
||||||
self.dl_session: Any = None
|
|
||||||
self.active_downloads: Dict = {}
|
|
||||||
self.window_transparency: bool = False
|
|
||||||
self.interfaces: List = []
|
|
||||||
self.active_interfaces: List = []
|
|
||||||
self.bound_interface: Any = None
|
|
||||||
self.log_buffer: List[str] = []
|
|
||||||
self.downloads_lock = threading.RLock()
|
self.downloads_lock = threading.RLock()
|
||||||
self.main_window: Any = None
|
|
||||||
self.loop_running: bool = False
|
|
||||||
self.shutdown_event = threading.Event()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def image_path(self) -> str:
|
def image_path(self) -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user