提交 e9a30042 authored 作者: Frederic's avatar Frederic

better error message.

上级 bb58f1a6
...@@ -39,27 +39,32 @@ def filter_compiledir(path): ...@@ -39,27 +39,32 @@ def filter_compiledir(path):
# 2. The path is stable w.r.t. e.g. symlinks (which makes it easier # 2. The path is stable w.r.t. e.g. symlinks (which makes it easier
# to re-use compiled modules). # to re-use compiled modules).
path = os.path.realpath(path) path = os.path.realpath(path)
valid = True if os.access(path, os.F_OK): # Do it exist?
if not os.access(path, os.R_OK | os.W_OK): if not os.access(path, os.R_OK | os.W_OK | os.X_OK):
# If it exist we need read, write and listing access
raise ValueError(
"compiledir '%s' exist but you don't have read, write or"
" listing permissions." % path)
else:
try: try:
os.makedirs(path, 0770) # read-write-execute for user and group os.makedirs(path, 0770) # read-write-execute for user and group
except OSError, e: except OSError, e:
# Maybe another parallel execution of theano was trying to create # Maybe another parallel execution of theano was trying to create
# the same directory at the same time. # the same directory at the same time.
if e.errno != errno.EEXIST: if e.errno != errno.EEXIST:
valid = False raise ValueError(
"We where not able to create the compiledir directory"
" '%s'. Check the permissions." % path)
if valid:
try: try:
# PROBLEM: sometimes the initial approach based on # PROBLEM: sometimes the initial approach based on
# os.system('touch') returned -1 for an unknown reason; the # os.system('touch') returned -1 for an unknown reason; the
# alternate approach here worked in all cases... it was weird. # alternate approach here worked in all cases... it was weird.
open(os.path.join(path, '__init__.py'), 'w').close() open(os.path.join(path, '__init__.py'), 'w').close()
except: except Exception:
valid = False # This should not happen as we checked that we have the permissions.
raise ValueError('Failed to create the __init__.py file in the '
if not valid: 'compiledir: "%s". Check the permissions.' % path)
raise ValueError('Invalid value for compiledir: %s' % path)
return path return path
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论