mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 17:59:43 +02:00
refractor files and improve aria2 process killing, needs improvement
This commit is contained in:
@@ -12,12 +12,13 @@ from PySide6.QtWidgets import (
|
|||||||
QTabWidget,
|
QTabWidget,
|
||||||
QProgressBar,
|
QProgressBar,
|
||||||
)
|
)
|
||||||
from PySide6.QtGui import QIcon, QAction
|
from PySide6.QtGui import QIcon, QAction, QCloseEvent
|
||||||
import darkdetect
|
import darkdetect
|
||||||
import threading
|
import threading
|
||||||
from core.utils.wrappers import run_thread
|
from core.utils.general.wrappers import run_thread
|
||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
from core.utils.network.download import download_selected
|
from core.utils.network.download import download_selected
|
||||||
|
from core.utils.general.shutdown import closehelper
|
||||||
from core.interface.utils.tabhelper import create_tab
|
from core.interface.utils.tabhelper import create_tab
|
||||||
from core.interface.utils.searchhelper import return_pressed
|
from core.interface.utils.searchhelper import return_pressed
|
||||||
from core.interface.dialogs.settings import settings_dialog
|
from core.interface.dialogs.settings import settings_dialog
|
||||||
@@ -108,6 +109,10 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.progress_timer.timeout.connect(lambda: run_thread(threading.Thread(target=self.update_progress)))
|
self.progress_timer.timeout.connect(lambda: run_thread(threading.Thread(target=self.update_progress)))
|
||||||
self.progress_timer.start(1000)
|
self.progress_timer.start(1000)
|
||||||
|
|
||||||
|
def closeEvent(self, event: QCloseEvent):
|
||||||
|
closehelper()
|
||||||
|
event.accept()
|
||||||
|
|
||||||
def set_tracker(self, _):
|
def set_tracker(self, _):
|
||||||
state.tracker = self.tracker_list.currentText()
|
state.tracker = self.tracker_list.currentText()
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,6 @@ def send_notification(shutdown_event):
|
|||||||
message = f"{download.name} has finished downloading.",
|
message = f"{download.name} has finished downloading.",
|
||||||
timeout = 4
|
timeout = 4
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class AppState:
|
|||||||
speed_limit: int = 0
|
speed_limit: int = 0
|
||||||
aria2process: Optional[Any] = None
|
aria2process: Optional[Any] = None
|
||||||
aria2: Any = None
|
aria2: Any = None
|
||||||
|
aria2p: Any = None
|
||||||
aria2_threads: int = 4
|
aria2_threads: int = 4
|
||||||
|
|
||||||
state = AppState(posts=[], post_titles=[], post_urls=[], post_author=[], download_path="")
|
state = AppState(posts=[], post_titles=[], post_urls=[], post_author=[], download_path="")
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
from core.utils.data.state import state
|
||||||
|
import threading
|
||||||
|
|
||||||
|
|
||||||
|
shutdown_event = threading.Event()
|
||||||
|
|
||||||
|
def kill_aria2server():
|
||||||
|
if state.aria2process:
|
||||||
|
state.aria2process.kill()
|
||||||
|
if state.debug:
|
||||||
|
print("\nKilled Aria2")
|
||||||
|
|
||||||
|
|
||||||
|
def closehelper():
|
||||||
|
shutdown_event.set()
|
||||||
|
kill_aria2server()
|
||||||
@@ -3,7 +3,7 @@ from core.utils.data.tracker import get_item_url
|
|||||||
from core.utils.data.tracker import get_magnet_link
|
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.wrappers import run_thread
|
from core.utils.general.wrappers import run_thread
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,19 +2,20 @@ from core.interface.gui import MainWindow
|
|||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
from core.network.aria2_integration import aria2server
|
from core.network.aria2_integration import aria2server
|
||||||
from core.network.aria2_integration import send_notification
|
from core.network.aria2_integration import send_notification
|
||||||
from core.utils.wrappers import run_thread
|
from core.utils.general.shutdown import kill_aria2server, closehelper, shutdown_event
|
||||||
import threading
|
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 PySide6 import QtWidgets
|
from PySide6 import QtWidgets
|
||||||
import qdarktheme
|
import qdarktheme
|
||||||
import darkdetect
|
import darkdetect
|
||||||
|
import threading
|
||||||
import signal
|
import signal
|
||||||
import atexit
|
import atexit
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# Debug Output
|
# Debug Output
|
||||||
state.debug = True
|
state.debug = True
|
||||||
shutdown_event = threading.Event()
|
|
||||||
|
|
||||||
def run_gui():
|
def run_gui():
|
||||||
app = QtWidgets.QApplication([])
|
app = QtWidgets.QApplication([])
|
||||||
@@ -30,19 +31,8 @@ def run_aria2server():
|
|||||||
aria2process = aria2server()
|
aria2process = aria2server()
|
||||||
return aria2process
|
return aria2process
|
||||||
|
|
||||||
|
|
||||||
def kill_aria2server():
|
|
||||||
if state.aria2process:
|
|
||||||
state.aria2process.kill()
|
|
||||||
if state.debug:
|
|
||||||
print("\nKilled Aria2")
|
|
||||||
|
|
||||||
|
|
||||||
def keyboardinterrupthandler(signum, frame):
|
def keyboardinterrupthandler(signum, frame):
|
||||||
shutdown_event.set()
|
closehelper()
|
||||||
kill_aria2server()
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
read_config()
|
read_config()
|
||||||
|
|||||||
Reference in New Issue
Block a user