cubicweb/web/propertysheet.py
changeset 11965 fb03a4113979
parent 11767 432f87a63057
child 12288 2c582a242b66
equal deleted inserted replaced
11964:01eeea97e549 11965:fb03a4113979
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    18 """property sheets allowing configuration of the web ui"""
    18 """property sheets allowing configuration of the web ui"""
    19 
    19 
    20 
    20 
    21 
    21 
       
    22 import errno
    22 import re
    23 import re
    23 import os
    24 import os
    24 import os.path as osp
    25 import os.path as osp
    25 import tempfile
    26 import tempfile
    26 
    27 
   107             tmpfd, tmpfile = tempfile.mkstemp(dir=rcachedir, prefix=osp.basename(cachefile))
   108             tmpfd, tmpfile = tempfile.mkstemp(dir=rcachedir, prefix=osp.basename(cachefile))
   108             with os.fdopen(tmpfd, 'w') as stream:
   109             with os.fdopen(tmpfd, 'w') as stream:
   109                 stream.write(content)
   110                 stream.write(content)
   110             try:
   111             try:
   111                 os.rename(tmpfile, cachefile)
   112                 os.rename(tmpfile, cachefile)
   112             except IOError:
   113             except OSError as err:
       
   114                 if err.errno != errno.EEXIST:
       
   115                     raise
   113                 # Under windows, os.rename won't overwrite an existing file
   116                 # Under windows, os.rename won't overwrite an existing file
   114                 os.unlink(cachefile)
   117                 os.unlink(cachefile)
   115                 os.rename(tmpfile, cachefile)
   118                 os.rename(tmpfile, cachefile)
   116             adirectory = self._cache_directory
   119             adirectory = self._cache_directory
   117         return adirectory
   120         return adirectory