mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-05-31 10:28:38 +02:00
refactor: move start and start_server to private
This commit is contained in:
@@ -200,7 +200,7 @@ class BECGuiClient(RPCBase):
|
||||
return None
|
||||
|
||||
@property
|
||||
def selected_device(self):
|
||||
def selected_device(self) -> str | None:
|
||||
"""
|
||||
Selected device for the plot.
|
||||
"""
|
||||
@@ -256,7 +256,7 @@ class BECGuiClient(RPCBase):
|
||||
self._do_show_all()
|
||||
self._gui_started_event.set()
|
||||
|
||||
def start_server(self, wait=False) -> None:
|
||||
def _start_server(self, wait=False) -> None:
|
||||
"""
|
||||
Start the GUI server, and execute callback when it is launched
|
||||
"""
|
||||
@@ -287,8 +287,12 @@ class BECGuiClient(RPCBase):
|
||||
rpc_client = RPCBase(gui_id=f"{self._gui_id}:window", parent=self)
|
||||
return rpc_client._run_rpc("_dump")
|
||||
|
||||
def _start(self):
|
||||
return self._start_server()
|
||||
|
||||
def start(self):
|
||||
return self.start_server()
|
||||
# FIXME keeping backwards compatibility for now
|
||||
return self._start()
|
||||
|
||||
def _do_show_all(self):
|
||||
rpc_client = RPCBase(gui_id=f"{self._gui_id}:window", parent=self)
|
||||
@@ -311,7 +315,7 @@ class BECGuiClient(RPCBase):
|
||||
if self._process is not None:
|
||||
return self.show_all()
|
||||
# backward compatibility: show() was also starting server
|
||||
return self.start_server(wait=True)
|
||||
return self._start_server(wait=True)
|
||||
|
||||
def hide(self):
|
||||
return self.hide_all()
|
||||
|
||||
@@ -49,7 +49,7 @@ def connected_client_figure(gui_id, bec_client_lib):
|
||||
def connected_client_gui_obj(gui_id, bec_client_lib):
|
||||
gui = BECGuiClient(gui_id=gui_id)
|
||||
try:
|
||||
gui.start_server(wait=True)
|
||||
gui._start_server(wait=True)
|
||||
yield gui
|
||||
finally:
|
||||
gui.close()
|
||||
@@ -60,7 +60,7 @@ def connected_client_dock(gui_id, bec_client_lib):
|
||||
gui = BECGuiClient(gui_id=gui_id)
|
||||
gui._auto_updates_enabled = False
|
||||
try:
|
||||
gui.start_server(wait=True)
|
||||
gui._start_server(wait=True)
|
||||
yield gui.main
|
||||
finally:
|
||||
gui.close()
|
||||
@@ -70,7 +70,7 @@ def connected_client_dock(gui_id, bec_client_lib):
|
||||
def connected_client_dock_w_auto_updates(gui_id, bec_client_lib):
|
||||
gui = BECGuiClient(gui_id=gui_id)
|
||||
try:
|
||||
gui.start_server(wait=True)
|
||||
gui._start_server(wait=True)
|
||||
yield gui, gui.main
|
||||
finally:
|
||||
gui.close()
|
||||
|
||||
@@ -342,10 +342,10 @@ def test_rpc_gui_obj(connected_client_gui_obj, qtbot):
|
||||
assert gui.gui_is_alive()
|
||||
gui.close()
|
||||
assert not gui.gui_is_alive()
|
||||
gui.start_server(wait=True)
|
||||
gui._start_server(wait=True)
|
||||
assert gui.gui_is_alive()
|
||||
# calling start multiple times should not change anything
|
||||
gui.start_server(wait=True)
|
||||
gui._start_server(wait=True)
|
||||
gui.start()
|
||||
# gui.windows should have main, and main dock area should have same gui_id as before
|
||||
assert len(gui.windows) == 1
|
||||
|
||||
@@ -77,7 +77,7 @@ def test_client_utils_passes_client_config_to_server(bec_dispatcher):
|
||||
with bec_client_mixin() as mixin:
|
||||
with mock.patch("bec_widgets.cli.client_utils._start_plot_process") as mock_start_plot:
|
||||
mock_start_plot.return_value = [mock.MagicMock(), mock.MagicMock()]
|
||||
mixin.start_server(
|
||||
mixin._start_server(
|
||||
wait=False
|
||||
) # the started event will not be set, wait=True would block forever
|
||||
mock_start_plot.assert_called_once_with(
|
||||
|
||||
Reference in New Issue
Block a user