cubicweb/web/propertysheet.py
branch3.23
changeset 11961 a25e52cd8be4
parent 11461 f5a4e14d1dd2
equal deleted inserted replaced
11845:eed83dee2c79 11961:a25e52cd8be4
    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 __docformat__ = "restructuredtext en"
    20 __docformat__ = "restructuredtext en"
    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