Skip to content

Commit 19e2394

Browse files
committed
fix(server): skip call on protocol if not present
1 parent df46242 commit 19e2394

File tree

1 file changed

+36
-22
lines changed

1 file changed

+36
-22
lines changed

trame_vtk/widgets/vtk/common.py

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -500,14 +500,16 @@ def update_geometry(
500500
if widgets is None:
501501
widgets = self._widgets
502502

503-
if self.server.protocol:
504-
delta_state = self._helper.scene(
505-
self.__view,
506-
new_state=False,
507-
widgets=widgets,
508-
orientation_axis=orientation_axis,
509-
)
510-
self.server.protocol.publish("trame.vtk.delta", delta_state)
503+
if not self.server.protocol:
504+
return
505+
506+
delta_state = self._helper.scene(
507+
self.__view,
508+
new_state=False,
509+
widgets=widgets,
510+
orientation_axis=orientation_axis,
511+
)
512+
self.server.protocol.publish("trame.vtk.delta", delta_state)
511513

512514
full_state = self._helper.scene(
513515
self.__view,
@@ -527,12 +529,14 @@ def export_geometry(self, widgets=None, orientation_axis=0, format="zip", **kwar
527529
if widgets is None:
528530
widgets = self._widgets
529531

530-
if self.server.protocol:
531-
encoded_data = self._helper.export(
532-
self.__view,
533-
widgets=widgets,
534-
orientation_axis=orientation_axis,
535-
)
532+
if not self.server.protocol:
533+
return
534+
535+
encoded_data = self._helper.export(
536+
self.__view,
537+
widgets=widgets,
538+
orientation_axis=orientation_axis,
539+
)
536540

537541
if encoded_data:
538542
json_out = json.dumps(encoded_data)
@@ -549,7 +553,8 @@ def update_image(self, reset_camera=False):
549553
"""
550554
Force update to image
551555
"""
552-
self._helper.push_image(self.__view, reset_camera)
556+
if self.server.protocol:
557+
self._helper.push_image(self.__view, reset_camera)
553558

554559
def set_local_rendering(self, local=True, **kwargs):
555560
self.server.state[self.__mode_key] = "local" if local else "remote"
@@ -753,9 +758,13 @@ def update(self, **kwargs):
753758
"""
754759
Force image to be pushed to client
755760
"""
756-
self._helper.push_image(self.__view)
761+
if self.server.protocol:
762+
self._helper.push_image(self.__view)
757763

758764
def start_animation(self, fps=30, quality=100, ratio=1):
765+
if not self.server.protocol:
766+
return
767+
759768
if self._is_animating:
760769
return
761770

@@ -764,6 +773,9 @@ def start_animation(self, fps=30, quality=100, ratio=1):
764773
self._helper.start_animation(self.__view, fps, quality, ratio)
765774

766775
def stop_animation(self):
776+
if not self.server.protocol:
777+
return
778+
767779
if not self._is_animating:
768780
return
769781

@@ -961,12 +973,14 @@ def export(self, widgets=None, orientation_axis=0, format="zip", **kwargs):
961973
if widgets is None:
962974
widgets = self._widgets
963975

964-
if self.server.protocol:
965-
encoded_data = self._helper.export(
966-
self.__view,
967-
widgets=widgets,
968-
orientation_axis=orientation_axis,
969-
)
976+
if not self.server.protocol:
977+
return
978+
979+
encoded_data = self._helper.export(
980+
self.__view,
981+
widgets=widgets,
982+
orientation_axis=orientation_axis,
983+
)
970984

971985
if encoded_data:
972986
json_out = json.dumps(encoded_data)

0 commit comments

Comments
 (0)