Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/ansys/pyensight/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def populate_service_host_port( # pragma: no cover


def launch_enshell_interface(
enshell_grpc_channel: Any, grpc_port: int, timeout: float
enshell_grpc_channel: Any, grpc_port: int, timeout: float, secret_key: str
) -> enshell_grpc.EnShellGRPC:
"""Launch the EnShell gRPC Interface.

Expand All @@ -186,9 +186,11 @@ def launch_enshell_interface(
"""
if enshell_grpc_channel: # pragma: no cover
enshell = enshell_grpc.EnShellGRPC() # pragma: no cover
enshell.set_security_token(secret_key)
enshell.connect_existing_channel(enshell_grpc_channel) # pragma: no cover
else:
enshell = enshell_grpc.EnShellGRPC(port=grpc_port)
enshell.set_security_token(secret_key)
time_start = time.time()
while time.time() - time_start < timeout: # pragma: no cover
if enshell.is_connected():
Expand Down
5 changes: 4 additions & 1 deletion src/ansys/pyensight/core/dockerlauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,10 @@ def connect(self):
#
# Start up the EnShell gRPC interface
self._enshell = launch_enshell_interface(
self._enshell_grpc_channel, self._service_host_port["grpc"][1], self._timeout
self._enshell_grpc_channel,
self._service_host_port["grpc"][1],
self._timeout,
self._secret_key,
)
log_dir = "/data"
if self._enshell_grpc_channel: # pragma: no cover
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/pyensight/core/enshell_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(
self._stub = None
#
# self._security_token = str(random.randint(0, 1000000))
self._security_token: Optional[int] = None
self._security_token: Optional[str] = None
#
# values found from EnShell in the Container
self._cei_home = None
Expand Down Expand Up @@ -80,7 +80,7 @@ def port(self):
"""
return self._port

def set_security_token(self, n: Optional[int] = None):
def set_security_token(self, n: Optional[str] = None):
"""set the security token for the gRPC connection.

EnShell supports a security token in either numeric (-security {int}) or
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def docker_launcher_session() -> "Session":
@pytest.fixture
def enshell_mock():
mocked_grpc = mock.MagicMock("GRPC")
mocked_grpc.set_security_token = lambda secret: True
mocked_grpc.command = mock.MagicMock("command")
mocked_grpc.is_connected = lambda: True
mocked_grpc.connect = mock.MagicMock("execute_connection")
Expand Down