ansys-pyensight-core 0.7.7__tar.gz → 0.7.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ansys-pyensight-core might be problematic. Click here for more details.

Files changed (34) hide show
  1. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/PKG-INFO +2 -2
  2. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/pyproject.toml +2 -2
  3. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/dockerlauncher.py +52 -44
  4. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/enscontext.py +17 -15
  5. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/enshell_grpc.py +8 -8
  6. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/ensight_grpc.py +37 -35
  7. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/ensobj.py +4 -4
  8. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/launch_ensight.py +2 -2
  9. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/launcher.py +4 -4
  10. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/listobj.py +18 -16
  11. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/renderable.py +47 -25
  12. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/session.py +33 -29
  13. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/utils/export.py +9 -9
  14. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/utils/omniverse.py +59 -24
  15. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/utils/omniverse_dsg_server.py +43 -5
  16. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/utils/parts.py +50 -36
  17. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/utils/query.py +41 -35
  18. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/utils/variables.py +256 -225
  19. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/utils/views.py +14 -14
  20. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/LICENSE +0 -0
  21. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/README.rst +0 -0
  22. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/__init__.py +0 -0
  23. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/deep_pixel_view.html +0 -0
  24. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/locallauncher.py +0 -0
  25. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/py.typed +0 -0
  26. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/sgeo_poll.html +0 -0
  27. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/utils/__init__.py +0 -0
  28. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/utils/adr.py +0 -0
  29. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/utils/resources/Materials/000_sky.exr +0 -0
  30. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/utils/resources/Materials/Fieldstone/Fieldstone_BaseColor.png +0 -0
  31. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/utils/resources/Materials/Fieldstone/Fieldstone_N.png +0 -0
  32. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/utils/resources/Materials/Fieldstone/Fieldstone_ORM.png +0 -0
  33. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/utils/resources/Materials/Fieldstone.mdl +0 -0
  34. {ansys_pyensight_core-0.7.7 → ansys_pyensight_core-0.7.9}/src/ansys/pyensight/core/utils/support.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ansys-pyensight-core
3
- Version: 0.7.7
3
+ Version: 0.7.9
4
4
  Summary: A python wrapper for Ansys EnSight
5
5
  Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
6
6
  Maintainer-email: "ANSYS, Inc." <pyansys.core@ansys.com>
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Requires-Dist: importlib-metadata>=4.0; python_version<='3.8'
19
- Requires-Dist: ansys-api-pyensight==0.3.7
19
+ Requires-Dist: ansys-api-pyensight==0.3.9
20
20
  Requires-Dist: requests>=2.28.2
21
21
  Requires-Dist: docker>=6.1.0
22
22
  Requires-Dist: urllib3<2
@@ -6,7 +6,7 @@ build-backend = "flit_core.buildapi"
6
6
 
7
7
  [project]
8
8
  name = "ansys-pyensight-core"
9
- version = "0.7.7"
9
+ version = "0.7.9"
10
10
  description = "A python wrapper for Ansys EnSight"
11
11
  readme = "README.rst"
12
12
  requires-python = ">=3.9,<4"
