mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 09:59:41 +02:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 90124fd9c8 | |||
| 4175f82967 | |||
| 4bf2e9af81 |
@@ -18,7 +18,7 @@ from PySide6.QtWidgets import (
|
|||||||
QStyledItemDelegate,
|
QStyledItemDelegate,
|
||||||
)
|
)
|
||||||
|
|
||||||
from PySide6.QtGui import QIcon, QCloseEvent, QImage, QPixmap, QContextMenuEvent
|
from PySide6.QtGui import QIcon, QCloseEvent, QImage, QPixmap, QContextMenuEvent, QGuiApplication
|
||||||
import darkdetect
|
import darkdetect
|
||||||
import threading
|
import threading
|
||||||
import platform
|
import platform
|
||||||
@@ -67,6 +67,9 @@ def download_update(latest_version):
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
def windowCloseHelper():
|
||||||
|
QGuiApplication.quit()
|
||||||
|
|
||||||
class MainWindow(QtWidgets.QMainWindow, QWidget):
|
class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||||
log_signal = Signal(str) # Thread-safe signal for logging
|
log_signal = Signal(str) # Thread-safe signal for logging
|
||||||
|
|
||||||
@@ -154,7 +157,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
header = table.horizontalHeader()
|
header = table.horizontalHeader()
|
||||||
header.setSectionResizeMode(0, QHeaderView.ResizeMode.Stretch)
|
header.setSectionResizeMode(0, QHeaderView.ResizeMode.Stretch)
|
||||||
header.setSectionResizeMode(1, QHeaderView.ResizeMode.Fixed)
|
header.setSectionResizeMode(1, QHeaderView.ResizeMode.Fixed)
|
||||||
header.resizeSection(1, 500)
|
header.resizeSection(1, 200)
|
||||||
header.setStretchLastSection(False)
|
header.setStretchLastSection(False)
|
||||||
|
|
||||||
return table
|
return table
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
from core.utils.logging.logs import consoleLog
|
from core.utils.logging.logs import consoleLog, remove_download_log
|
||||||
from core.utils.network.download import run_download_direct
|
from core.utils.network.download import run_download_direct
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
def split_data(data):
|
def split_data(data):
|
||||||
|
|
||||||
count = data.count
|
count = data.count
|
||||||
@@ -16,6 +18,11 @@ def check_completed(downloads, resume):
|
|||||||
run_download_direct(download.magnet_uri)
|
run_download_direct(download.magnet_uri)
|
||||||
consoleLog(f"Resuming {download.title}")
|
consoleLog(f"Resuming {download.title}")
|
||||||
|
|
||||||
|
def check_downloads(downloads):
|
||||||
|
for download in downloads:
|
||||||
|
if os.path.exists(download.path):
|
||||||
|
consoleLog(f"Existing Download: {download.title}")
|
||||||
|
else:
|
||||||
|
consoleLog(f"Inexistent Download: {download.title}")
|
||||||
|
remove_download_log(download.magnet_uri)
|
||||||
|
|
||||||
@@ -77,10 +77,12 @@ def remove_download_log(magnet_uri) -> DownloadList:
|
|||||||
else:
|
else:
|
||||||
downloads = []
|
downloads = []
|
||||||
|
|
||||||
|
|
||||||
magnet_link = (magnet_uri or "").strip()
|
magnet_link = (magnet_uri or "").strip()
|
||||||
|
title = next((getattr(d, 'title', 'Unknown') for d in downloads if (getattr(d, 'magnet_uri', None) or '').strip() == magnet_link or (getattr(d, 'url', None) or '').strip() == magnet_link))
|
||||||
downloads = [d for d in downloads if (getattr(d, 'magnet_uri', None) or "").strip() != magnet_link and (getattr(d, 'url', None) or "").strip() != magnet_link]
|
downloads = [d for d in downloads if (getattr(d, 'magnet_uri', None) or "").strip() != magnet_link and (getattr(d, 'url', None) or "").strip() != magnet_link]
|
||||||
|
|
||||||
consoleLog(f"Removed {magnet_link} from Log File")
|
consoleLog(f"Removed {title} from Log File")
|
||||||
|
|
||||||
download_list = DownloadList(data=downloads, count=len(downloads))
|
download_list = DownloadList(data=downloads, count=len(downloads))
|
||||||
with open(downloads_file, "w") as file:
|
with open(downloads_file, "w") as file:
|
||||||
|
|||||||
+7
-11
@@ -1,11 +1,11 @@
|
|||||||
from core.interface.gui import MainWindow
|
from core.interface.gui import MainWindow, windowCloseHelper
|
||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
from core.utils.logging.logs import consoleLog
|
from core.utils.logging.logs import consoleLog
|
||||||
from core.network.libtorrent_misc import send_notification, update_log
|
from core.network.libtorrent_misc import send_notification, update_log
|
||||||
from core.utils.logging.logs import get_download_logs
|
from core.utils.logging.logs import get_download_logs
|
||||||
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.logging.loghandler import split_data, check_completed
|
from core.utils.logging.loghandler import split_data, check_completed, check_downloads
|
||||||
from core.network.interface import list_interfaces, init_interfaces
|
from core.network.interface import list_interfaces, init_interfaces
|
||||||
from core.utils.config.config import read_config
|
from core.utils.config.config import read_config
|
||||||
from PySide6 import QtWidgets
|
from PySide6 import QtWidgets
|
||||||
@@ -14,15 +14,9 @@ import qdarktheme
|
|||||||
import threading
|
import threading
|
||||||
import platform
|
import platform
|
||||||
import signal
|
import signal
|
||||||
import argparse
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
parser.add_argument("--debug", action="store_true")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
def run_gui():
|
def run_gui():
|
||||||
app = QtWidgets.QApplication.instance() or QtWidgets.QApplication(sys.argv)
|
app = QtWidgets.QApplication.instance() or QtWidgets.QApplication(sys.argv)
|
||||||
qdarktheme.setup_theme("auto")
|
qdarktheme.setup_theme("auto")
|
||||||
@@ -39,14 +33,13 @@ def run_gui():
|
|||||||
|
|
||||||
def keyboardinterrupthandler(signum, frame):
|
def keyboardinterrupthandler(signum, frame):
|
||||||
closehelper()
|
closehelper()
|
||||||
|
windowCloseHelper()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main():
|
||||||
start_time = time.perf_counter()
|
start_time = time.perf_counter()
|
||||||
read_config()
|
read_config()
|
||||||
logs = get_download_logs()
|
logs = get_download_logs()
|
||||||
_, downloads = split_data(logs)
|
_, downloads = split_data(logs)
|
||||||
if args.debug:
|
|
||||||
state.debug = args.debug # override of read_config
|
|
||||||
signal.signal(signal.SIGINT, keyboardinterrupthandler)
|
signal.signal(signal.SIGINT, keyboardinterrupthandler)
|
||||||
consoleLog("Starting SoftwareManager...")
|
consoleLog("Starting SoftwareManager...")
|
||||||
consoleLog("Fetching Network Interfaces...")
|
consoleLog("Fetching Network Interfaces...")
|
||||||
@@ -60,7 +53,10 @@ if __name__ == "__main__":
|
|||||||
consoleLog("Started Thread: update_log")
|
consoleLog("Started Thread: update_log")
|
||||||
run_thread(threading.Thread(target=check_completed, args=(downloads, state.autoresume)))
|
run_thread(threading.Thread(target=check_completed, args=(downloads, state.autoresume)))
|
||||||
consoleLog("Started Thread: check_completed")
|
consoleLog("Started Thread: check_completed")
|
||||||
|
check_downloads(downloads)
|
||||||
elapsed = time.perf_counter() - start_time
|
elapsed = time.perf_counter() - start_time
|
||||||
consoleLog(f"Initialization completed in {elapsed:.2f}s. Launching GUI")
|
consoleLog(f"Initialization completed in {elapsed:.2f}s. Launching GUI")
|
||||||
run_gui()
|
run_gui()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user