using pathlib for chmod
This commit is contained in:
parent
e3b384dc7f
commit
8e45e65375
1 changed files with 8 additions and 2 deletions
|
@ -17,6 +17,7 @@ import argparse
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from git import Repo
|
from git import Repo
|
||||||
import os
|
import os
|
||||||
|
from pathlib import Path
|
||||||
import platform
|
import platform
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -155,8 +156,13 @@ def secure_delete(path: str):
|
||||||
def del_rw(action, name, exc):
|
def del_rw(action, name, exc):
|
||||||
if not os.path.exists(name):
|
if not os.path.exists(name):
|
||||||
return
|
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)
|
shutil.rmtree(path, onerror=del_rw)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue