blob: e2799f16eed64a97ccfce6306d16b8803753e979 (
plain)
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
|
import os
import shutil
import subprocess
from plugins.agl_test_conf import REPORT_LOGS_DIR
from plugins.agl_test_conf import TMP_LOGS_DIR
from plugins.agl_test_conf import TMP_TEST_REPORT
#Check if there is the command that we needed
def find_cmd(cmd):
output = subprocess.run(['which',cmd],stdout=subprocess.PIPE)
if output.returncode==0:
return 0
else:
print("error: {} is not found".format(cmd))
return 1
#Make dir for THIS_TEST to save the log
def create_dir(THIS_TEST):
TMP_THIS_TEST_LOG = TMP_LOGS_DIR + THIS_TEST + "/log/"
TMP_TEST_REPORT_THIS = TMP_TEST_REPORT + THIS_TEST
subprocess.run(['mkdir','-p',TMP_THIS_TEST_LOG])
subprocess.run(['mkdir','-p',TMP_TEST_REPORT_THIS])
# print errors
def printe(msg):
print("**** ERROR: " + msg)
# print debug info
def printd(msg):
# TODO
print("==== DEBUG: " + msg)
# delete entire temp log folder
def rm_all_tmp():
env_dist=os.environ
mode = str(env_dist.get("LOG_MODE"))
if mode == "clear":
shutil.rmtree(TMP_LOGS_DIR)
|