try:
        os.makedirs(d)
    except OSError:
        if not os.path.isdir(d):