CourseInfo.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:GLT 作者: MikeTheGreat 项目源码 文件源码
def rmtree_remove_readonly_files(func, path, exc_info):
    """
    Error handler for ``shutil.rmtree``.

    If the error is due to an access error (read only file)
    it attempts to add write permission and then retries.

    If the error is for another reason it re-raises the error.

    Usage : ``shutil.rmtree(path, onerror=rmtree_remove_readonly_files)``

    This code was copied from
    http://stackoverflow.com/questions/2656322/shutil-rmtree-fails-on-windows-with-access-is-denied
    """
    import stat
    if not os.access(path, os.W_OK):
        # Is the error an access error ?
        os.chmod(path, stat.S_IWUSR)
        func(path)
    else:
        raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号