mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 09:59:41 +02:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b2522438c |
@@ -13,6 +13,7 @@ from PySide6.QtWidgets import (
|
|||||||
QSpinBox,
|
QSpinBox,
|
||||||
QCheckBox,
|
QCheckBox,
|
||||||
QFileDialog,
|
QFileDialog,
|
||||||
|
QComboBox
|
||||||
)
|
)
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
@@ -56,7 +57,6 @@ def settings_dialog(self):
|
|||||||
|
|
||||||
autoresume_layout.addStretch()
|
autoresume_layout.addStretch()
|
||||||
autoresume_checkbox.setChecked(state.autoresume)
|
autoresume_checkbox.setChecked(state.autoresume)
|
||||||
autoresume_checkbox.toggled.connect(lambda checked: setattr(state, 'autoresume', checked))
|
|
||||||
autoresume_layout.addWidget(autoresume_checkbox)
|
autoresume_layout.addWidget(autoresume_checkbox)
|
||||||
dialog.layout().addWidget(autoresume_container)
|
dialog.layout().addWidget(autoresume_container)
|
||||||
|
|
||||||
@@ -206,6 +206,35 @@ def settings_dialog(self):
|
|||||||
max_downloads.setFixedHeight(30)
|
max_downloads.setFixedHeight(30)
|
||||||
dialog.layout().addWidget(max_downloads_container)
|
dialog.layout().addWidget(max_downloads_container)
|
||||||
|
|
||||||
|
#####################
|
||||||
|
# INTERFACE BINDING #
|
||||||
|
#####################
|
||||||
|
|
||||||
|
interface_container = QWidget()
|
||||||
|
interface_layout = QHBoxLayout()
|
||||||
|
|
||||||
|
interface_label = QLabel("Network Interface:")
|
||||||
|
interface_layout.addWidget(interface_label)
|
||||||
|
interface_select = QComboBox()
|
||||||
|
interface_select.addItems(["None"] + state.interfaces)
|
||||||
|
|
||||||
|
target = state.bound_interface if state.bound_interface else "None"
|
||||||
|
|
||||||
|
index = interface_select.findText(target)
|
||||||
|
if index >= 0:
|
||||||
|
interface_select.setCurrentIndex(index)
|
||||||
|
else:
|
||||||
|
interface_select.setCurrentIndex(0)
|
||||||
|
|
||||||
|
interface_select.setFixedWidth(180)
|
||||||
|
interface_select.setFixedHeight(30)
|
||||||
|
interface_select.setFixedWidth(180)
|
||||||
|
interface_select.setFixedHeight(30)
|
||||||
|
interface_layout.addWidget(interface_select)
|
||||||
|
interface_container.setLayout(interface_layout)
|
||||||
|
dialog.layout().addWidget(interface_container)
|
||||||
|
|
||||||
|
|
||||||
###############
|
###############
|
||||||
# SAVE/CANCEL #
|
# SAVE/CANCEL #
|
||||||
###############
|
###############
|
||||||
@@ -214,7 +243,17 @@ def settings_dialog(self):
|
|||||||
|
|
||||||
save_btn = QPushButton("Save")
|
save_btn = QPushButton("Save")
|
||||||
cancel_btn = QPushButton("Cancel")
|
cancel_btn = QPushButton("Cancel")
|
||||||
save_btn.clicked.connect(lambda: save_settings(close_settings, api_url.text(), download_path.text(), down_speed_limit.value(), up_speed_limit.value(), image_path.text(), None, max_connections.value(), max_downloads.value()))
|
save_btn.clicked.connect(lambda: save_settings(
|
||||||
|
close_settings,
|
||||||
|
api_url.text(),
|
||||||
|
download_path.text(),
|
||||||
|
down_speed_limit.value(),
|
||||||
|
up_speed_limit.value(),
|
||||||
|
image_path.text(),
|
||||||
|
autoresume_checkbox.isChecked(),
|
||||||
|
max_connections.value(),
|
||||||
|
max_downloads.value(),
|
||||||
|
interface_select.currentText()))
|
||||||
|
|
||||||
cancel_btn.clicked.connect(dialog.reject)
|
cancel_btn.clicked.connect(dialog.reject)
|
||||||
layout.addWidget(cancel_btn)
|
layout.addWidget(cancel_btn)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from core.utils.general.logs import consoleLog
|
|||||||
from .config import create_config
|
from .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):
|
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):
|
||||||
if apiurl is not None:
|
if apiurl is not None:
|
||||||
state.api_url = apiurl
|
state.api_url = apiurl
|
||||||
if download_path is not None:
|
if download_path is not None:
|
||||||
@@ -21,6 +21,8 @@ def save_settings(close=lambda: None, apiurl=None, download_path=None, down_spee
|
|||||||
state.max_connections = max_connections
|
state.max_connections = max_connections
|
||||||
if max_downloads is not None:
|
if max_downloads is not None:
|
||||||
state.max_downloads = max_downloads
|
state.max_downloads = max_downloads
|
||||||
|
if bound_interface is not None:
|
||||||
|
state.bound_interface = None if bound_interface == "None" else bound_interface
|
||||||
|
|
||||||
|
|
||||||
update_settings()
|
update_settings()
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ if __name__ == "__main__":
|
|||||||
init_interfaces()
|
init_interfaces()
|
||||||
consoleLog(f"Current Bound: {state.bound_interface}")
|
consoleLog(f"Current Bound: {state.bound_interface}")
|
||||||
run_thread(threading.Thread(target=send_notification, args=(shutdown_event,), daemon=True))
|
run_thread(threading.Thread(target=send_notification, args=(shutdown_event,), daemon=True))
|
||||||
consoleLog("Started send_notification thread")
|
consoleLog("Started Thread: send_notification")
|
||||||
run_thread(threading.Thread(target=update_log, args=(shutdown_event,), daemon=True))
|
run_thread(threading.Thread(target=update_log, args=(shutdown_event,), daemon=True))
|
||||||
consoleLog("Started update_log thread")
|
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("Launching GUI")
|
consoleLog("Launching GUI")
|
||||||
run_gui()
|
run_gui()
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
import psutil
|
|
||||||
|
|
||||||
addrs = psutil.net_if_addrs()
|
|
||||||
stats = psutil.net_if_stats()
|
|
||||||
|
|
||||||
|
|
||||||
def get_active_interfaces():
|
|
||||||
active = []
|
|
||||||
|
|
||||||
for interface, addr_list in addrs.items():
|
|
||||||
up = stats[interface].isup
|
|
||||||
for addr in addr_list:
|
|
||||||
if addr.family == 2: # ipv4
|
|
||||||
ipv4 = addr.address
|
|
||||||
if not ipv4.startswith("127.") and not ipv4.startswith("169.254") and up == True:
|
|
||||||
print(f'"{interface}": True')
|
|
||||||
active.append(interface)
|
|
||||||
print(active)
|
|
||||||
return active
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print(list(addrs.keys()))
|
|
||||||
|
|
||||||
# print(addrs)
|
|
||||||
# print()
|
|
||||||
# sigmer = list()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# for interface in stats.keys():
|
|
||||||
# print(f"{interface}: UP = {stats[interface].isup}")
|
|
||||||
# sigmer.append(f"{interface}: {stats[interface].isup}")
|
|
||||||
|
|
||||||
# print(sigmer)
|
|
||||||
Reference in New Issue
Block a user