def METHOD_NAME(self, path, mode=None):
    """ensure a directory exists at a given path
    This is a version of os.mkdir, with the following differences:
    - returns True if it created the directory, False otherwise
    - ignores EEXIST, protecting against race conditions where
      the dir may have been created in between the check and
      the creation
    - sets permissions if requested and the dir already exists
    """
    if os.path.exists(path):
        if mode and os.stat(path).st_mode != mode:
            try:
                os.chmod(path, mode)
            except OSError:
                self.log.warning(
                    "Could not set permissions on %s",
                    path
                )
        return False
    try:
        if mode:
            os.mkdir(path, mode)
        else:
            os.mkdir(path)
    except OSError as e:
        if e.errno == errno.EEXIST:
            return False
        else:
            raise
    return True