diff --git a/src/gmv/gmvault_utils.py b/src/gmv/gmvault_utils.py index 9503f98a..cd8b476a 100755 --- a/src/gmv/gmvault_utils.py +++ b/src/gmv/gmvault_utils.py @@ -33,6 +33,7 @@ import locale import urllib import chardet +import errno import gmv.log_utils as log_utils import gmv.conf.conf_helper @@ -395,15 +396,17 @@ def contains_any(string, char_set): return 1 in [c in string for c in char_set] def makedirs(a_path): - """ my own version of makedir """ - - if os.path.isdir(a_path): - # it already exists so return - return - elif os.path.isfile(a_path): - raise OSError("a file with the same name as the desired dir, '%s', already exists."%(a_path)) - - os.makedirs(a_path) + """ + Create all the intermediate directories in a path. + Similar to the `mkdir -p` command. + """ + try: + os.makedirs(a_path) + except OSError as exc: # Python >2.5 + if exc.errno == errno.EEXIST and os.path.isdir(a_path): + pass + else: + raise def __rmgeneric(path, __func__): """ private function that is part of delete_all_under """