From 3073109a160e16d421e3d89b960d4af2286b8021 Mon Sep 17 00:00:00 2001 From: Kerry McAdams Date: Tue, 1 Aug 2023 15:58:17 -0400 Subject: [PATCH 1/4] added warning for ansys-mechanical when provided an input script --- src/ansys/mechanical/core/run.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ansys/mechanical/core/run.py b/src/ansys/mechanical/core/run.py index e39b5e319..5f683fdfe 100644 --- a/src/ansys/mechanical/core/run.py +++ b/src/ansys/mechanical/core/run.py @@ -4,6 +4,7 @@ from asyncio.subprocess import PIPE import os import sys +import warnings import ansys.tools.path as atp import click @@ -170,6 +171,11 @@ def cli( if input_script: args.append("-script") args.append(input_script) + warnings.warn( + "Please ensure ExtAPI.Application.Close() is at the end of your script. " + "Without this command, Batch mode will not terminate.", + stacklevel=2, + ) print(f"Starting Ansys Mechanical version {version_name} in {mode} mode...") if port: From cf84e804f68d39b93e1e6c88b3b5f972fa19124a Mon Sep 17 00:00:00 2001 From: Kerry McAdams Date: Thu, 3 Aug 2023 15:01:02 -0400 Subject: [PATCH 2/4] added version check for warning msg --- src/ansys/mechanical/core/run.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ansys/mechanical/core/run.py b/src/ansys/mechanical/core/run.py index 5f683fdfe..e84cba186 100644 --- a/src/ansys/mechanical/core/run.py +++ b/src/ansys/mechanical/core/run.py @@ -171,11 +171,13 @@ def cli( if input_script: args.append("-script") args.append(input_script) - warnings.warn( - "Please ensure ExtAPI.Application.Close() is at the end of your script. " - "Without this command, Batch mode will not terminate.", - stacklevel=2, - ) + + if version < 241: + warnings.warn( + "Please ensure ExtAPI.Application.Close() is at the end of your script. " + "Without this command, Batch mode will not terminate.", + stacklevel=2, + ) print(f"Starting Ansys Mechanical version {version_name} in {mode} mode...") if port: From e398867b582dfab0987a39f894e82db2153e90d1 Mon Sep 17 00:00:00 2001 From: Kerry McAdams <58492561+klmcadams@users.noreply.github.com> Date: Thu, 3 Aug 2023 15:06:41 -0400 Subject: [PATCH 3/4] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b32d7d6e..38263b6e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG](https://kee ### Added - Added warning for ansys-mechanical when provided an input script (#319) +- Added version check for ansys-mechanical warning message (#323) ### Changed From dc049086d2ce8268319ad3e880aad48548d3d5cc Mon Sep 17 00:00:00 2001 From: Kerry McAdams Date: Fri, 4 Aug 2023 11:15:07 -0400 Subject: [PATCH 4/4] fixed warning message to run only for input script batch < 241 --- src/ansys/mechanical/core/run.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/ansys/mechanical/core/run.py b/src/ansys/mechanical/core/run.py index b46a05df7..4c6417ea9 100644 --- a/src/ansys/mechanical/core/run.py +++ b/src/ansys/mechanical/core/run.py @@ -171,19 +171,14 @@ def cli( if input_script: args.append("-script") args.append(input_script) + + if (not graphical) and input_script and (version < 241): warnings.warn( "Please ensure ExtAPI.Application.Close() is at the end of your script. " "Without this command, Batch mode will not terminate.", stacklevel=2, ) - if version < 241: - warnings.warn( - "Please ensure ExtAPI.Application.Close() is at the end of your script. " - "Without this command, Batch mode will not terminate.", - stacklevel=2, - ) - print(f"Starting Ansys Mechanical version {version_name} in {mode} mode...") if port: # TODO - Mechanical doesn't write anything to the stdout in grpc mode