提交 f266a3ba authored 作者: Frédéric Bastien's avatar Frédéric Bastien

Merge pull request #24 from lamblin/nouiz_mixed2

Use logger instead of printing. Update error message.
import cPickle import cPickle
import errno import errno
import logging
import os import os
import platform import platform
import re import re
...@@ -17,6 +18,9 @@ from theano.configparser import config, AddConfigVar, ConfigParam, StrParam ...@@ -17,6 +18,9 @@ from theano.configparser import config, AddConfigVar, ConfigParam, StrParam
from theano.gof.utils import flatten from theano.gof.utils import flatten
from theano.misc.windows import call_subprocess_Popen from theano.misc.windows import call_subprocess_Popen
_logger = logging.getLogger("theano.gof.compiledir")
# Using the dummy file descriptors below is a workaround for a crash # Using the dummy file descriptors below is a workaround for a crash
# experienced in an unusual Python 2.4.4 Windows environment with the default # experienced in an unusual Python 2.4.4 Windows environment with the default
# None values. # None values.
...@@ -225,18 +229,25 @@ def cleanup(): ...@@ -225,18 +229,25 @@ def cleanup():
keydata.key_pkl = filename keydata.key_pkl = filename
keydata.remove_key(key) keydata.remove_key(key)
except IOError, e: except IOError, e:
print ("ERROR while removing a key entry" _logger.error(
" from file. '%s'." "Could not remove file '%s'. To complete "
" Delete its directory" % filename) "the clean-up, please remove manually "
"the directory containing it.",
filename)
if len(keydata.keys) == 0: if len(keydata.keys) == 0:
shutil.rmtree(os.path.join(compiledir, directory)) shutil.rmtree(os.path.join(compiledir, directory))
except EOFError: except EOFError:
print ("ERROR while reading this key file '%s'." _logger.error(
" Delete its directory" % filename) "Could not read key file '%s'. To complete "
"the clean-up, please remove manually "
"the directory containing it.",
filename)
except IOError: except IOError:
print ("ERROR while cleaning up this directory '%s'." _logger.error(
" Delete it." % directory) "Could not clean up this directory: '%s'. To complete "
"the clean-up, please remove it manually.",
directory)
finally: finally:
if file is not None: if file is not None:
file.close() file.close()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论