-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun.py
51 lines (43 loc) · 1.41 KB
/
run.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
import os
import sys
import subprocess
import time
from threading import Timer
def proc_file(path):
p = subprocess.Popen('python3 controller/main.py ' + path, shell=True)
p.wait()
def proc_folder(path):
for _, _, files in os.walk(path):
for file in files:
print(file)
# Check analysis status
continue_fl = False
for _, dirs, _ in os.walk('final_report'):
for dir in dirs:
if str(file) in dir:
print('\033[93mINFO | \033[00mFound generated report')
continue_fl = True
break
if not continue_fl:
if path.endswith('/'):
file_path = sys.argv[1] + file
else:
file_path = sys.argv[1] + '/' + file
proc_file(file_path)
k = subprocess.Popen('sudo pkill qemu-system-', shell=True)
k.wait()
print(80*'-')
return 0
if __name__ == "__main__":
# Create_report folder
if not os.path.exists('final_report/'):
os.makedirs('final_report/')
if not os.path.exists('report/'):
os.makedirs('report/')
path = sys.argv[1]
if os.path.isdir(path):
proc_folder(path)
elif os.path.isfile(path):
proc_file(path)
else:
print('\033[93mINFO | \033[00mInput is not a file or directory')