mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 19:28:00 +00:00
lf_check.py : check for std_err being empty lf_report.py: formatting updates
Signed-off-by: Chuck SmileyRekiere <chuck.smileyrekiere@candelatech.com>
This commit is contained in:
@@ -118,7 +118,6 @@ class lf_report():
|
|||||||
print("graph_dst_file: {}".format(graph_dst_file))
|
print("graph_dst_file: {}".format(graph_dst_file))
|
||||||
shutil.move(graph_src_file,graph_dst_file)
|
shutil.move(graph_src_file,graph_dst_file)
|
||||||
|
|
||||||
|
|
||||||
def set_path(self,_path):
|
def set_path(self,_path):
|
||||||
self.path = _path
|
self.path = _path
|
||||||
|
|
||||||
@@ -131,10 +130,6 @@ class lf_report():
|
|||||||
self.date = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")).replace(':','-')
|
self.date = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")).replace(':','-')
|
||||||
self.date_time_directory = self.date + str("_") + str(self.results_dir_name)
|
self.date_time_directory = self.date + str("_") + str(self.results_dir_name)
|
||||||
|
|
||||||
#def set_date_time_directory(self,date_time_directory):
|
|
||||||
# self.date_time_directory = date_time_directory
|
|
||||||
|
|
||||||
|
|
||||||
def build_date_time_directory(self):
|
def build_date_time_directory(self):
|
||||||
if self.date_time_directory == "":
|
if self.date_time_directory == "":
|
||||||
self.set_date_time_directory()
|
self.set_date_time_directory()
|
||||||
@@ -221,7 +216,6 @@ class lf_report():
|
|||||||
self.write_html()
|
self.write_html()
|
||||||
self.write_pdf()
|
self.write_pdf()
|
||||||
|
|
||||||
# only use is pass all data in constructor, no graph output
|
|
||||||
def build_all(self):
|
def build_all(self):
|
||||||
self.build_banner()
|
self.build_banner()
|
||||||
self.build_table_title()
|
self.build_table_title()
|
||||||
@@ -313,7 +307,6 @@ class lf_report():
|
|||||||
"""
|
"""
|
||||||
self.html +=self.graph_html_obj
|
self.html +=self.graph_html_obj
|
||||||
|
|
||||||
|
|
||||||
# Unit Test
|
# Unit Test
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ sys.path.append('../')
|
|||||||
from lf_report import lf_report
|
from lf_report import lf_report
|
||||||
sys.path.append('/')
|
sys.path.append('/')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CONFIG_FILE = os.getcwd() + '/lf_check_config.ini'
|
CONFIG_FILE = os.getcwd() + '/lf_check_config.ini'
|
||||||
RUN_CONDITION = 'ENABLE'
|
RUN_CONDITION = 'ENABLE'
|
||||||
|
|
||||||
@@ -52,7 +50,6 @@ class FileAdapter(object):
|
|||||||
def flush(self):
|
def flush(self):
|
||||||
pass # leave it to logging to flush properly
|
pass # leave it to logging to flush properly
|
||||||
|
|
||||||
|
|
||||||
class lf_check():
|
class lf_check():
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
_csv_outfile,
|
_csv_outfile,
|
||||||
@@ -67,7 +64,6 @@ class lf_check():
|
|||||||
self.results = ""
|
self.results = ""
|
||||||
self.csv_outfile = _csv_outfile,
|
self.csv_outfile = _csv_outfile,
|
||||||
self.outfile = _outfile
|
self.outfile = _outfile
|
||||||
|
|
||||||
|
|
||||||
# Functions in this section are/can be overridden by descendants
|
# Functions in this section are/can be overridden by descendants
|
||||||
def read_config_contents(self):
|
def read_config_contents(self):
|
||||||
@@ -106,15 +102,10 @@ class lf_check():
|
|||||||
|
|
||||||
# no spaces after FACTORY_DFLT
|
# no spaces after FACTORY_DFLT
|
||||||
command = "./{} {}".format("scenario.py", "--load FACTORY_DFLT")
|
command = "./{} {}".format("scenario.py", "--load FACTORY_DFLT")
|
||||||
#process = subprocess.run((command).split(' '), check= True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True,timeout=20)
|
|
||||||
process = subprocess.Popen((command).split(' '), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
process = subprocess.Popen((command).split(' '), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||||
# wait for the process to terminate
|
# wait for the process to terminate
|
||||||
out, err = process.communicate()
|
out, err = process.communicate()
|
||||||
errcode = process.returncode
|
errcode = process.returncode
|
||||||
print("###################### STDOUT - scenario load FACTORY_DFLT #########################")
|
|
||||||
print(process.stdout)
|
|
||||||
print("###################### STDERR - scenario load FACTORY_DFLT #########################")
|
|
||||||
print(process.stderr)
|
|
||||||
|
|
||||||
def load_blank_db(self):
|
def load_blank_db(self):
|
||||||
print("file_wd {}".format(self.scripts_wd))
|
print("file_wd {}".format(self.scripts_wd))
|
||||||
@@ -126,12 +117,7 @@ class lf_check():
|
|||||||
|
|
||||||
# no spaces after FACTORY_DFLT
|
# no spaces after FACTORY_DFLT
|
||||||
command = "./{} {}".format("scenario.py", "--load BLANK")
|
command = "./{} {}".format("scenario.py", "--load BLANK")
|
||||||
process = subprocess.run((command).split(' '), check= True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True,timeout=20)
|
process = subprocess.Popen((command).split(' '), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||||
print("###################### STDOUT - scenario load BLANK #########################")
|
|
||||||
print(process.stdout)
|
|
||||||
print("###################### STDERR - scenario load BLANK #########################")
|
|
||||||
print(process.stderr)
|
|
||||||
|
|
||||||
|
|
||||||
def run_script_test(self):
|
def run_script_test(self):
|
||||||
for test in self.test_dict:
|
for test in self.test_dict:
|
||||||
@@ -144,9 +130,7 @@ class lf_check():
|
|||||||
if self.radio_dict[radio]["KEY"] in self.test_dict[test]['args']:
|
if self.radio_dict[radio]["KEY"] in self.test_dict[test]['args']:
|
||||||
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace(self.radio_dict[radio]["KEY"],'--radio "{}" --ssid "{}" --passwd "{}" --security "{}"'
|
self.test_dict[test]['args'] = self.test_dict[test]['args'].replace(self.radio_dict[radio]["KEY"],'--radio "{}" --ssid "{}" --passwd "{}" --security "{}"'
|
||||||
.format(self.radio_dict[radio]['RADIO'],self.radio_dict[radio]['SSID'],self.radio_dict[radio]['PASSWD'],self.radio_dict[radio]['SECURITY']))
|
.format(self.radio_dict[radio]['RADIO'],self.radio_dict[radio]['SSID'],self.radio_dict[radio]['PASSWD'],self.radio_dict[radio]['SECURITY']))
|
||||||
# Clear out the database
|
|
||||||
self.load_factory_default_db()
|
self.load_factory_default_db()
|
||||||
#self.load_blank_db()
|
|
||||||
sleep(5) # the sleep is to allow for the database to stablize
|
sleep(5) # the sleep is to allow for the database to stablize
|
||||||
|
|
||||||
# CMR this is just to get the directory with the scripts to run.
|
# CMR this is just to get the directory with the scripts to run.
|
||||||
@@ -158,14 +142,9 @@ class lf_check():
|
|||||||
print("failed to change to {}".format(self.scripts_wd))
|
print("failed to change to {}".format(self.scripts_wd))
|
||||||
cmd_args = "{}".format(self.test_dict[test]['args'])
|
cmd_args = "{}".format(self.test_dict[test]['args'])
|
||||||
command = "./{} {}".format(self.test_dict[test]['command'], cmd_args)
|
command = "./{} {}".format(self.test_dict[test]['command'], cmd_args)
|
||||||
#command = "{}/{}".format(scripts_wd,self.test_dict[test]['command'])
|
|
||||||
# cmd_args = "{}".format(self.test_dict[test]['args'])
|
|
||||||
print("command: {}".format(command))
|
print("command: {}".format(command))
|
||||||
print("cmd_args {}".format(cmd_args))
|
print("cmd_args {}".format(cmd_args))
|
||||||
|
|
||||||
# Put lanforge in known state
|
|
||||||
|
|
||||||
#try:
|
|
||||||
if self.outfile is not None:
|
if self.outfile is not None:
|
||||||
stdout_log_txt = self.outfile[:-4]
|
stdout_log_txt = self.outfile[:-4]
|
||||||
stdout_log_txt = stdout_log_txt + "{}-stdout.txt".format(test)
|
stdout_log_txt = stdout_log_txt + "{}-stdout.txt".format(test)
|
||||||
@@ -181,22 +160,19 @@ class lf_check():
|
|||||||
out, err = process.communicate()
|
out, err = process.communicate()
|
||||||
errcode = process.returncode
|
errcode = process.returncode
|
||||||
|
|
||||||
#pss1 = process.stdout.decode('utf-8', 'ignore')
|
|
||||||
#print(pss1)
|
|
||||||
|
|
||||||
#print("###################### STDOUT #########################")
|
|
||||||
#print(process.stdout)
|
|
||||||
print(stdout_log_txt)
|
print(stdout_log_txt)
|
||||||
print(stderr_log_txt)
|
stdout_log_size = os.path.getsize(stdout_log_txt)
|
||||||
#print("###################### STDERR #########################")
|
if stdout_log_size == 0:
|
||||||
# if the stderr is empty the test is considered , does there need to check for pass fail
|
print("File: {} is empty: {}".format(stdout_log_txt,str(stdout_log_size)))
|
||||||
print(process.stderr)
|
|
||||||
if (process.stderr == ''):
|
|
||||||
print("stderr empty")
|
|
||||||
else:
|
else:
|
||||||
print("stderr not empty")
|
print("File: {} is not empty: {}".format(stdout_log_txt,str(stdout_log_size)))
|
||||||
#except:
|
|
||||||
# print("exception on command: {}".format(command))
|
print(stderr_log_txt)
|
||||||
|
stderr_log_size = os.path.getsize(stderr_log_txt)
|
||||||
|
if stderr_log_size == 0:
|
||||||
|
print("File: {} is empty: {}".format(stderr_log_txt,str(stderr_log_size)))
|
||||||
|
else:
|
||||||
|
print("File: {} is not empty: {}".format(stderr_log_txt,str(stderr_log_size)))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# arguments
|
# arguments
|
||||||
|
|||||||
Reference in New Issue
Block a user