diff --git a/harness/bin/test_harness_driver.py b/harness/bin/test_harness_driver.py index 79e534b1..dd3c4c0e 100755 --- a/harness/bin/test_harness_driver.py +++ b/harness/bin/test_harness_driver.py @@ -148,8 +148,6 @@ def auto_generated_scripts(harness_config, """ - messloc = "In function {functionname}:".format(functionname="auto_generated_scripts") - status_dir = apptest.get_path_to_status() ra_dir = apptest.get_path_to_runarchive() @@ -167,7 +165,7 @@ def auto_generated_scripts(harness_config, try: build_exit_value = mymachine.build_executable() except SetBuildRTEError as error: - message = f"{messloc} Unable to set the build runtime environnment." + message = f"Unable to set the build runtime environnment." message += error.message a_logger.doCriticalLogging(message) finally: @@ -185,7 +183,7 @@ def auto_generated_scripts(harness_config, submit_exit_value = 0 if actions['submit'] and (build_exit_value != 0): submit_exit_value = 1 - message = f"{messloc} No submit action due to prior failed build." + message = f"No submit action due to prior failed build." a_logger.doCriticalLogging(message) elif actions['submit'] and (build_exit_value == 0): @@ -236,7 +234,7 @@ def auto_generated_scripts(harness_config, if job_id != "0": jstatus.log_event(status_file.StatusFile.EVENT_JOB_QUEUED, job_id) else: - message = f"{messloc} Submit error, failed to retrieve the job id." + message = f"Submit error, failed to retrieve the job id." a_logger.doCriticalLogging(message) submit_exit_value = 1 else: @@ -268,7 +266,7 @@ def auto_generated_scripts(harness_config, run_exit_value = p.returncode run_stdout.close() else: - message = f"{messloc} Run error, failed to retrieve the job id." + message = f"Run error, failed to retrieve the job id." a_logger.doCriticalLogging(message) run_exit_value = 1 @@ -286,7 +284,7 @@ def auto_generated_scripts(harness_config, mymachine.start_report_executable() mymachine.log_to_db() else: - message = f"{messloc} check error, failed to retrieve the job id." + message = f"Check error, failed to retrieve the job id." a_logger.doCriticalLogging(message) check_exit_value = 1 diff --git a/harness/libraries/apptest.py b/harness/libraries/apptest.py index 0042b9d6..5e5c22f1 100644 --- a/harness/libraries/apptest.py +++ b/harness/libraries/apptest.py @@ -542,16 +542,15 @@ def _start_test(self, run_as_subprocess_command_return_exitstatus(starttestcomand, command_execution_directory=pathtoscripts) if exit_status > 0: - message = ( "In function {function_name} we have a critical error.\n" - "The command '{cmd}' has exited with a failure.\n" - "The exit return value is {value}\n.").format(function_name=self.__name_of_current_function(), cmd=starttestcomand,value=exit_status) + message = ( "The command '{cmd}' has exited with a failure.\n" + "The exit return value is {value}\n.").format(cmd=starttestcomand,value=exit_status) self.logger.doCriticalLogging(message) string1 = "Command failed: " + starttestcomand return 1 else: - message = "In function {function_name}, the command '{cmd}' has executed sucessfully.\n".format(function_name=self.__name_of_current_function(),cmd=starttestcomand) + message = "'{cmd}' has executed sucessfully.\n".format(cmd=starttestcomand) message += "stdout of command : {}\n".format(stdout) message += "stderr of command : {}\n".format(stderr) self.logger.doInfoLogging(message) @@ -561,7 +560,7 @@ def _stop_test(self): with open(pathtokillfile,"w") as kill_file: kill_file.write("") - message = "In function {function_name}, The kill file '{filename}' has been created.\n".format(function_name=self.__name_of_current_function(),filename=pathtokillfile) + message = "The kill file '{filename}' has been created.\n".format(filename=pathtokillfile) self.logger.doInfoLogging(message) def _run_db_extensions(self): diff --git a/harness/machine_types/base_machine.py b/harness/machine_types/base_machine.py index a5a4a399..14565ce9 100644 --- a/harness/machine_types/base_machine.py +++ b/harness/machine_types/base_machine.py @@ -180,9 +180,7 @@ def submit_batch_script(self): The exit status of submitting the batch script to the scheduler. An exit_status of 0 indicates success, other wise failure. """ - messloc = "In function {functionname}:".format(functionname=self._name_of_current_function()) - - message = f"{messloc} Submitting a batch script." + message = f"Submitting a batch script." self.logger.doInfoLogging(message) currentdir = os.getcwd() @@ -195,20 +193,20 @@ def submit_batch_script(self): try: if filename != "": - message = f"{messloc} The submit runtime environmental file is {filename}." + message = f"The submit runtime environmental file is {filename}." self.logger.doInfoLogging(message) new_env = linux_utilities.get_new_environment(self,filename) except SetBuildRTEError as error: - message = f"{messloc} Unable to set the submit runtime environment." + message = f"Unable to set the submit runtime environment." self.logger.doCriticalLogging(message) exit_status = linux_utilities.submit_batch_script(self,new_env) if exit_status != 0: - message = f"{messloc} Unsuccessful batch script submission with exit status of {exit_status}." + message = f"Unsuccessful batch script submission with exit status of {exit_status}." self.logger.doCriticalLogging(message) else: - message = f"{messloc} Successful batch script submission with exit status of {exit_status}." + message = f"Successful batch script submission with exit status of {exit_status}." self.logger.doInfoLogging(message) return exit_status @@ -273,9 +271,7 @@ def build_executable(self): The exit status of the build command. """ - messloc = "In function {functionname}:".format(functionname=self._name_of_current_function()) - - message = f"{messloc} Start of buiding executable.\n" + message = f"Start of buiding executable.\n" self.logger.doInfoLogging(message) currentdir = os.getcwd() @@ -292,7 +288,7 @@ def build_executable(self): if not copy_rc == 0: return copy_rc - message = f"{messloc} Copied source to build directory.\n" + message = f"Copied source to build directory.\n" self.logger.doInfoLogging(message) # Get the environment using the build runtime environment file. @@ -300,23 +296,23 @@ def build_executable(self): filename = self.build_runtime_environment_command_file if filename != "": - message = f"{messloc} The build runtime environmental file is {filename}." + message = f"The build runtime environmental file is {filename}." self.logger.doInfoLogging(message) new_env = linux_utilities.get_new_environment(self,filename) - message = f"{messloc} The new build environment is as follows:\n" + message = f"The new build environment is as follows:\n" message += str(new_env) self.logger.doInfoLogging(message) # We now change directories to the build directory. os.chdir(path_to_build_directory) - message = f"{messloc} Changed to build directory {path_to_build_directory}. Commencing build ..." + message = f"Changed to build directory {path_to_build_directory}. Commencing build ..." self.logger.doInfoLogging(message) # We run the build command. exit_status = self._build_executable(new_env) - message = f"{messloc} The build exit status is {exit_status}." + message = f"The build exit status is {exit_status}." if exit_status == 0: self.logger.doInfoLogging(message) else: @@ -325,10 +321,10 @@ def build_executable(self): # We now change back to starting directory. os.chdir(currentdir) - message = f"{messloc} Changed back to Scripts directory {currentdir}." + message = f"Changed back to Scripts directory {currentdir}." self.logger.doInfoLogging(message) - message = f"{messloc} End of buiding executable." + message = f"End of buiding executable." self.logger.doInfoLogging(message) return exit_status @@ -341,9 +337,6 @@ def check_executable(self): int : The exist status of the check command. """ - - messloc = "In function {functionname}:".format(functionname=self._name_of_current_function()) - currentdir = os.getcwd() runarchive_dir = self.apptest.get_path_to_runarchive() @@ -352,16 +345,16 @@ def check_executable(self): filename = self.check_runtime_environment_command_file try: if filename != "": - message = f"{messloc} The check runtime environmental file is {filename}." + message = f"The check runtime environmental file is {filename}." new_env = linux_utilities.get_new_environment(self,filename) except SetBuildRTEError as error: - message = f"{messloc} Unable to set the check runtime environment." + message = f"Unable to set the check runtime environment." self.logger.doCriticalLogging(message) # We now change to the runarchive directory. os.chdir(runarchive_dir) - message = f"{messloc} The current working directory is {runarchive_dir} " + message = f"The current working directory is {runarchive_dir} " self.logger.doInfoLogging(message) # We now run the check command. @@ -372,7 +365,7 @@ def check_executable(self): # We now change back to starting directory. os.chdir(currentdir) - message = f"{messloc} The current working directory is {currentdir} " + message = f"The current working directory is {currentdir} " self.logger.doInfoLogging(message) return check_status @@ -386,8 +379,7 @@ def start_report_executable(self): """ report_command_str = self.test_config.get_report_command() - messloc = "In function {functionname}: ".format(functionname=self._name_of_current_function()) - message = f"{messloc} Running report executable script report script {report_command_str }." + message = f"Running report executable script report script {report_command_str }." print(message) self.logger.doInfoLogging(message) @@ -403,8 +395,7 @@ def log_to_db(self): ------ bool: Success (True), otherwise, not logged to Databases """ - messloc = "In function {functionname}: ".format(functionname=self._name_of_current_function()) - message = f"{messloc} attempting to log to Databases." + message = f"Attempting to log to Databases." self.logger.doInfoLogging(message) @@ -436,8 +427,6 @@ def _submit_batch_script(self,new_env): return exit_status def _copy_source_to_build_directory(self): - messloc = "In function {functionname}:".format(functionname=self._name_of_current_function()) - path_to_source = self.apptest.get_path_to_source() path_to_test_source = self.apptest.get_path_to_test_source() # Use Error threshold to show this message all the time @@ -472,11 +461,10 @@ def _copy_source_to_build_directory(self): def _write_check_exit_status(self, cstatus): """ Write the status of checking results to the status directory.""" - messloc = "In function {functionname}:".format(functionname=self._name_of_current_function()) status_file = self.apptest.get_path_to_job_status_file() with open(status_file, "w") as file_obj: - message = f"{messloc} Writing check_exit_status {cstatus} into {status_file}" + message = f"Writing check_exit_status {cstatus} into {status_file}" self.logger.doInfoLogging(message) file_obj.write(str(cstatus)) return diff --git a/harness/machine_types/linux_utilities.py b/harness/machine_types/linux_utilities.py index c5794f0d..56d8bedd 100644 --- a/harness/machine_types/linux_utilities.py +++ b/harness/machine_types/linux_utilities.py @@ -138,13 +138,11 @@ def check_executable(a_machine,new_env): my_current_frame = inspect.currentframe() my_current_frame_info = inspect.getframeinfo(my_current_frame) my_functioname = my_current_frame_info.function - messloc = "In function {functionname}:".format(functionname=my_functioname ) - checkcmd = a_machine.check_command path_to_checkscript = a_machine.apptest.get_path_to_scripts() check_command_line = _form_proper_command_line(path_to_checkscript,checkcmd) - message = f"{messloc} The check command line is {check_command_line}." + message = f"The check command line is {check_command_line}." a_machine.logger.doInfoLogging(message) check_outfile = "output_check.txt" @@ -160,7 +158,7 @@ def check_executable(a_machine,new_env): check_exit_status = p.returncode - message = f"{messloc} The check command return code {check_exit_status}." + message = f"The check command return code {check_exit_status}." a_machine.logger.doInfoLogging(message) return check_exit_status @@ -384,7 +382,6 @@ def build_executable(a_machine, new_env): # Get the name of the current function. frame = inspect.currentframe() function_name = inspect.getframeinfo(frame).function - messloc = "In function {functionname}:".format(functionname=function_name ) # Update the build environment env_vars = a_machine.test_config.test_environment @@ -405,7 +402,7 @@ def build_executable(a_machine, new_env): # We get the command for bulding the binary. buildcmd = a_machine.test_config.get_build_command() - message = f"{messloc} The build command: {buildcmd}" + message = f"The build command: {buildcmd}" a_machine.logger.doInfoLogging(message) if a_machine.separate_build_stdio: @@ -429,7 +426,6 @@ def submit_batch_script(a_machine, new_env): # Get the name of the current function. frame = inspect.currentframe() function_name = inspect.getframeinfo(frame).function - messloc = "In function {functionname}:".format(functionname=function_name) # Update the batch submission environment env_vars = a_machine.test_config.test_environment @@ -452,7 +448,7 @@ def submit_batch_script(a_machine, new_env): batch_script = a_machine.test_config.get_batch_file() submit_exit_value = a_machine.submit_to_scheduler(batch_script) - message = f"{messloc} Submitted batch script {batch_script} with exit status of {submit_exit_value}." + message = f"Submitted batch script {batch_script} with exit status of {submit_exit_value}." return submit_exit_value #-----------------------------------------------------