File: rm_rf.py

package info (click to toggle)
py-stringmatching 0.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,956 kB
  • sloc: python: 3,979; makefile: 174; sh: 7
file content (21 lines) | stat: -rw-r--r-- 392 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from __future__ import print_function
import os
import sys
import stat
import shutil

def remove_readonly(func, path, excinfo):
    os.chmod(path, stat.S_IWRITE)
    func(path)

def main():
    print(sys.executable)
    try:
        shutil.rmtree(sys.argv[1], onerror=remove_readonly)
    except Exception as e:
        print("Error")
        print(e)

if __name__ == '__main__':
    main()