Zeroconf reports system properties (#59)

* Zeroconf.found_clients() now returns dicts of clients, not just hostnames

* Adjustments to distributed_job_manager.py

* Undo config change

* Report system metrics (cpu, os, etc) via zeroconf_server.py

* Zeroconf.found_clients() now returns dicts of clients, not just hostnames

* Adjustments to distributed_job_manager.py

* Undo config change

* Zeroconf.found_clients() now returns dicts of clients, not just hostnames

* Adjustments to distributed_job_manager.py

* Undo config change

* Adjustments to distributed_job_manager.py

* Undo config change

* Rename ZeroconfServer.found_clients() to found_hostnames()
This commit is contained in:
2023-11-04 20:46:27 -05:00
committed by GitHub
parent d3b84c6212
commit 06a613fcc4
9 changed files with 38 additions and 33 deletions

View File

@@ -214,25 +214,14 @@ class MainWindow(QMainWindow):
# Update the Server Info box when a server is changed
self.server_info_hostname.setText(self.current_hostname or "unknown")
if self.current_server_proxy.system_os:
self.server_info_os.setText(f"OS: {self.current_server_proxy.system_os} "
f"{self.current_server_proxy.system_os_version}")
self.server_info_cpu.setText(f"CPU: {self.current_server_proxy.system_cpu} - "
f"{self.current_server_proxy.system_cpu_count} cores")
server_info = ZeroconfServer.get_hostname_properties(self.current_hostname)
if server_info:
self.server_info_os.setText(f"OS: {server_info['system_os']} {server_info['system_os_version']}")
self.server_info_cpu.setText(f"CPU: {server_info['system_cpu']} - {server_info.get('system_cpu_cores')} cores")
else:
self.server_info_os.setText(f"OS: Loading...")
self.server_info_cpu.setText(f"CPU: Loading...")
self.server_info_os.setText(f"OS: Unknown")
self.server_info_cpu.setText(f"CPU: Unknown")
def update_server_info_worker():
server_details = self.current_server_proxy.get_status()
if server_details['hostname'] == self.current_hostname:
self.server_info_os.setText(f"OS: {server_details.get('system_os')} "
f"{server_details.get('system_os_version')}")
self.server_info_cpu.setText(f"CPU: {server_details.get('system_cpu')} - "
f"{server_details.get('cpu_count')} cores")
update_thread = threading.Thread(target=update_server_info_worker)
update_thread.start()
except AttributeError:
pass
@@ -379,7 +368,7 @@ class MainWindow(QMainWindow):
self.image_label.setPixmap(pixmap)
def update_servers(self):
found_servers = list(set(ZeroconfServer.found_clients() + self.added_hostnames))
found_servers = list(set(ZeroconfServer.found_hostnames() + self.added_hostnames))
# Always make sure local hostname is first
current_hostname = socket.gethostname()
if found_servers and found_servers[0] != current_hostname:
@@ -402,7 +391,8 @@ class MainWindow(QMainWindow):
current_server_list.append(self.server_list_view.item(i).text())
for hostname in found_servers:
if hostname not in current_server_list:
image_path = os.path.join(resources_dir(), 'icons', 'Monitor.png')
properties = ZeroconfServer.get_hostname_properties(hostname)
image_path = os.path.join(resources_dir(), 'icons', f"{properties.get('system_os', 'Monitor')}.png")
list_widget = QListWidgetItem(QIcon(image_path), hostname)
self.server_list_view.addItem(list_widget)