mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 09:59:41 +02:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9afced8a0b | |||
| db77bed3cf | |||
| cc3b201450 |
@@ -28,18 +28,33 @@ def settings_dialog(self):
|
|||||||
def close_settings():
|
def close_settings():
|
||||||
dialog.reject()
|
dialog.reject()
|
||||||
|
|
||||||
checkbox_container = QWidget()
|
update_checkbox_container = QWidget()
|
||||||
checkbox_layout = QHBoxLayout()
|
update_checkbox_layout = QHBoxLayout()
|
||||||
|
|
||||||
# ignore updates checkbox
|
# ignore updates checkbox
|
||||||
checkbox = QCheckBox()
|
update_checkbox = QCheckBox()
|
||||||
checkbox_container.setLayout(checkbox_layout)
|
update_checkbox_container.setLayout(update_checkbox_layout)
|
||||||
checkbox_layout.addWidget(QLabel("Ignore Updates: "))
|
update_checkbox_layout.addWidget(QLabel("Ignore Updates: "))
|
||||||
checkbox_layout.addStretch()
|
update_checkbox_layout.addStretch()
|
||||||
checkbox.setChecked(state.ignore_updates)
|
update_checkbox.setChecked(state.ignore_updates)
|
||||||
checkbox.toggled.connect(lambda checked: setattr(state, 'ignore_updates', checked))
|
update_checkbox.toggled.connect(lambda checked: setattr(state, 'ignore_updates', checked))
|
||||||
checkbox_layout.addWidget(checkbox)
|
update_checkbox_layout.addWidget(update_checkbox)
|
||||||
dialog.layout().addWidget(checkbox_container)
|
dialog.layout().addWidget(update_checkbox_container)
|
||||||
|
|
||||||
|
# auto-resume downloads checkbox
|
||||||
|
|
||||||
|
autoresume_container = QWidget()
|
||||||
|
autoresume_layout = QHBoxLayout()
|
||||||
|
|
||||||
|
autoresume_checkbox = QCheckBox()
|
||||||
|
autoresume_container.setLayout(autoresume_layout)
|
||||||
|
autoresume_layout.addWidget(QLabel("Auto-Resume Downloads: "))
|
||||||
|
|
||||||
|
autoresume_layout.addStretch()
|
||||||
|
autoresume_checkbox.setChecked(state.autoresume)
|
||||||
|
autoresume_checkbox.toggled.connect(lambda checked: setattr(state, 'autoresume', checked))
|
||||||
|
autoresume_layout.addWidget(autoresume_checkbox)
|
||||||
|
dialog.layout().addWidget(autoresume_container)
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# THREAD SETTING #
|
# THREAD SETTING #
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ def create_config():
|
|||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
|
|
||||||
config["General"] = {"debug": True, "api_url": f"{state.api_url}", "aria2_threads": f"{state.aria2_threads}", "download_path": f"{state.download_path}", f"speed_limit": f"{state.speed_limit}",
|
config["General"] = {"debug": True, "api_url": f"{state.api_url}", "aria2_threads": f"{state.aria2_threads}", "download_path": f"{state.download_path}", f"speed_limit": f"{state.speed_limit}",
|
||||||
"ignore_updates": f"{state.ignore_updates}", "image_path": f"{state.image_path}"}
|
"ignore_updates": f"{state.ignore_updates}", "image_path": f"{state.image_path}", "autoresume": f"{state.autoresume}"}
|
||||||
|
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming"))
|
config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming"))
|
||||||
@@ -51,3 +51,5 @@ def read_config():
|
|||||||
state.ignore_updates = config.getboolean("General", "ignore_updates")
|
state.ignore_updates = config.getboolean("General", "ignore_updates")
|
||||||
if state.image_path is not None:
|
if state.image_path is not None:
|
||||||
state.image_path = config.get("General", "image_path")
|
state.image_path = config.get("General", "image_path")
|
||||||
|
if state.autoresume is not None:
|
||||||
|
state.autoresume = config.getboolean("General", "autoresume")
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ def restart_aria2c():
|
|||||||
atexit.unregister(kill_aria2server)
|
atexit.unregister(kill_aria2server)
|
||||||
atexit.register(kill_aria2server)
|
atexit.register(kill_aria2server)
|
||||||
|
|
||||||
def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_path=None, speed_limit=None, image_path=None):
|
def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_path=None, speed_limit=None, image_path=None, autoresume=None):
|
||||||
if thread_count is not None:
|
if thread_count is not None:
|
||||||
state.aria2_threads = thread_count
|
state.aria2_threads = thread_count
|
||||||
if apiurl is not None:
|
if apiurl is not None:
|
||||||
@@ -24,6 +24,9 @@ def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_p
|
|||||||
state.speed_limit = speed_limit
|
state.speed_limit = speed_limit
|
||||||
if image_path is not None:
|
if image_path is not None:
|
||||||
state.image_path = image_path
|
state.image_path = image_path
|
||||||
|
if autoresume is not None:
|
||||||
|
state.autoresume = autoresume
|
||||||
|
|
||||||
|
|
||||||
create_config()
|
create_config()
|
||||||
restart_aria2c()
|
restart_aria2c()
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class AppState(QObject):
|
|||||||
self._image_path: str = ""
|
self._image_path: str = ""
|
||||||
self.ignore_updates: bool = False
|
self.ignore_updates: bool = False
|
||||||
self.debug: bool = False
|
self.debug: bool = False
|
||||||
|
self.autoresume: bool = True
|
||||||
self.tracker: str = "rutracker"
|
self.tracker: str = "rutracker"
|
||||||
self.api_url: str = "https://api.michijackson.xyz"
|
self.api_url: str = "https://api.michijackson.xyz"
|
||||||
self.download_path: str = str(Path.home() / "Downloads")
|
self.download_path: str = str(Path.home() / "Downloads")
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
from core.utils.data.state import state
|
||||||
|
from core.utils.network.download import run_download_direct
|
||||||
|
|
||||||
|
def split_data(data):
|
||||||
|
|
||||||
|
count = data.count
|
||||||
|
downloads = data.data
|
||||||
|
|
||||||
|
return count, downloads
|
||||||
|
|
||||||
|
def check_completed(downloads, resume):
|
||||||
|
for download in downloads:
|
||||||
|
if download.completed == False:
|
||||||
|
if state.debug:
|
||||||
|
print(f"Found unfinished download: {download.title}")
|
||||||
|
if resume == True:
|
||||||
|
run_download_direct(download.magnet_uri)
|
||||||
|
if state.debug:
|
||||||
|
print(f"Resuming {download.title}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -27,5 +27,9 @@ def run_download(item, posts, post_titles):
|
|||||||
add_download_log(item, post_url, magnet_uri, False)
|
add_download_log(item, post_url, magnet_uri, False)
|
||||||
add_magnet(magnet_uri)
|
add_magnet(magnet_uri)
|
||||||
|
|
||||||
|
def run_download_direct(magnet_uri):
|
||||||
|
start_client()
|
||||||
|
add_magnet(magnet_uri)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ 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, update_log
|
from core.network.aria2_integration import send_notification, update_log
|
||||||
|
from core.utils.general.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.general.loghandler import split_data, check_completed
|
||||||
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
|
||||||
@@ -37,6 +39,8 @@ def keyboardinterrupthandler(signum, frame):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
read_config()
|
read_config()
|
||||||
|
logs = get_download_logs()
|
||||||
|
count, downloads = split_data(logs)
|
||||||
if args.debug:
|
if args.debug:
|
||||||
state.debug = args.debug # override of read_config
|
state.debug = args.debug # override of read_config
|
||||||
if state.debug:
|
if state.debug:
|
||||||
@@ -45,6 +49,7 @@ if __name__ == "__main__":
|
|||||||
signal.signal(signal.SIGINT, keyboardinterrupthandler)
|
signal.signal(signal.SIGINT, keyboardinterrupthandler)
|
||||||
run_thread(threading.Thread(target=send_notification, args=(shutdown_event,), daemon=True))
|
run_thread(threading.Thread(target=send_notification, args=(shutdown_event,), daemon=True))
|
||||||
run_thread(threading.Thread(target=update_log, args=(shutdown_event,), daemon=True))
|
run_thread(threading.Thread(target=update_log, args=(shutdown_event,), daemon=True))
|
||||||
|
run_thread(threading.Thread(target=check_completed, args=(downloads, state.autoresume)))
|
||||||
if state.debug:
|
if state.debug:
|
||||||
print("Launching GUI")
|
print("Launching GUI")
|
||||||
run_gui()
|
run_gui()
|
||||||
|
|||||||
Reference in New Issue
Block a user