Skip to content

Commit 37c14ca

Browse files
22.10.15 - Added version checker for FCSViewer.
1 parent 36bf3df commit 37c14ca

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

FCSViewer.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def __init__(self, viewer_pid: int, document_operator: DocumentBuilder):
2222
self.viewer_url = '127.0.0.1'
2323
self.viewer_request_url = f'http://{self.viewer_url}:{self.viewer_id}/toFrontend'
2424
self.platform = platform
25-
self.is_available = self.has_active_viewer() # ToDo: Have some method to ping the frontend
25+
self.is_available = self.has_active_viewer()
26+
self.is_viewer_compatible = self.has_compatible_viewer()
2627
self.document_operator = document_operator
2728
self.published_object_counter = 0
2829
self.plugin_name = "FCSPythonProject"
@@ -69,6 +70,27 @@ def is_port_in_use(port: int) -> bool:
6970
print(f"has_active_viewer failed: {ex}. Will assume no Viewer is connected!")
7071
return False
7172

73+
def has_compatible_viewer(self) -> bool:
74+
"""
75+
If a viewer instance was found, we check if its version
76+
is in coherence with the backend's version.
77+
"""
78+
79+
from PyFCS import check_api_compatibility
80+
from PyFCS import get_backend_api_version
81+
82+
if not self.is_available: return False
83+
84+
response = requests.get(f"http://{self.viewer_url}:{self.viewer_id}/version")
85+
86+
viewer_version = response.text
87+
if not check_api_compatibility(viewer_version):
88+
print(f"!!! Viewer instance version ({viewer_version}) is not compatible with current backend API version ({get_backend_api_version()})!!!")
89+
self.is_available = False
90+
91+
return True
92+
93+
7294
def update_viewer(self) -> None:
7395
"""
7496
Updates viewer's document. Will load all added entities to the viewer

0 commit comments

Comments
 (0)