fix bug with os.readlink and regular files

Signed-off-by: Vassil Vassilev <vvasilev@cern.ch>
This commit is contained in:
erlanger 2016-11-09 21:52:34 -05:00 committed by sftnight
parent 20420081cf
commit c5216dd7b8

View File

@ -78,9 +78,18 @@ class ClingKernel(Kernel):
super(ClingKernel, self).__init__(**kwargs)
try:
whichCling = os.readlink(shutil.which('cling'))
except OSError as e:
#If cling is not a symlink try a regular file
#readlink returns POSIX error EINVAL (22) if the
#argument is not a symlink
if e.args[0] == 22:
whichCling = shutil.which('cling')
else:
raise e
except AttributeError:
from distutils.spawn import find_executable
whichCling = find_executable('cling')
if whichCling:
clingInstDir = os.path.dirname(os.path.dirname(whichCling))
llvmResourceDir = clingInstDir