-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean.py
72 lines (52 loc) · 1.94 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import os
import shutil
import fnmatch
def delete_folder(path):
if os.path.exists(path):
shutil.rmtree(path)
print(f"Deleted folder: {path}")
else:
print(f"Folder not found: {path}")
def delete_file(path):
if os.path.exists(path):
os.remove(path)
print(f"Deleted file: {path}")
else:
print(f"File not found: {path}")
def delete_files_in_folder_with_extensions(folder, extensions):
for root, _, files in os.walk(folder):
for file in files:
if any(file.endswith(ext) for ext in extensions):
file_path = os.path.join(root, file)
delete_file(file_path)
def delete_folders_with_prefix(folder, prefix):
for root, dirs, _ in os.walk(folder):
for dir in dirs:
if dir.startswith(prefix):
dir_path = os.path.join(root, dir)
delete_folder(dir_path)
def run_make_clean_and_delete_makefile(target_dir):
makefile_path = os.path.join(target_dir, "Makefile")
os.chdir(target_dir)
os.system("make clean")
delete_file(makefile_path)
os.chdir("..")
def main():
# Delete folders "functions" and "approximated_function"
delete_folder("functions")
delete_folder("approximated_functions")
delete_folder("knob_tuning")
# Delete folder "dependency_graphs/target"
delete_folder("dependency_graphs")
# Delete folder "compilation_testing/"
delete_folder("compilation_testing")
# Delete all txt, json, and csv files in the "log" folder
delete_files_in_folder_with_extensions("logs", [".txt", ".json"])
# Remove .elf files from remondBin
delete_files_in_folder_with_extensions("renodeBin", [".elf"])
# Remove "ground_truth.csv" from target dir, run make clean, then delete the Makefile
delete_file("target/ground_truth.csv")
run_make_clean_and_delete_makefile("target")
print("Cleanup completed.")
if __name__ == "__main__":
main()