The fileutils module hasn't been updated since
November of 2014. We need to bring this module up
to date to support the namespace changes that have
been made.
Current HEAD in OSLO:
---------------------
commit
e589dde0721a0a67e4030813e582afec6e70d042
Date: Wed Feb 18 03:08:12 2015 +0000
Merge "Have a little fun with release notes"
Changes merged with this patch:
---------------------
ac17de97 - Use oslo_utils instead of deprecated oslo.utils
809080ed - Introduce fileutils ensure_dir creation mode parameter
Change-Id: I0bca3cc59126abed8ef736bf5e199857f681e5cd
import errno
import logging
import os
+import stat
import tempfile
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):