(self, host: SSHHost)
| 454 | pass |
| 455 | |
| 456 | def load_host(self, host: SSHHost): |
| 457 | self.is_loading = True |
| 458 | self._touched_options.clear() |
| 459 | self.current_host = host |
| 460 | self.original_host_state = copy.deepcopy(host) |
| 461 | |
| 462 | if not host: |
| 463 | self._clear_all_fields() |
| 464 | self.is_loading = False |
| 465 | return |
| 466 | |
| 467 | def _safe_set_entry_text(row, text): |
| 468 | try: |
| 469 | if row is not None: |
| 470 | row.set_text(text) |
| 471 | except Exception: |
| 472 | pass |
| 473 | |
| 474 | _safe_set_entry_text( |
| 475 | getattr(self, "patterns_entry", None), " ".join(host.patterns) |
| 476 | ) |
| 477 | _safe_set_entry_text( |
| 478 | getattr(self, "hostname_entry", None), host.get_option("HostName") or "" |
| 479 | ) |
| 480 | _safe_set_entry_text( |
| 481 | getattr(self, "user_entry", None), host.get_option("User") or "" |
| 482 | ) |
| 483 | port_value = host.get_option("Port") or "22" |
| 484 | try: |
| 485 | port_int = int(port_value) if port_value.isdigit() else 22 |
| 486 | if hasattr(self, "port_entry") and self.port_entry: |
| 487 | self.port_entry.set_value(port_int) |
| 488 | except (ValueError, AttributeError): |
| 489 | if hasattr(self, "port_entry") and self.port_entry: |
| 490 | self.port_entry.set_value(22) |
| 491 | _safe_set_entry_text( |
| 492 | getattr(self, "identity_entry", None), host.get_option("IdentityFile") or "" |
| 493 | ) |
| 494 | |
| 495 | forward_agent = host.get_option("ForwardAgent") |
| 496 | try: |
| 497 | if getattr(self, "forward_agent_switch", None) is not None: |
| 498 | self.forward_agent_switch.set_active(forward_agent == "yes") |
| 499 | except Exception: |
| 500 | pass |
| 501 | |
| 502 | _safe_set_entry_text( |
| 503 | getattr(self, "proxy_jump_entry", None), host.get_option("ProxyJump") or "" |
| 504 | ) |
| 505 | _safe_set_entry_text( |
| 506 | getattr(self, "proxy_cmd_entry", None), |
| 507 | host.get_option("ProxyCommand") or "", |
| 508 | ) |
| 509 | _safe_set_entry_text( |
| 510 | getattr(self, "local_forward_entry", None), |
| 511 | host.get_option("LocalForward") or "", |
| 512 | ) |
| 513 | _safe_set_entry_text( |
no test coverage detected