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