@@ -27,7 +27,7 @@ classifiers = [
27
27
 
28
28
  dependencies = [
29
29
  "importlib-metadata>=4.0; python_version<='3.8'",
30
- "ansys-api-pyensight==0.3.7",
30
+ "ansys-api-pyensight==0.3.9",
31
31
  "requests>=2.28.2",
32
32
  "docker>=6.1.0",
33
33
  "urllib3<2",
@@ -171,8 +171,10 @@ class DockerLauncher(Launcher):
171
171
  # EnShell gRPC port, EnSight gRPC port, HTTP port, WSS port
172
172
  # skip 1999 as that internal to the container is used to the container for the VNC connection
173
173
  ports = self._find_unused_ports(4, avoid=[1999])
174
- if ports is None:
175
- raise RuntimeError("Unable to allocate local ports for EnSight session")
174
+ if ports is None: # pragma: no cover
175
+ raise RuntimeError(
176
+ "Unable to allocate local ports for EnSight session"
177
+ ) # pragma: no cover
176
178
  self._service_host_port = {}
177
179
  self._service_host_port["grpc"] = ("127.0.0.1", ports[0])
178
180
  self._service_host_port["grpc_private"] = ("127.0.0.1", ports[1])
@@ -218,7 +220,7 @@ class DockerLauncher(Launcher):
218
220
 
219
221
  """
220
222
  try:
221
- if self._docker_client is not None:
223
+ if self._docker_client is not None: # pragma: no cover
222
224
  self._docker_client.images.pull(self._image_name)
223
225
  except Exception:
224
226
  raise RuntimeError(f"Can't pull Docker image: {self._image_name}")
@@ -316,9 +318,9 @@ class DockerLauncher(Launcher):
316
318
 
317
319
  logging.debug("Starting Container...\n")
318
320
  if data_volume:
319
- if use_egl:
321
+ if use_egl: # pragma: no cover
320
322
  if self._docker_client:
321
- self._container = self._docker_client.containers.run(
323
+ self._container = self._docker_client.containers.run( # pragma: no cover
322
324
  self._image_name,
323
325
  command=enshell_cmd,
324
326
  volumes=data_volume,
@@ -349,8 +351,8 @@ class DockerLauncher(Launcher):
349
351
  )
350
352
  logging.debug(f"_container = {str(self._container)}\n")
351
353
  else:
352
- if use_egl:
353
- if self._docker_client:
354
+ if use_egl: # pragma: no cover
355
+ if self._docker_client: # pragma: no cover
354
356
  self._container = self._docker_client.containers.run(
355
357
  self._image_name,
356
358
  command=enshell_cmd,
@@ -364,11 +366,13 @@ class DockerLauncher(Launcher):
364
366
  auto_remove=True,
365
367
  remove=True,
366
368
  )
367
- else:
368
- logging.debug(f"Running container {self._image_name} with cmd {enshell_cmd}\n")
369
- logging.debug(f"ports to map: {ports_to_map}\n")
370
- if self._docker_client:
371
- self._container = self._docker_client.containers.run(
369
+ else: # pragma: no cover
370
+ logging.debug(
371
+ f"Running container {self._image_name} with cmd {enshell_cmd}\n"
372
+ ) # pragma: no cover
373
+ logging.debug(f"ports to map: {ports_to_map}\n") # pragma: no cover
374
+ if self._docker_client: # pragma: no cover
375
+ self._container = self._docker_client.containers.run( # pragma: no cover
372
376
  self._image_name,
373
377
  command=enshell_cmd,
374
378
  environment=container_env,
@@ -412,17 +416,17 @@ class DockerLauncher(Launcher):
412
416
  )
413
417
  self._enshell = enshell_grpc.EnShellGRPC(port=self._service_host_port["grpc"][1])
414
418
  time_start = time.time()
415
- while time.time() - time_start < self._timeout:
419
+ while time.time() - time_start < self._timeout: # pragma: no cover
416
420
  if self._enshell.is_connected():
417
421
  break
418
422
  try:
419
423
  self._enshell.connect(timeout=self._timeout)
420
- except OSError:
421
- pass
424
+ except OSError: # pragma: no cover
425
+ pass # pragma: no cover
422
426
 
423
- if not self._enshell.is_connected():
424
- self.stop()
425
- raise RuntimeError("Can't connect to EnShell over gRPC.")
427
+ if not self._enshell.is_connected(): # pragma: no cover
428
+ self.stop() # pragma: no cover
429
+ raise RuntimeError("Can't connect to EnShell over gRPC.") # pragma: no cover
426
430
 
427
431
  cmd = "set_no_reroute_log"
428
432
  ret = self._enshell.run_command(cmd)
@@ -432,7 +436,7 @@ class DockerLauncher(Launcher):
432
436
  raise RuntimeError(f"Error sending EnShell command: {cmd} ret: {ret}")
433
437
 
434
438
  files_to_try = [log_dir + "/enshell.log", "/home/ensight/enshell.log"]
435
- for f in files_to_try:
439
+ for f in files_to_try: # pragma: no cover
436
440
  cmd = "set_debug_log " + f
437
441
  ret = self._enshell.run_command(cmd)
438
442
  if ret[0] == 0:
@@ -441,15 +445,17 @@ class DockerLauncher(Launcher):
441
445
  else:
442
446
  logging.debug(f"enshell error; cmd: {cmd} ret: {ret}\n")
443
447
 
444
- if self._enshell_log_file is not None:
448
+ if self._enshell_log_file is not None: # pragma: no cover
445
449
  logging.debug(f"enshell log file {self._enshell_log_file}\n")
446
450
 
447
451
  cmd = "verbose 3"
448
452
  ret = self._enshell.run_command(cmd)
449
453
  logging.debug(f"enshell cmd: {cmd} ret: {ret}\n")
450
- if ret[0] != 0:
451
- self.stop()
452
- raise RuntimeError(f"Error sending EnShell command: {cmd} ret: {ret}")
454
+ if ret[0] != 0: # pragma: no cover
455
+ self.stop() # pragma: no cover
456
+ raise RuntimeError(
457
+ f"Error sending EnShell command: {cmd} ret: {ret}"
458
+ ) # pragma: no cover
453
459
 
454
460
  logging.debug("Connected to EnShell. Getting CEI_HOME and Ansys version...\n")
455
461
  logging.debug(f" _enshell: {self._enshell}\n\n")
@@ -473,16 +479,16 @@ class DockerLauncher(Launcher):
473
479
 
474
480
  # Run EnSight
475
481
  ensight_env_vars = None
476
- if container_env_str != "":
477
- ensight_env_vars = container_env_str
482
+ if container_env_str != "": # pragma: no cover
483
+ ensight_env_vars = container_env_str # pragma: no cover
478
484
 
479
485
  if use_egl:
480
- if ensight_env_vars is None:
486
+ if ensight_env_vars is None: # pragma: no cover
481
487
  ensight_env_vars = (
482
488
  "LD_PRELOAD=/usr/local/lib64/libGL.so.1:/usr/local/lib64/libEGL.so.1"
483
489
  )
484
490
  else:
485
- ensight_env_vars += (
491
+ ensight_env_vars += ( # pragma: no cover
486
492
  "LD_PRELOAD=/usr/local/lib64/libGL.so.1:/usr/local/lib64/libEGL.so.1"
487
493
  )
488
494
 
@@ -501,9 +507,11 @@ class DockerLauncher(Launcher):
501
507
 
502
508
  logging.debug(f"Starting EnSight with args: {ensight_args}\n")
503
509
  ret = self._enshell.start_ensight(ensight_args, ensight_env_vars)
504
- if ret[0] != 0:
505
- self.stop()
506
- raise RuntimeError(f"Error starting EnSight with args: {ensight_args}")
510
+ if ret[0] != 0: # pragma: no cover
511
+ self.stop() # pragma: no cover
512
+ raise RuntimeError(
513
+ f"Error starting EnSight with args: {ensight_args}"
514
+ ) # pragma: no cover
507
515
 
508
516
  logging.debug("EnSight started. Starting wss...\n")
509
517
 
@@ -534,14 +542,14 @@ class DockerLauncher(Launcher):
534
542
  wss_cmd += " --local_session envision 5"
535
543
 
536
544
  wss_env_vars = None
537
- if container_env_str != "":
538
- wss_env_vars = container_env_str
545
+ if container_env_str != "": # pragma: no cover
546
+ wss_env_vars = container_env_str # pragma: no cover
539
547
 
540
548
  logging.debug(f"Starting WSS: {wss_cmd}\n")
541
549
  ret = self._enshell.start_other(wss_cmd, extra_env=wss_env_vars)
542
- if ret[0] != 0:
543
- self.stop()
544
- raise RuntimeError(f"Error starting WSS: {wss_cmd}\n")
550
+ if ret[0] != 0: # pragma: no cover
551
+ self.stop() # pragma: no cover
552
+ raise RuntimeError(f"Error starting WSS: {wss_cmd}\n") # pragma: no cover
545
553
 
546
554
  logging.debug("wss started. Making session...\n")
547
555
 
@@ -578,12 +586,12 @@ class DockerLauncher(Launcher):
578
586
  def stop(self) -> None:
579
587
  """Release any additional resources allocated during launching."""
580
588
  if self._enshell:
581
- if self._enshell.is_connected():
589
+ if self._enshell.is_connected(): # pragma: no cover
582
590
  try:
583
591
  logging.debug("Stopping EnShell.\n")
584
592
  self._enshell.stop_server()
585
- except Exception:
586
- pass
593
+ except Exception: # pragma: no cover
594
+ pass # pragma: no cover
587
595
  self._enshell = None
588
596
  #
589
597
  if self._container:
@@ -640,7 +648,7 @@ class DockerLauncher(Launcher):
640
648
  ``True`` if the system is EGL capable, ``False`` otherwise.
641
649
  """
642
650
  if self._is_windows():
643
- return False
651
+ return False # pragma: no cover
644
652
 
645
653
  # FIXME: MFK, need to figure out how we'd do this
646
654
  # with a PIM managed system such as Ansys Lab
@@ -661,8 +669,8 @@ class DockerLauncher(Launcher):
661
669
  str
662
670
  Contents of the log or ``None``.
663
671
  """
664
- if self._enshell_log_file is None:
665
- return None
672
+ if self._enshell_log_file is None: # pragma: no cover
673
+ return None # pragma: no cover
666
674
 
667
675
  if self._container is not None:
668
676
  try:
@@ -685,9 +693,9 @@ class DockerLauncher(Launcher):
685
693
  s = text.read().decode("utf-8")
686
694
  text.close()
687
695
  return s
688
- except Exception as e:
689
- logging.debug(f"Error getting EnShell log: {e}\n")
690
- return None
696
+ except Exception as e: # pragma: no cover
697
+ logging.debug(f"Error getting EnShell log: {e}\n") # pragma: no cover
698
+ return None # pragma: no cover
691
699
 
692
700
  fs = self.file_service() # pragma: no cover
693
701
  if fs is not None: # pragma: no cover
@@ -111,8 +111,8 @@ class EnsContext:
111
111
 
112
112
  """
113
113
  data = self._buffer.getvalue()
114
- if len(data) < 1:
115
- raise RuntimeError("No context data to save")
114
+ if len(data) < 1: # pragma: no cover
115
+ raise RuntimeError("No context data to save") # pragma: no cover
116
116
  with open(filename, "wb") as fp:
117
117
  fp.write(data)
118
118
 
@@ -135,9 +135,9 @@ class EnsContext:
135
135
 
136
136
  """
137
137
  data = self._buffer.getvalue()
138
- if b64:
138
+ if b64: # pragma: no cover
139
139
  return base64.b64encode(data).decode("ascii")
140
- return data
140
+ return data # pragma: no cover
141
141
 
142
142
  def _build_from_directory(self, pathname: str) -> None:
143
143
  """Create a zip object from the contents of a directory
@@ -192,7 +192,7 @@ class EnsContext:
192
192
  # ensight.objs.core.CURRENTCASE[0].setmetatag('ENS_UNITS_SYSTEM_NAME','SI')
193
193
  start = ctx.index(b"# Object MetaData commands")
194
194
  end = ctx.index(b"# End Object MetaData commands")
195
- if (start >= 0) and (end >= 0):
195
+ if (start >= 0) and (end >= 0): # pragma: no cover
196
196
  saved_lines = list()
197
197
  for line in ctx[start:end].split(b"\n"):
198
198
  skip = b".setmetatag('CFD_VAR'" in line
@@ -206,14 +206,14 @@ class EnsContext:
206
206
  continue
207
207
  saved_lines.append(line)
208
208
  ctx = ctx[:start] + b"\n".join(saved_lines) + ctx[end:]
209
- except ValueError:
210
- warnings.warn("Note: Object Metadata block not found")
209
+ except ValueError: # pragma: no cover
210
+ warnings.warn("Note: Object Metadata block not found") # pragma: no cover
211
211
  try:
212
212
  # remove the Textures block (as the textures are not in the project)
213
213
  start = ctx.index(b"# Textures")
214
- end = ctx.index(b"# Attributes To Restore Viewport Defaults")
215
- if (start >= 0) and (end >= 0):
216
- ctx = ctx[:start] + ctx[end:]
214
+ end = ctx.index(b"# Attributes To Restore Viewport Defaults") # pragma: no cover
215
+ if (start >= 0) and (end >= 0): # pragma: no cover
216
+ ctx = ctx[:start] + ctx[end:] # pragma: no cover
217
217
  except ValueError:
218
218
  warnings.warn("Note: Object Metadata block not found")
219
219
  # rewrite the file
@@ -237,9 +237,11 @@ class EnsContext:
237
237
  with tempfile.TemporaryDirectory() as tempdirname:
238
238
  the_file = zipfile.ZipFile(self._buffer, "r")
239
239
  the_file.extractall(path=tempdirname)
240
- if self._type in (self._SIMPLE_CONTEXT, self._FULL_CONTEXT):
241
- _ = ensight.file.context_restore_rescale("OFF")
242
- _ = ensight.file.restore_context(os.path.join(tempdirname, "context.ctx"))
240
+ if self._type in (self._SIMPLE_CONTEXT, self._FULL_CONTEXT): # pragma: no cover
241
+ _ = ensight.file.context_restore_rescale("OFF") # pragma: no cover
242
+ _ = ensight.file.restore_context(
243
+ os.path.join(tempdirname, "context.ctx")
244
+ ) # pragma: no cover
243
245
 
244
246
  def _capture_context(
245
247
  self, ensight: Any, context: int = _SIMPLE_CONTEXT, all_cases: bool = True
@@ -264,7 +266,7 @@ class EnsContext:
264
266
  with tempfile.TemporaryDirectory() as tempdirname:
265
267
  # Save a context
266
268
  which = "current_case"
267
- if all_cases:
269
+ if all_cases: # pragma: no cover
268
270
  which = "all_cases"
269
271
  _ = ensight.file.save_context_type(which)
270
272
  _ = ensight.file.save_context(os.path.join(tempdirname, "context.ctx"))
@@ -273,7 +275,7 @@ class EnsContext:
273
275
  with open(os.path.join(tempdirname, "simplecontext.txt"), "w") as fp:
274
276
  fp.write("simplecontext")
275
277
  self._fix_context_file(os.path.join(tempdirname, "context.ctx"))
276
- elif context == self._FULL_CONTEXT:
278
+ elif context == self._FULL_CONTEXT: # pragma: no cover
277
279
  with open(os.path.join(tempdirname, "fullcontext.txt"), "w") as fp:
278
280
  fp.write("fullcontext")
279
281
  self._build_from_directory(tempdirname)
@@ -95,11 +95,11 @@ class EnShellGRPC(object):
95
95
  n : Optional[int], optional
96
96
  An string to be used as the security token, by default None
97
97
  """
98
- self._security_token = n
98
+ self._security_token = n # pragma: no cover
99
99
 
100
100
  def set_random_security_token(self):
101
101
  """Set a random security token for the gRPC connection."""
102
- self._security_token = str(random.randint(0, 1000000))
102
+ self._security_token = str(random.randint(0, 1000000)) # pragma: no cover
103
103
 
104
104
  def security_token(self):
105
105
  """Return the security token for the gRPC connection.
@@ -118,10 +118,10 @@ class EnShellGRPC(object):
118
118
  send the gRPC exit() call and then shut down all connections.
119
119
  """
120
120
  # if we launched EnShell, shut it down.
121
- if self._pid is not None:
122
- _ = self.stop_server()
121
+ if self._pid is not None: # pragma: no cover
122
+ _ = self.stop_server() # pragma: no cover
123
123
 
124
- def start_server(self):
124
+ def start_server(self): # pragma: no cover
125
125
  """Start an EnShell gRPC server instance.
126
126
 
127
127
  If the host application wishes to launch an EnShell instance, start_server()
@@ -165,13 +165,13 @@ class EnShellGRPC(object):
165
165
  """
166
166
  response = None
167
167
  # if we are connected and we started the server, we will emit the 'exit' message
168
- if self.is_connected():
168
+ if self.is_connected(): # pragma: no cover
169
169
  response = self._stub.exit_cleanly(
170
170
  enshell_pb2.google_dot_protobuf_dot_empty__pb2.Empty(), metadata=self.metadata()
171
171
  )
172
172
  self._stub = None
173
173
  self._dsg_stub = None
174
- if self._channel:
174
+ if self._channel: # pragma: no cover
175
175
  self._channel.close()
176
176
  self._channel = None
177
177
  self._pid = None
@@ -239,7 +239,7 @@ class EnShellGRPC(object):
239
239
  self._channel = channel
240
240
  self._stub = enshell_pb2_grpc.EnShellServiceStub(self._channel)
241
241
 
242
- def metadata(self):
242
+ def metadata(self): # pragma: no cover
243
243
  """Compute internal gRPC stream metadata."""
244
244
  ret = list()
245
245
  if self._security_token is not None:
@@ -70,7 +70,7 @@ class EnSightGRPC(object):
70
70
 
71
71
  @security_token.setter
72
72
  def security_token(self, name: str) -> None:
73
- self._security_token = name
73
+ self._security_token = name # pragma: no cover
74
74
 
75
75
  @property
76
76
  def session_name(self) -> str:
@@ -98,20 +98,22 @@ class EnSightGRPC(object):
98
98
  force: bool, optional
99
99
  if stop_ensight and force are true, stop EnSight aggressively
100
100
  """
101
- if self.is_connected():
101
+ if self.is_connected(): # pragma: no cover
102
102
  # if requested, send 'Exit'
103
- if stop_ensight:
103
+ if stop_ensight: # pragma: no cover
104
104
  # the gRPC ExitRequest is exactly that, a request in some
105
105
  # cases the operation needs to be forced
106
- if force:
106
+ if force: # pragma: no cover
107
107
  try:
108
108
  self.command("ensight.exit(0)", do_eval=False)
109
- except IOError:
109
+ except IOError: # pragma: no cover
110
110
  # we expect this as the exit can result in the gRPC call failing
111
- pass
111
+ pass # pragma: no cover
112
112
  else:
113
- if self._stub:
114
- _ = self._stub.Exit(ensight_pb2.ExitRequest(), metadata=self._metadata())
113
+ if self._stub: # pragma: no cover
114
+ _ = self._stub.Exit(
115
+ ensight_pb2.ExitRequest(), metadata=self._metadata()
116
+ ) # pragma: no cover
115
117
  # clean up control objects
116
118
  self._stub = None
117
119
  self._dsg_stub = None
@@ -153,9 +155,9 @@ class EnSightGRPC(object):
153
155
  )
154
156
  try:
155
157
  grpc.channel_ready_future(self._channel).result(timeout=timeout)
156
- except grpc.FutureTimeoutError:
157
- self._channel = None
158
- return
158
+ except grpc.FutureTimeoutError: # pragma: no cover
159
+ self._channel = None # pragma: no cover
160
+ return # pragma: no cover
159
161
  # hook up the stub interface
160
162
  self._stub = ensight_pb2_grpc.EnSightServiceStub(self._channel)
161
163
  self._dsg_stub = dynamic_scene_graph_pb2_grpc.DynamicSceneGraphServiceStub(self._channel)
@@ -169,12 +171,12 @@ class EnSightGRPC(object):
169
171
  """
170
172
  ret: List[Tuple[bytes, Union[str, bytes]]] = list()
171
173
  s: Union[str, bytes]
172
- if self._security_token:
174
+ if self._security_token: # pragma: no cover
173
175
  s = self._security_token
174
- if type(s) == str:
176
+ if type(s) == str: # pragma: no cover
175
177
  s = s.encode("utf-8")
176
178
  ret.append((b"shared_secret", s))
177
- if self.session_name:
179
+ if self.session_name: # pragma: no cover
178
180
  s = self.session_name.encode("utf-8")
179
181
  ret.append((b"session_name", s))
180
182
  return ret
@@ -217,11 +219,11 @@ class EnSightGRPC(object):
217
219
  """
218
220
  self.connect()
219
221
  ret_type = ensight_pb2.RenderRequest.IMAGE_RAW
220
- if png:
222
+ if png: # pragma: no cover
221
223
  ret_type = ensight_pb2.RenderRequest.IMAGE_PNG
222
224
  response: Any
223
225
  try:
224
- if self._stub:
226
+ if self._stub: # pragma: no cover
225
227
  response = self._stub.RenderImage(
226
228
  ensight_pb2.RenderRequest(
227
229
  type=ret_type,
@@ -232,8 +234,8 @@ class EnSightGRPC(object):
232
234
  ),
233
235
  metadata=self._metadata(),
234
236
  )
235
- except Exception:
236
- raise IOError("gRPC connection dropped")
237
+ except Exception: # pragma: no cover
238
+ raise IOError("gRPC connection dropped") # pragma: no cover
237
239
  return response.value
238
240
 
239
241
  def geometry(self) -> bytes:
@@ -256,13 +258,13 @@ class EnSightGRPC(object):
256
258
  self.connect()
257
259
  response: Any
258
260
  try:
259
- if self._stub:
261
+ if self._stub: # pragma: no cover
260
262
  response = self._stub.GetGeometry(
261
263
  ensight_pb2.GeometryRequest(type=ensight_pb2.GeometryRequest.GEOMETRY_GLB),
262
264
  metadata=self._metadata(),
263
265
  )
264
- except Exception:
265
- raise IOError("gRPC connection dropped")
266
+ except Exception: # pragma: no cover
267
+ raise IOError("gRPC connection dropped") # pragma: no cover
266
268
  return response.value
267
269
 
268
270
  def command(self, command_string: str, do_eval: bool = True, json: bool = False) -> Any:
@@ -297,20 +299,20 @@ class EnSightGRPC(object):
297
299
  self.connect()
298
300
  flags = ensight_pb2.PythonRequest.EXEC_RETURN_PYTHON
299
301
  response: Any
300
- if json:
301
- flags = ensight_pb2.PythonRequest.EXEC_RETURN_JSON
302
+ if json: # pragma: no cover
303
+ flags = ensight_pb2.PythonRequest.EXEC_RETURN_JSON # pragma: no cover
302
304
  if not do_eval:
303
305
  flags = ensight_pb2.PythonRequest.EXEC_NO_RESULT
304
306
  try:
305
- if self._stub:
307
+ if self._stub: # pragma: no cover
306
308
  response = self._stub.RunPython(
307
309
  ensight_pb2.PythonRequest(type=flags, command=command_string),
308
310
  metadata=self._metadata(),
309
311
  )
310
312
  except Exception:
311
313
  raise IOError("gRPC connection dropped")
312
- if response.error < 0:
313
- raise RuntimeError(response.value)
314
+ if response.error < 0: # pragma: no cover
315
+ raise RuntimeError(response.value) # pragma: no cover
314
316
  if flags == ensight_pb2.PythonRequest.EXEC_NO_RESULT:
315
317
  return None
316
318
  # This was moved externally so pre-processing could be performed
@@ -344,11 +346,11 @@ class EnSightGRPC(object):
344
346
  a list of events stored on this instance. If callback is not None, the object
345
347
  will be called with the event string, otherwise they can be retrieved using get_event().
346
348
  """
347
- if self._event_stream is not None:
348
- return
349
+ if self._event_stream is not None: # pragma: no cover
350
+ return # pragma: no cover
349
351
  self._event_callback = callback
350
352
  self.connect()
351
- if self._stub:
353
+ if self._stub: # pragma: no cover
352
354
  self._event_stream = self._stub.GetEventStream(
353
355
  ensight_pb2.EventStreamRequest(prefix=self.prefix()),
354
356
  metadata=self._metadata(),
@@ -367,9 +369,9 @@ class EnSightGRPC(object):
367
369
  -------
368
370
  True if a ensightservice::EventReply steam is active
369
371
  """
370
- return self._event_stream is not None
372
+ return self._event_stream is not None # pragma: no cover
371
373
 
372
- def dynamic_scene_graph_stream(self, client_cmds):
374
+ def dynamic_scene_graph_stream(self, client_cmds): # pragma: no cover
373
375
  """Open up a dynamic scene graph stream
374
376
 
375
377
  Make a DynamicSceneGraphService::GetSceneStream() rpc call and return
@@ -387,7 +389,7 @@ class EnSightGRPC(object):
387
389
  self.connect()
388
390
  return self._dsg_stub.GetSceneStream(client_cmds, metadata=self._metadata())
389
391
 
390
- def get_event(self) -> Optional[str]:
392
+ def get_event(self) -> Optional[str]: # pragma: no cover
391
393
  """Retrieve and remove the oldest ensightservice::EventReply string
392
394
 
393
395
  When any of the event streaming systems is enabled, Python threads will receive the
@@ -409,10 +411,10 @@ class EnSightGRPC(object):
409
411
  This method is used by threads to make the events they receive available to
410
412
  calling applications via get_event().
411
413
  """
412
- if self._event_callback:
414
+ if self._event_callback: # pragma: no cover
413
415
  self._event_callback(evt.tag)
414
416
  return
415
- self._events.append(evt.tag)
417
+ self._events.append(evt.tag) # pragma: no cover
416
418
 
417
419
  def _poll_events(self) -> None:
418
420
  """Internal method to handle event streams
@@ -421,7 +423,7 @@ class EnSightGRPC(object):
421
423
  ensightservice::EventReply stream.
422
424
  """
423
425
  try:
424
- while self._stub is not None:
426
+ while self._stub is not None: # pragma: no cover
425
427
  evt = self._event_stream.next()
426
428
  self._put_event(evt)
427
429
  except Exception:
@@ -452,16 +452,16 @@ class ENSOBJ(object):
452
452
 
453
453
  def __str__(self) -> str:
454
454
  desc = ""
455
- if hasattr(self.__class__, "attr_list"):
455
+ if hasattr(self.__class__, "attr_list"): # pragma: no cover
456
456
  if self._session.ensight.objs.enums.DESCRIPTION in self.__class__.attr_list:
457
457
  try:
458
- if hasattr(self, "DESCRIPTION"):
458
+ if hasattr(self, "DESCRIPTION"): # pragma: no cover
459
459
  desc_text = self.DESCRIPTION
460
460
  else:
461
461
  desc_text = ""
462
- except RuntimeError:
462
+ except RuntimeError: # pragma: no cover
463
463
  # self.DESCRIPTION is a gRPC call that can fail for default objects
464
- desc_text = ""
464
+ desc_text = "" # pragma: no cover
465
465
  desc = f", desc: '{desc_text}'"
466
466
  owned = ""
467
467
  if self._is_owned:
@@ -31,8 +31,8 @@ try:
31
31
  from ansys.pyensight.core.dockerlauncher import DockerLauncher
32
32
 
33
33
  docker_is_available = True
34
- except Exception:
35
- pass
34
+ except Exception: # pragma: no cover
35
+ pass # pragma: no cover
36
36
  logging.debug(f"docker_is_available: {docker_is_available}\n")
37
37
 
38
38
 
@@ -78,8 +78,8 @@ class Launcher:
78
78
  self._egl_env_val: Optional[bool] = None
79
79
  egl_env = os.environ.get("PYENSIGHT_FORCE_ENSIGHT_EGL")
80
80
  if egl_env is not None:
81
- if egl_env == "1":
82
- self._egl_env_val = True
81
+ if egl_env == "1": # pragma: no cover
82
+ self._egl_env_val = True # pragma: no cover
83
83
  else:
84
84
  self._egl_env_val = False
85
85
  # a dict of any optional launcher specific query parameters for URLs
@@ -127,7 +127,7 @@ class Launcher:
127
127
 
128
128
  # stop the websocketserver instance
129
129
  url = f"http://{session.hostname}:{session.html_port}/v1/stop"
130
- if session.secret_key:
130
+ if session.secret_key: # pragma: no cover
131
131
  url += f"?security_token={session.secret_key}"
132
132
  _ = requests.get(url)
133
133
 
@@ -221,7 +221,7 @@ class Launcher:
221
221
  # in case we failed...
222
222
  if len(ports) < count: # pragma: no cover
223
223
  return None # pragma: no cover
224
- return ports
224
+ return ports # pragma: no cover
225
225
 
226
226
  def _use_egl(self) -> bool:
227
227
  """Return True if the system supports the EGL and if EGL was desired.