Menu

#68 Class SolutionDirectory crashes trying to create symbolic links on a CIFS file-system

confirmed
None
normal
crash
always
none
The Library
0.5.4
general
2011-06-07
2011-06-06
No

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")
--------------------------------------------------

Discussion

  • Bernhard Gschaider

    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)

     
  • Philippose Rajan

    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 -----------------------------

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.