Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Windows data path name, and change to when examples folder is created #1615

Merged
merged 3 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 2 additions & 11 deletions src/ansys/fluent/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,8 @@ def version_info() -> str:
logging.config.dictConfig(config)

# Setup data directory
try:
USER_DATA_PATH = appdirs.user_data_dir("ansys_fluent_core")
if not os.path.exists(USER_DATA_PATH):
os.makedirs(USER_DATA_PATH)

EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples")
if not os.path.exists(EXAMPLES_PATH):
os.makedirs(EXAMPLES_PATH)

except Exception:
pass
USER_DATA_PATH = appdirs.user_data_dir(appname="ansys_fluent_core", appauthor="Ansys")
EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples")

BUILDING_GALLERY = False

Expand Down
10 changes: 6 additions & 4 deletions src/ansys/fluent/core/examples/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ def _get_file_url(filename: str, directory: Optional[str] = None) -> str:

def _retrieve_file(url: str, filename: str, save_path: Optional[str] = None) -> str:
if save_path is None:
local_path: str = os.path.join(
pyfluent.EXAMPLES_PATH, os.path.basename(filename)
)
save_path = pyfluent.EXAMPLES_PATH
else:
save_path = os.path.abspath(save_path)
local_path = os.path.join(save_path, os.path.basename(filename))
local_path = os.path.join(save_path, os.path.basename(filename))
local_path_no_zip = re.sub(".zip$", "", local_path)
# First check if file has already been downloaded
if os.path.isfile(local_path_no_zip) or os.path.isdir(local_path_no_zip):
Expand All @@ -58,6 +56,10 @@ def _retrieve_file(url: str, filename: str, save_path: Optional[str] = None) ->

logging.info("Downloading specified file...")

# Check if save path exists
if not os.path.exists(save_path):
os.makedirs(save_path)

# grab the correct url retriever
urlretrieve = urllib.request.urlretrieve

Expand Down
2 changes: 2 additions & 0 deletions src/ansys/fluent/core/launcher/fluent_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def start_fluent_container(mounted_from: str, mounted_to: str, args: List[str])
int
gPRC server port exposed from the container.
"""
if not os.path.exists(mounted_from):
os.makedirs(mounted_from)
fd, sifile = tempfile.mkstemp(suffix=".txt", prefix="serverinfo-", dir=mounted_from)
os.close(fd)
timeout = 100
Expand Down