From 8e45e65375e92d586431538a94315a0c798b06b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=BChnel?= Date: Thu, 16 Apr 2020 10:25:24 +0000 Subject: [PATCH] using pathlib for chmod --- scripts/run_cmake.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/run_cmake.py b/scripts/run_cmake.py index 0d19446..61bd5fb 100755 --- a/scripts/run_cmake.py +++ b/scripts/run_cmake.py @@ -17,6 +17,7 @@ import argparse from enum import Enum from git import Repo import os +from pathlib import Path import platform import shutil import subprocess @@ -155,8 +156,13 @@ def secure_delete(path: str): def del_rw(action, name, exc): if not os.path.exists(name): return - os.chmod(name, stat.S_IWRITE) - secure_delete(name) + + for root, dirs, files in os.walk(name, topdown=False): + for name in files: + p = Path (os.path.join(root, name)) + p.chmod(stat.S_IWRITE) + + shutil.rmtree(name) shutil.rmtree(path, onerror=del_rw)