-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added checks for openfoam installation
- Loading branch information
1 parent
a7b8009
commit e20f6c2
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import subprocess, re | ||
from pyvnt.Reference.error_classes import VersionError | ||
''' | ||
This function checks for the existence of an external software package. | ||
''' | ||
|
||
def check_package(name, version): | ||
|
||
pkg_cmd = "" | ||
if name == "OpenFOAM": | ||
pkg_cmd = "blockMesh" | ||
|
||
try: | ||
res = subprocess.check_output([pkg_cmd, "-help"], text=True, shell=True) | ||
|
||
match = re.search(r"OpenFOAM-(\d+)", res) | ||
|
||
v = match.group(1) | ||
|
||
if v != version: | ||
raise VersionError(v) | ||
except Exception as e: | ||
print(e) | ||
print("OpenFOAM might not be installed or its environment might not be active") |