# HG changeset patch # User Sylvain Thénault # Date 1342774668 -7200 # Node ID 4c1efb5bde0a31d4e1698bcd2cb89966b6f92377 # Parent 0044a29ea1184908bee3e8c961bb3efa67ed592c [config] load_configuration should not crash because of fs errors. Closes #2286215 diff -r 0044a29ea118 -r 4c1efb5bde0a cwconfig.py --- a/cwconfig.py Thu Jul 19 09:01:54 2012 +0200 +++ b/cwconfig.py Fri Jul 20 10:57:48 2012 +0200 @@ -171,6 +171,7 @@ import sys import os +import stat import logging import logging.config from smtplib import SMTP @@ -1076,7 +1077,12 @@ If not, try to fix this, letting exception propagate when not possible. """ if not exists(path): - os.makedirs(path) + self.info('creating %s directory', path) + try: + os.makedirs(path) + except OSError, ex: + self.warning('error while creating %s directory: %s', path, ex) + return if self['uid']: try: uid = int(self['uid']) @@ -1090,10 +1096,20 @@ return fstat = os.stat(path) if fstat.st_uid != uid: - os.chown(path, uid, os.getgid()) - import stat + self.info('giving ownership of %s directory to %s', path, self['uid']) + try: + os.chown(path, uid, os.getgid()) + except OSError, ex: + self.warning('error while giving ownership of %s directory to %s: %s', + path, self['uid'], ex) if not (fstat.st_mode & stat.S_IWUSR): - os.chmod(path, fstat.st_mode | stat.S_IWUSR) + self.info('forcing write permission on directory %s', path) + try: + os.chmod(path, fstat.st_mode | stat.S_IWUSR) + except OSError, ex: + self.warning('error while forcing write permission on directory %s: %s', + path, ex) + return @cached def instance_md5_version(self):