Skip to content

Commit 7ecd8f1

Browse files
HugoCLSCdependabot[bot]Robert0MartRobertogmmcosta15
authored
Patch GUI blocking & Additional load messages (#176)
* ADD: Additional load messages (#169) Co-authored-by: Roberto <roberto.martins@blockstec.com> * Refactor `NetworkWindow` (#174) * refactor: change network list to listview * Refactor: Refac to MVC view with Controller being runnables on a threadpoll * UPD: Regenerated icon_resources_rc * networkWindow.py: refactor to include listview wifiConnectivityWindow.ui: change horizontalLayout to a vertical layout with a listview and a vertical scrollbar wifiConnectivityWindow.py: generated file from QtDesigner with some optimizations Signed-off-by: Guilherme Costa <guiherme.costa@blockstec.com> * networkWindow: rebase merge conflits fix and cleanup Signed-off-by: Guilherme Costa <guiherme.costa@blockstec.com> * networkWindow.py: added missing right icon Signed-off-by: Guilherme Costa <guiherme.costa@blockstec.com> * Fix typo * networkWindow.py: optimize and bugfix on self.paths Signed-off-by: Guilherme Costa <guiherme.costa@blockstec.com> * networkWindow.py: comments cleanup * networkWindow.py: fix missing formatting * Revert accidental changes to requirements.txt * networkwindo.py: between 5 and 25 show only one bar icon * bugfix: fixed wrong imports * bugfix: wrong button name * resolve merge conflits * add missing docstrings * add missing docstrings * separation between saved and unsaved network and update code * refactor network window file * Add hidden network page, fix scrollbar behaviour at borders remove the need to use wificonnectivitywindow_ui * cleanup of unused code * fix code formatation * changed QtWidgets.QApplication.processEvents for repaint * delete unused files * fix formatting issues and logic to parse sensors * fix code formatation --------- Signed-off-by: Guilherme Costa <guiherme.costa@blockstec.com> Co-authored-by: Roberto Martins <robertomicael.martins@gmail.com> Co-authored-by: Guilherme Costa <guiherme.costa@blockstec.com> Co-authored-by: HugoCLSC <hugo.santos.costa@gmail.com> Co-authored-by: Roberto <roberto.martins@blockstec.com> * Fix incorrect file removal (#177) --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Hugo Costa <hugo.santos.costa@gmail.com> Signed-off-by: Guilherme Costa <guiherme.costa@blockstec.com> Signed-off-by: gmmcosta15 <guilherme.costa@blockstec.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Roberto Martins <robertomicael.martins@gmail.com> Co-authored-by: Roberto <roberto.martins@blockstec.com> Co-authored-by: Guilherme Costa <guilherme.costa@blockstec.com> Co-authored-by: Guilherme Costa <guiherme.costa@blockstec.com>
1 parent 5feef9b commit 7ecd8f1

22 files changed

Lines changed: 4774 additions & 5740 deletions

BlocksScreen/lib/network.py

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,15 @@ def get_wired_interfaces(self) -> typing.List[dbusNm.NetworkDeviceWired]:
354354
filter(
355355
lambda path: path,
356356
filter(
357-
lambda device: asyncio.run_coroutine_threadsafe(
358-
dbusNm.NetworkDeviceGeneric(
359-
bus=self.system_dbus, device_path=device
360-
).device_type.get_async(),
361-
self.loop,
362-
).result(timeout=2)
363-
== dbusNm.enums.DeviceType.ETHERNET,
357+
lambda device: (
358+
asyncio.run_coroutine_threadsafe(
359+
dbusNm.NetworkDeviceGeneric(
360+
bus=self.system_dbus, device_path=device
361+
).device_type.get_async(),
362+
self.loop,
363+
).result(timeout=2)
364+
== dbusNm.enums.DeviceType.ETHERNET
365+
),
364366
devices,
365367
),
366368
),
@@ -386,13 +388,15 @@ def get_wireless_interfaces(
386388
filter(
387389
lambda path: path,
388390
filter(
389-
lambda device: asyncio.run_coroutine_threadsafe(
390-
dbusNm.NetworkDeviceGeneric(
391-
bus=self.system_dbus, device_path=device
392-
).device_type.get_async(),
393-
self.loop,
394-
).result(timeout=3)
395-
== dbusNm.enums.DeviceType.WIFI,
391+
lambda device: (
392+
asyncio.run_coroutine_threadsafe(
393+
dbusNm.NetworkDeviceGeneric(
394+
bus=self.system_dbus, device_path=device
395+
).device_type.get_async(),
396+
self.loop,
397+
).result(timeout=3)
398+
== dbusNm.enums.DeviceType.WIFI
399+
),
396400
devices,
397401
),
398402
),
@@ -472,6 +476,68 @@ def get_current_ip_addr(self) -> str:
472476
return [address_data["address"][1] for address_data in addr_data][0]
473477
except IndexError as e:
474478
logger.error("List out of index %s", e)
479+
except Exception as e:
480+
logger.error("Error getting current IP address: %s", e)
481+
return ""
482+
483+
def get_device_ip_by_interface(self, interface_name: str = "wlan0") -> str:
484+
"""Get IPv4 address for a specific interface via NetworkManager D-Bus.
485+
486+
This method retrieves the IP address directly from a specific network
487+
interface, useful for getting hotspot IP when it's the active connection
488+
on that interface.
489+
490+
Args:
491+
interface_name: The network interface name (e.g., "wlan0", "eth0")
492+
493+
Returns:
494+
str: The IPv4 address or empty string if not found
495+
"""
496+
if not self.nm:
497+
return ""
498+
499+
try:
500+
devices_future = asyncio.run_coroutine_threadsafe(
501+
self.nm.get_devices(), self.loop
502+
)
503+
devices = devices_future.result(timeout=2)
504+
505+
for device_path in devices:
506+
device = dbusNm.NetworkDeviceGeneric(
507+
bus=self.system_dbus, device_path=device_path
508+
)
509+
510+
# Check if this is the interface we want
511+
iface_future = asyncio.run_coroutine_threadsafe(
512+
device.interface.get_async(), self.loop
513+
)
514+
iface = iface_future.result(timeout=2)
515+
516+
if iface != interface_name:
517+
continue
518+
519+
# Get IP4Config path
520+
ip4_path_future = asyncio.run_coroutine_threadsafe(
521+
device.ip4_config.get_async(), self.loop
522+
)
523+
ip4_path = ip4_path_future.result(timeout=2)
524+
525+
if not ip4_path or ip4_path == "/":
526+
return ""
527+
528+
# Get address data
529+
ip4_config = dbusNm.IPv4Config(bus=self.system_dbus, ip4_path=ip4_path)
530+
addr_data_future = asyncio.run_coroutine_threadsafe(
531+
ip4_config.address_data.get_async(), self.loop
532+
)
533+
addr_data = addr_data_future.result(timeout=2)
534+
535+
if addr_data and len(addr_data) > 0:
536+
return addr_data[0]["address"][1]
537+
538+
except Exception as e:
539+
logger.error("Failed to get IP for interface %s: %s", interface_name, e)
540+
475541
return ""
476542

477543
async def _gather_primary_interface(
@@ -821,7 +887,7 @@ def get_saved_ssid_names(self) -> typing.List[str]:
821887
return []
822888
return list(
823889
map(
824-
lambda saved_network: (saved_network.get("ssid", None)),
890+
lambda saved_network: saved_network.get("ssid", None),
825891
_saved_networks,
826892
)
827893
)

BlocksScreen/lib/panels/controlTab.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def __init__(
9999
self.probe_helper_page.subscribe_config[list, "PyQt_PyObject"].connect(
100100
self.printer.on_subscribe_config
101101
)
102+
self.printer.extruder_update.connect(self.probe_helper_page.on_extruder_update)
102103
self.printer.gcode_move_update.connect(
103104
self.probe_helper_page.on_gcode_move_update
104105
)

0 commit comments

Comments
 (0)