From 6e332860d5996cf631f9b88a6e997ac90748d9f3 Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Tue, 18 May 2021 05:42:00 -0600 Subject: [PATCH] lf_check.py : added timeout on Popen Signed-off-by: Chuck SmileyRekiere --- py-scripts/tools/lf_check.py | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/py-scripts/tools/lf_check.py b/py-scripts/tools/lf_check.py index 2c221c89..e26b1753 100755 --- a/py-scripts/tools/lf_check.py +++ b/py-scripts/tools/lf_check.py @@ -276,22 +276,31 @@ class lf_check(): process = subprocess.Popen((command).split(' '), shell=False, stdout=stdout_log, stderr=stderr_log, universal_newlines=True) try: - out, err = process.communicate() - except: - if err: - self.logger.info("command Test timed out: {}".format(command)) + #out, err = process.communicate() + process.wait(timeout=120) + except subprocess.TimeoutExpired: + process.terminate() + self.test_result = "TIMEOUT" + + #if err: + # self.logger.info("command Test timed out: {}".format(command)) #self.logger.info(stderr_log_txt) - stderr_log_size = os.path.getsize(stderr_log_txt) - if stderr_log_size > 0 : - self.logger.info("File: {} is not empty: {}".format(stderr_log_txt,str(stderr_log_size))) + if(self.test_result != "TIMEOUT"): + stderr_log_size = os.path.getsize(stderr_log_txt) + if stderr_log_size > 0 : + self.logger.info("File: {} is not empty: {}".format(stderr_log_txt,str(stderr_log_size))) - self.test_result = "Failure" - background = self.background_red + self.test_result = "Failure" + background = self.background_red + else: + self.logger.info("File: {} is empty: {}".format(stderr_log_txt,str(stderr_log_size))) + self.test_result = "Success" + background = self.background_green else: - self.logger.info("File: {} is empty: {}".format(stderr_log_txt,str(stderr_log_size))) - self.test_result = "Success" - background = self.background_green + self.logger.info("TIMEOUT FAILURE, Check LANforge Radios") + self.test_result = "Time Out" + background = self.background_purple self.html_results += """ """ + str(test) + """""" + str(command) + """ @@ -299,6 +308,8 @@ class lf_check(): STDOUT""" if self.test_result == "Failure": self.html_results += """STDERR""" + elif self.test_result == "Time Out": + self.html_results += """STDERR""" else: self.html_results += """""" self.html_results += """"""