lf_check.py : clean up comments

Signed-off-by: Chuck SmileyRekiere <chuck.smileyrekiere@candelatech.com>
This commit is contained in:
Chuck SmileyRekiere
2021-06-13 16:30:26 -06:00
parent f31fa056cf
commit ebac5c534d

View File

@@ -12,6 +12,7 @@ The config file name can be passed in as a configuraiton parameter.
EXAMPLE: EXAMPLE:
lf_check.py # this will use the defaults lf_check.py # this will use the defaults
lf_check.py --ini <unique ini file> --test_suite <suite to use in .ini file> lf_check.py --ini <unique ini file> --test_suite <suite to use in .ini file>
lf_check.py --ini <unique ini file> --test_suite <suite to use in .ini file> --production
NOTES: NOTES:
Before using lf_check.py Before using lf_check.py
@@ -52,7 +53,6 @@ dir_path = os.path.dirname(os.path.realpath(__file__))
parent_dir_path = os.path.abspath(os.path.join(dir_path,os.pardir)) parent_dir_path = os.path.abspath(os.path.join(dir_path,os.pardir))
sys.path.insert(0, parent_dir_path) sys.path.insert(0, parent_dir_path)
#sys.path.append('../')
from lf_report import lf_report from lf_report import lf_report
sys.path.append('/') sys.path.append('/')
@@ -121,7 +121,7 @@ class lf_check():
report_url=report_file.replace('/home/lanforge/', '') report_url=report_file.replace('/home/lanforge/', '')
if report_url.startswith('/'): if report_url.startswith('/'):
report_url = report_url[1:] report_url = report_url[1:]
# Following recommendation # following recommendation
# NOTE: https://stackoverflow.com/questions/24196932/how-can-i-get-the-ip-address-from-nic-in-python # NOTE: https://stackoverflow.com/questions/24196932/how-can-i-get-the-ip-address-from-nic-in-python
#command = 'echo "$HOSTNAME mail system works!" | mail -s "Test: $HOSTNAME $(date)" chuck.rekiere@candelatech.com' #command = 'echo "$HOSTNAME mail system works!" | mail -s "Test: $HOSTNAME $(date)" chuck.rekiere@candelatech.com'
hostname = socket.gethostname() hostname = socket.gethostname()
@@ -196,8 +196,8 @@ NOTE: for now to see stdout and stderr remove /home/lanforge from path.
<br> <br>
""" """
# Functions in this section are/can be overridden by descendants # functions in this section are/can be overridden by descendants
# This code reads the lf_check_config.ini file to populate the test variables # this code reads the lf_check_config.ini file to populate the test variables
def read_config_contents(self): def read_config_contents(self):
self.logger.info("read_config_contents {}".format(self.config_ini)) self.logger.info("read_config_contents {}".format(self.config_ini))
config_file = configparser.ConfigParser() config_file = configparser.ConfigParser()
@@ -283,7 +283,7 @@ NOTE: for now to see stdout and stderr remove /home/lanforge from path.
out, err = process.communicate() out, err = process.communicate()
errcode = process.returncode errcode = process.returncode
# Not currently used # not currently used
def load_blank_db(self): def load_blank_db(self):
#self.logger.info("file_wd {}".format(self.scripts_wd)) #self.logger.info("file_wd {}".format(self.scripts_wd))
try: try:
@@ -320,10 +320,10 @@ NOTE: for now to see stdout and stderr remove /home/lanforge from path.
self.logger.info("test: {} skipped".format(test)) self.logger.info("test: {} skipped".format(test))
# load the default database # load the default database
elif self.test_dict[test]['enabled'] == "TRUE": elif self.test_dict[test]['enabled'] == "TRUE":
# Make the command replace ment a separate method call. # make the command replace ment a separate method call.
# loop through radios # loop through radios
for radio in self.radio_dict: for radio in self.radio_dict:
# Replace RADIO, SSID, PASSWD, SECURITY with actual config values (e.g. RADIO_0_CFG to values) # replace RADIO, SSID, PASSWD, SECURITY with actual config values (e.g. RADIO_0_CFG to values)
# not "KEY" is just a word to refer to the RADIO define (e.g. RADIO_0_CFG) to get the vlaues # not "KEY" is just a word to refer to the RADIO define (e.g. RADIO_0_CFG) to get the vlaues
# --num_stations needs to be int not string (no double quotes) # --num_stations needs to be int not string (no double quotes)
if self.radio_dict[radio]["KEY"] in self.test_dict[test]['args']: if self.radio_dict[radio]["KEY"] in self.test_dict[test]['args']:
@@ -395,7 +395,7 @@ NOTE: for now to see stdout and stderr remove /home/lanforge from path.
print("running {}".format(command)) print("running {}".format(command))
try: try:
process = subprocess.Popen((command).split(' '), shell=False, stdout=stdout_log, stderr=stderr_log, universal_newlines=True) process = subprocess.Popen((command).split(' '), shell=False, stdout=stdout_log, stderr=stderr_log, universal_newlines=True)
# If there is a better solution please propose, the TIMEOUT Result is different then FAIL # if there is a better solution please propose, the TIMEOUT Result is different then FAIL
try: try:
#out, err = process.communicate() #out, err = process.communicate()
process.wait(timeout=int(self.test_timeout)) process.wait(timeout=int(self.test_timeout))
@@ -472,14 +472,14 @@ for running scripts listed in lf_check_config.ini
args = parser.parse_args() args = parser.parse_args()
# Load test config file information # load test config file information
config_ini = os.getcwd() + '/' + args.ini config_ini = os.getcwd() + '/' + args.ini
if os.path.exists(config_ini): if os.path.exists(config_ini):
print("TEST CONFIG : {}".format(config_ini)) print("TEST CONFIG : {}".format(config_ini))
else: else:
print("EXITING: NOTFOUND TEST CONFIG : {} ".format(config_ini)) print("EXITING: NOTFOUND TEST CONFIG : {} ".format(config_ini))
exit(1) exit(1)
# Select test suite # select test suite
test_suite = args.suite test_suite = args.suite
if args.production: if args.production:
@@ -489,8 +489,7 @@ for running scripts listed in lf_check_config.ini
production = False production = False
print("Email to email list") print("Email to email list")
# create report class for reporting
# Create Report Class for reporting
report = lf_report(_results_dir_name="lf_check", report = lf_report(_results_dir_name="lf_check",
_output_html="lf_check.html", _output_html="lf_check.html",
_output_pdf="lf-check.pdf") _output_pdf="lf-check.pdf")
@@ -508,13 +507,13 @@ for running scripts listed in lf_check_config.ini
_csv_results = csv_results, _csv_results = csv_results,
_outfile = outfile_path) _outfile = outfile_path)
# Get git sha # get git sha
process = subprocess.Popen(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE) process = subprocess.Popen(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE)
(commit_hash, err) = process.communicate() (commit_hash, err) = process.communicate()
exit_code = process.wait() exit_code = process.wait()
git_sha = commit_hash.decode('utf-8','ignore') git_sha = commit_hash.decode('utf-8','ignore')
# Set Up logging # set up logging
logfile = args.logfile[:-4] logfile = args.logfile[:-4]
print("logfile: {}".format(logfile)) print("logfile: {}".format(logfile))
logfile = "{}-{}.log".format(logfile,current_time) logfile = "{}-{}.log".format(logfile,current_time)
@@ -531,11 +530,11 @@ for running scripts listed in lf_check_config.ini
logger.info("commit_hash: {}".format(commit_hash)) logger.info("commit_hash: {}".format(commit_hash))
logger.info("commit_hash2: {}".format(commit_hash.decode('utf-8','ignore'))) logger.info("commit_hash2: {}".format(commit_hash.decode('utf-8','ignore')))
# READ Config and RUN Tests # read config and run tests
check.read_config_contents() check.read_config_contents()
check.run_script_test() check.run_script_test()
# Generate Ouptput reports # generate output reports
report.set_title("LF Check: lf_check.py") report.set_title("LF Check: lf_check.py")
report.build_banner() report.build_banner()
report.start_content_div() report.start_content_div()
@@ -550,7 +549,6 @@ for running scripts listed in lf_check_config.ini
print("html report: {}".format(html_report)) print("html report: {}".format(html_report))
report.write_pdf_with_timestamp() report.write_pdf_with_timestamp()
report_path = os.path.dirname(html_report) report_path = os.path.dirname(html_report)
parent_report_dir = os.path.dirname(report_path) parent_report_dir = os.path.dirname(report_path)
@@ -559,7 +557,6 @@ for running scripts listed in lf_check_config.ini
# duplicates html_report file up one directory # duplicates html_report file up one directory
lf_check_html_report = parent_report_dir + "/{}.html".format(outfile) lf_check_html_report = parent_report_dir + "/{}.html".format(outfile)
#
banner_src_png = report_path + "/banner.png" banner_src_png = report_path + "/banner.png"
banner_dest_png = parent_report_dir + "/banner.png" banner_dest_png = parent_report_dir + "/banner.png"
CandelaLogo_src_png = report_path + "/CandelaLogo2-90dpi-200x90-trans.png" CandelaLogo_src_png = report_path + "/CandelaLogo2-90dpi-200x90-trans.png"