Ansys Common Tools

0.5.0 · active · verified Thu Apr 16

Ansys Common Tools is a Python library providing a set of utilities and helper functions designed for use across various PyAnsys libraries. It includes tools for certificate management, file downloads, error handling, gRPC server launching, miscellaneous helpers, and versioning. The current version is 0.5.0, and it follows a regular, feature-driven release cadence.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use the `AnsysNotification` class (introduced in v0.5.0) and the `download_file` utility. Ensure your logging is configured to view notifications. For the download example, a placeholder URL is used; replace it with a valid URL for testing actual file downloads.

import logging
import tempfile
import os
from ansys.tools.common.misc import AnsysNotification

# Configure logging to see AnsysNotification messages
logging.basicConfig(level=logging.INFO, format='%(levelname)s:%(name)s:%(message)s')

# Example 1: Using AnsysNotification (new in v0.5.0)
notification = AnsysNotification(
    title="Example Message",
    message="This is a test notification from ansys-tools-common.",
    tag="INFO"
)
notification.display()

# Example 2: Downloading a file
# Note: This is a placeholder for a real download URL
example_url = os.environ.get('EXAMPLE_DOWNLOAD_URL', 'https://www.ansys.com/static/assets/ansys-logo-full-color.svg')
if example_url == 'https://www.ansys.com/static/assets/ansys-logo-full-color.svg':
    print("Using placeholder URL. Provide a real URL for full functionality.")

with tempfile.TemporaryDirectory() as tmpdir:
    from ansys.tools.common.downloads import download_file
    downloaded_path = download_file(url=example_url, directory=tmpdir)
    print(f"File downloaded to: {downloaded_path}")

view raw JSON →