Sync from oslo-incubator

Copy fileutils.py changes from change id(s):
I369226f619895299c62f22a1debd0d4d120c912d
I7decb7bf5f3185f7d26ad99b0cb3475a88d3ec99

Also fix the openstack-common.conf to the correct package name

Change-Id: Ic77262bf94408395e720490264bcf7022461fe4d
This commit is contained in:
Davanum Srinivas 2015-05-16 16:00:48 -04:00
parent bf419a381f
commit b01e2a9cc8
2 changed files with 7 additions and 4 deletions

View File

@ -4,4 +4,4 @@
module = fileutils
# The base module to hold the copy of openstack.common
base=oslo.concurrency
base=oslo_concurrency

View File

@ -17,6 +17,7 @@ import contextlib
import errno
import logging
import os
import stat
import tempfile
from oslo_utils import excutils
@ -24,15 +25,17 @@ from oslo_utils import excutils
LOG = logging.getLogger(__name__)
_FILE_CACHE = {}
DEFAULT_MODE = stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO
def ensure_tree(path):
def ensure_tree(path, mode=DEFAULT_MODE):
"""Create a directory (and any ancestor directories required)
:param path: Directory to create
:param mode: Directory creation permissions
"""
try:
os.makedirs(path)
os.makedirs(path, mode)
except OSError as exc:
if exc.errno == errno.EEXIST:
if not os.path.isdir(path):
@ -58,7 +61,7 @@ def read_cached_file(filename, force_reload=False):
cache_info = _FILE_CACHE.setdefault(filename, {})
if not cache_info or mtime > cache_info.get('mtime', 0):
LOG.debug("Reloading cached file %s" % filename)
LOG.debug("Reloading cached file %s", filename)
with open(filename) as fap:
cache_info['data'] = fap.read()
cache_info['mtime'] = mtime