-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildallfortest.py
70 lines (53 loc) · 2.07 KB
/
buildallfortest.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
# This is a build for test script.
import os,sys
import time
# Options
TestingDB = False
TestingTools = True
Proxychains = False
RunAsWhileList = True
WhileList = [""]
blacklist = []
def Run(command):
for x in range (1,10):
code = os.WEXITSTATUS(os.system(command))
if (code == 0):
return
if (code == 1):
print(f"[Error] Waiting 5 minutes and retrying, {x}/10 ...")
time.sleep(60*5)
print("[Error] Found the error, exiting ...")
sys.exit(1)
if TestingDB :
print("[Step 1] Install all DB for testing ...")
allDBName = []
# Collect all db
for dirpath,_,filenames in os.walk("/var/lib/mkt/Res/Source"):
for file in filenames:
dbName = (dirpath + "/" +file)
dbName = dbName.replace("/var/lib/mkt/Res/Source/","")
dbName = (dbName[:-3])
allDBName.append(dbName)
print( f"[Step 1] Total DB: {len(allDBName)}")
for x in range(0,len(allDBName)):
print(f"[Step 1 - {x + 1}/{len(allDBName)}] Testing DB {allDBName[x]} ...")
RunCommand = ("mkt db install %s" % (allDBName[x]))
print("$ " + RunCommand)
Run(RunCommand)
if TestingTools :
print("[Step 2] Install all the tools ...")
from pathlib import Path
for dirpath, dirnames, filenames in os.walk("/var/lib/mkt/Tools/Source/"):
for file in filenames:
if (Path(dirpath + file).suffix == ".mkt"):
print("[Test] Processing : " + dirpath +"/"+ file)
relative_path = dirpath.replace("/var/lib/mkt/Tools/Source/","")
abs_path = "/var/lib/mkt/Tools/Install/" + relative_path
import shutil
from pathlib import Path
path = Path(abs_path)
print(abs_path)
path.mkdir(parents=True, exist_ok=True)
shutil.move(dirpath + "/"+ file, abs_path+ "/" + file)
from importlib.machinery import SourceFileLoader
SourceFileLoader("manesec", abs_path+ "/" + file).load_module().Install()