From: Travis Rhoden Date: Thu, 7 May 2015 21:43:15 +0000 (-0400) Subject: Add safe_makedirs function X-Git-Tag: v1.5.24~10^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4bc9e271d5d5d7715dfd36d0142e8aba2911138e;p=ceph-deploy.git Add safe_makedirs function safe_makedirs will recursively create paths, just like mkdirs -p The "safe" part is that it wont error/except if any of the paths already exist. Signed-off-by: Travis Rhoden --- diff --git a/ceph_deploy/hosts/remotes.py b/ceph_deploy/hosts/remotes.py index 88812fc..6c8e63a 100644 --- a/ceph_deploy/hosts/remotes.py +++ b/ceph_deploy/hosts/remotes.py @@ -296,6 +296,17 @@ def safe_mkdir(path): raise +def safe_makedirs(path): + """ create path recursively if it doesn't exist """ + try: + os.makedirs(path) + except OSError, e: + if e.errno == errno.EEXIST: + pass + else: + raise + + def zeroing(dev): """ zeroing last few blocks of device """ # this kills the crab