Use method ensure_tree from oslo.utils
Oslo.utils provides same function and just use it. Change-Id: Iac245d4d98c41edea5294a4d8842db69a42b3794
This commit is contained in:
@@ -24,6 +24,7 @@ import shutil
|
|||||||
import cachetools
|
import cachetools
|
||||||
import fasteners
|
import fasteners
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
|
from oslo_utils import fileutils
|
||||||
|
|
||||||
from taskflow import exceptions as exc
|
from taskflow import exceptions as exc
|
||||||
from taskflow.persistence import path_based
|
from taskflow.persistence import path_based
|
||||||
@@ -146,7 +147,7 @@ class Connection(path_based.PathBasedConnection):
|
|||||||
|
|
||||||
def _ensure_path(self, path):
|
def _ensure_path(self, path):
|
||||||
with _storagefailure_wrapper():
|
with _storagefailure_wrapper():
|
||||||
misc.ensure_tree(path)
|
fileutils.ensure_tree(path)
|
||||||
|
|
||||||
def _create_link(self, src_path, dest_path, transaction):
|
def _create_link(self, src_path, dest_path, transaction):
|
||||||
with _storagefailure_wrapper():
|
with _storagefailure_wrapper():
|
||||||
|
@@ -18,7 +18,6 @@
|
|||||||
import collections
|
import collections
|
||||||
import contextlib
|
import contextlib
|
||||||
import datetime
|
import datetime
|
||||||
import errno
|
|
||||||
import inspect
|
import inspect
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@@ -467,24 +466,6 @@ def as_int(obj, quiet=False):
|
|||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
||||||
# Taken from oslo-incubator file-utils but since that module pulls in a large
|
|
||||||
# amount of other files it does not seem so useful to include that full
|
|
||||||
# module just for this function.
|
|
||||||
def ensure_tree(path):
|
|
||||||
"""Create a directory (and any ancestor directories required).
|
|
||||||
|
|
||||||
:param path: Directory to create
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
os.makedirs(path)
|
|
||||||
except OSError as e:
|
|
||||||
if e.errno == errno.EEXIST:
|
|
||||||
if not os.path.isdir(path):
|
|
||||||
raise
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def capture_failure():
|
def capture_failure():
|
||||||
"""Captures the occurring exception and provides a failure object back.
|
"""Captures the occurring exception and provides a failure object back.
|
||||||
|
Reference in New Issue
Block a user