-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean.py
50 lines (40 loc) · 1.18 KB
/
clean.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import shutil
import os
import sys
buildPrefix = "Build-cmake"
buildConfig = "Debug"
deps = "dependencies"
def systemRemoveDir(path):
code = -1
if os.name == 'nt':
code = os.system("rm \"" + path + "\"")
else:
code = os.system("rm -rf \"" + path + "\"")
if code == 0:
print("Directory '%s' removed" % path)
else:
print("Return code: %d" % code)
def removeDir(path):
if os.path.exists(path):
if not os.access(path, os.W_OK):
os.chmod(path, stat.S_IWUSR)
try:
shutil.rmtree(path)
print("Directory '%s' removed" % path)
except OSError as e:
print("Exception while removing a directory '%s': %s: '%s'" % (path, e.strerror, e.filename))
print("Try to use shell command")
systemRemoveDir(path)
else:
print("'%s' directory already removed" % path)
for a in sys.argv:
if a == "release":
buildConfig = "Release"
if a == "g++":
buildPrefix="Build-g++"
if a == "full":
buildConfig = ""
build = buildPrefix + "/" + buildConfig
removeDir(build)
if len(sys.argv) > 1 and sys.argv[1] == "deps":
removeDir(deps)