Skip to content

Commit

Permalink
fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mfkrogh committed May 4, 2023
1 parent 2db3d45 commit a8aab30
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/ansys/pyensight/dockerlauncherenshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import os.path
import subprocess
from typing import Any, Optional
from urllib.parse import urlparse
import uuid

try:
Expand Down Expand Up @@ -106,18 +107,22 @@ def __init__(
self._ansys_version = None

if self._enshell_grpc_channel:
if len(self._pim_instance.services) != 3:
if not set(("grpc_private", "http", "ws")).issubset(self._pim_instance.services):
raise RuntimeError(
"If channel is specified, the PIM instance must have a list of length 3 "
+ "containing the appropriate service URIs. It does not."
)
self._service_host_port = {}
# grab the URIs for the 3 required services passed in from PIM
self._service_host_port["grpc_private"] = self._get_host_port(
self._pim_instance.services["grpc_private"].uri()
self._pim_instance.services["grpc_private"].uri
)
self._service_host_port["http"] = self._get_host_port(
self._pim_instance.services["http"].uri
)
self._service_host_port["ws"] = self._get_host_port(
self._pim_instance.services["ws"].uri
)
self._service_host_port["http"] = self._pim_instance.services["http"].uri()
self._service_host_port["ws"] = self._pim_instance.services["ws"].uri()
# for parity, add 'grpc' as a placeholder even though pim use sets up the grpc channel.
# this isn't used in this situation.
self._service_host_port["grpc"] = ("127.0.0.1", -1)
Expand Down Expand Up @@ -427,3 +432,7 @@ def _has_egl(self) -> bool:
return True
except (subprocess.CalledProcessError, FileNotFoundError):
return False

def _get_host_port(self, uri: str) -> tuple:
parse_results = urlparse(uri)
return (parse_results.hostname, parse_results.port)

0 comments on commit a8aab30

Please sign in to comment.