mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
Add basic download logging + fix debug
This commit is contained in:
@@ -29,4 +29,19 @@ def add_download_log(title, url, magnet_uri, completed) -> DownloadList:
|
|||||||
with open(downloads_file, "w") as file:
|
with open(downloads_file, "w") as file:
|
||||||
json.dump(asdict(download_list), file, indent=4)
|
json.dump(asdict(download_list), file, indent=4)
|
||||||
|
|
||||||
return download_list
|
return download_list
|
||||||
|
|
||||||
|
def get_download_logs() -> DownloadList:
|
||||||
|
downloads_file = os.path.join(state.settings_path, "downloads.json")
|
||||||
|
|
||||||
|
if os.path.exists(downloads_file) and os.path.getsize(downloads_file) > 0:
|
||||||
|
try:
|
||||||
|
with open(downloads_file, "r") as file:
|
||||||
|
existing_data = json.load(file)
|
||||||
|
downloads = [Download(**d) for d in existing_data.get("data", [])]
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
downloads = []
|
||||||
|
else:
|
||||||
|
downloads = []
|
||||||
|
|
||||||
|
return DownloadList(data=downloads, count=len(downloads))
|
||||||
@@ -4,6 +4,8 @@ from core.utils.data.tracker import get_magnet_link
|
|||||||
from core.network.aria2_wrapper import start_client
|
from core.network.aria2_wrapper import start_client
|
||||||
from core.network.aria2_wrapper import add_magnet
|
from core.network.aria2_wrapper import add_magnet
|
||||||
from core.utils.general.wrappers import run_thread
|
from core.utils.general.wrappers import run_thread
|
||||||
|
from core.utils.general.logs import add_download_log
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
|
||||||
@@ -22,6 +24,7 @@ def run_download(item, posts, post_titles):
|
|||||||
print("Selected URL: ", post_url)
|
print("Selected URL: ", post_url)
|
||||||
magnet_uri = get_magnet_link(post_url)
|
magnet_uri = get_magnet_link(post_url)
|
||||||
start_client()
|
start_client()
|
||||||
|
add_download_log(item, post_url, magnet_uri, False)
|
||||||
add_magnet(magnet_uri)
|
add_magnet(magnet_uri)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from core.network.aria2_integration import send_notification
|
|||||||
from core.utils.general.shutdown import closehelper, shutdown_event
|
from core.utils.general.shutdown import closehelper, shutdown_event
|
||||||
from core.utils.general.wrappers import run_thread
|
from core.utils.general.wrappers import run_thread
|
||||||
from core.utils.config.config import read_config
|
from core.utils.config.config import read_config
|
||||||
|
from core.utils.general.logs import get_download_logs
|
||||||
from PySide6 import QtWidgets
|
from PySide6 import QtWidgets
|
||||||
import qdarktheme
|
import qdarktheme
|
||||||
import darkdetect
|
import darkdetect
|
||||||
@@ -37,7 +38,8 @@ def keyboardinterrupthandler(signum, frame):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
read_config()
|
read_config()
|
||||||
state.debug = args.debug # override of read_config
|
if args.debug:
|
||||||
|
state.debug = args.debug # override of read_config
|
||||||
if state.debug:
|
if state.debug:
|
||||||
print("Starting Aria2 Server")
|
print("Starting Aria2 Server")
|
||||||
state.aria2process = run_aria2server()
|
state.aria2process = run_aria2server()
|
||||||
|
|||||||
Reference in New Issue
Block a user