Note
Go to the end to download the full example code.
Teardown#
This restores the environment after running the examples.
Description#
Perform the following steps to set up the environment: - Connect to Sherlock - Exit Sherlock - Delete temp files
import shutil
from examples.examples_globals import get_temp_dir
from ansys.sherlock.core import LOG, launcher
Exit Sherlock#
Exit the gRPC connection and shut down Sherlock.
LOG.info("Teardown: connect to and exit Sherlock")
try:
sherlock = launcher.connect(port=9092, timeout=2)
sherlock.common.exit(True)
LOG.info("Sherlock exited successfully.")
except Exception as e:
LOG.error(f"Error exiting Sherlock: {e}")
Clean temporary directory#
Delete the directory for storing temp files.
try:
shutil.rmtree(get_temp_dir(), ignore_errors=True)
except Exception as e:
LOG.error(f"Error deleting temporary directory: {e}")