The constructor for the class "SolutionDirectory" crashes when called with the default function arguments (with the parameter "paraviewLink=True") on an OpenFOAM case located on a CIFS (Samba) share.
Cause of the crash: CIFS shares do not support Symbolic Links, and the call to the function "os.symlink(<source>,<link>)" causes the script to abort.
Temporary work-around: Prevent PyFoam from creating the symbolic link by calling "SolutionDirectory" with "paraviewLink=False"
---- additional_information ----
Location where the crash occurs:
File: PyFoam/RunDictionary/SolutionDirectory.py
Line number: 69
------------- Quote - Begin ----------------------
# Old-school Paraview-reader (this can be removed eventually)
if paraviewLink and not path.exists(self.controlDict()+".foam"):
symlink(path.basename(self.controlDict()),self.controlDict()+".foam")
------------- Quote - End ------------------------
Possible solution: Use the python "shutil" module which provides the "copyfile" function to create a copy of "controlDict" to "controlDict.foam"
------------- Possible solution ------------------
import shutil
if paraviewLink and not path.exists(self.controlDict()+".foam"):
try:
symlink(path.basename(self.controlDict()),self.controlDict()+".foam")
except:
shutil.copyfile(path.basename(self.controlDict()),self.controlDict()+".foam")
--------------------------------------------------
What kind of exception is thrown without the try-except (because the use of a "catch all" except is usually discouraged). (its hard for me to reproduce it without a file system)
Hi,
Here is a copy-paste of the error message.... sorry, should have been part of the original bug-report.
-------------------- Quote - Begin ---------------------------------
Traceback (most recent call last):
File "/opt/Simulation/OpenFOAM/site/ThirdParty/PyFoam/bin/pyFoamDecompose.py", line 5, in <module>
Decomposer()
File "/opt/Simulation/OpenFOAM/site/ThirdParty/PyFoam/lib/python2.7/site-packages/PyFoam/Applications/Decomposer.py", line 40, in __init__
nr=2)
File "/opt/Simulation/OpenFOAM/site/ThirdParty/PyFoam/lib/python2.7/site-packages/PyFoam/Applications/PyFoamApplication.py", line 155, in __init__
result=self.run()
File "/opt/Simulation/OpenFOAM/site/ThirdParty/PyFoam/lib/python2.7/site-packages/PyFoam/Applications/Decomposer.py", line 210, in run
self.checkAndCommit(SolutionDirectory(case,archive=None))
File "/opt/Simulation/OpenFOAM/site/ThirdParty/PyFoam/lib/python2.7/site-packages/PyFoam/RunDictionary/SolutionDirectory.py", line 69, in __init__
symlink(path.basename(self.controlDict()),self.controlDict()+".foam")
OSError: [Errno 95] Operation not supported
------------------- Quote - End -----------------------------