@@ -194,6 +194,7 @@ def check_if_other_machines_failed_in_linked_run():
194194
195195# downloads attachments for a test case
196196def create_tc_log_ss_folder (run_id , test_case , temp_ini_file , server_version ):
197+ sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
197198 try :
198199 log_file_path = ConfigModule .get_config_value (
199200 "sectionOne" , "temp_run_file_path" , temp_ini_file
@@ -208,21 +209,25 @@ def create_tc_log_ss_folder(run_id, test_case, temp_ini_file, server_version):
208209 # create test_case_folder
209210 ConfigModule .add_config_value ("sectionOne" , "test_case" , test_case , temp_ini_file )
210211 ConfigModule .add_config_value ("sectionOne" , "test_case_folder" , test_case_folder , temp_ini_file )
212+ CommonUtil .ExecLog (sModuleInfo , f"Creating folder: { test_case_folder } " , 5 )
211213 FL .CreateFolder (test_case_folder )
212214
213215 # create log_folder for browser console error logs
214216 log_folder = test_case_folder + os .sep + "Log"
215217 ConfigModule .add_config_value ("sectionOne" , "log_folder" , log_folder , temp_ini_file )
218+ CommonUtil .ExecLog (sModuleInfo , f"Creating folder: { log_folder } " , 5 )
216219 FL .CreateFolder (log_folder )
217220
218221 # create screenshot_folder
219222 screenshot_folder = test_case_folder + os .sep + "screenshots"
220223 ConfigModule .add_config_value ("sectionOne" , "screen_capture_folder" , screenshot_folder , temp_ini_file )
224+ CommonUtil .ExecLog (sModuleInfo , f"Creating folder: { screenshot_folder } " , 5 )
221225 FL .CreateFolder (screenshot_folder )
222226
223227 # performance report folder
224228 performance_report = test_case_folder + os .sep + "performance_report"
225229 ConfigModule .add_config_value ("sectionOne" , "performance_report" , performance_report , temp_ini_file )
230+ CommonUtil .ExecLog (sModuleInfo , f"Creating folder: { performance_report } " , 5 )
226231 FL .CreateFolder (performance_report )
227232
228233 # TODO: we'll be breaking internal server compatibility anyway
@@ -231,14 +236,17 @@ def create_tc_log_ss_folder(run_id, test_case, temp_ini_file, server_version):
231236 # json report folder
232237 json_report = test_case_folder + os .sep + "json_report"
233238 ConfigModule .add_config_value ("sectionOne" , "json_report" , json_report , temp_ini_file )
239+ CommonUtil .ExecLog (sModuleInfo , f"Creating folder: { json_report } " , 5 )
234240 FL .CreateFolder (json_report )
235241
236242 # create where attachments from selenium browser will be
237243 # downloaded
238244 # ? Why are we keeping two separate download folders?
239245 zeuz_download_folder = test_case_folder + os .sep + "zeuz_download_folder"
246+ CommonUtil .ExecLog (sModuleInfo , f"Creating folder: { zeuz_download_folder } " , 5 )
240247 FL .CreateFolder (zeuz_download_folder )
241248 initial_download_folder = run_id_folder + os .sep + "initial_download_folder"
249+ CommonUtil .ExecLog (sModuleInfo , f"Creating folder: { initial_download_folder } " , 5 )
242250 FL .CreateFolder (initial_download_folder )
243251 ConfigModule .add_config_value ("sectionOne" , "initial_download_folder" , initial_download_folder , temp_ini_file )
244252 shared .Set_Shared_Variables ("zeuz_download_folder" , zeuz_download_folder )
@@ -290,13 +298,10 @@ def call_driver_function_of_test_step(
290298 # get step driver
291299 current_driver = all_step_info [StepSeq - 1 ]["step_driver_type" ]
292300 # current_driver = "Built_In_Driver"
293- print (f"DRIVER: { current_driver } " )
294-
295301 try :
296302 current_driver = "Drivers." + current_driver
297303 # if CommonUtil.step_module_name is None:
298304 module_name = importlib .import_module (current_driver ) # get module
299- print ("STEP DATA and VARIABLES" )
300305 # get step name
301306 if all_step_info [StepSeq - 1 ]["step_function" ]:
302307 step_name = all_step_info [StepSeq - 1 ]["step_function" ].strip ()
@@ -397,7 +402,6 @@ def call_driver_function_of_test_step(
397402 sStepResult = "zeuz_failed"
398403 q .put (sStepResult )
399404 except Exception as e :
400- print ("### Exception : {}" .format (e ))
401405 CommonUtil .Exception_Handler (sys .exc_info ())
402406 sStepResult = "zeuz_failed"
403407
@@ -734,14 +738,16 @@ def zip_and_delete_tc_folder_old(
734738 send_log_file_only_for_fail = True ,
735739):
736740 # if settings checked, then send log file or screenshots, otherwise don't send
741+ sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
737742 if sTestCaseStatus not in passed_tag_list or sTestCaseStatus in passed_tag_list and not send_log_file_only_for_fail :
738743 if ConfigModule .get_config_value ("RunDefinition" , "local_run" ) == "False" :
739744 FL .ZipFolder (
740745 ConfigModule .get_config_value ("sectionOne" , "test_case_folder" , temp_ini_file ),
741746 ConfigModule .get_config_value ("sectionOne" , "test_case_folder" , temp_ini_file ) + ".zip" ,
742747 )
743- # Delete the folder
744- FL .DeleteFolder (ConfigModule .get_config_value ("sectionOne" , "test_case_folder" , temp_ini_file ))
748+ path = ConfigModule .get_config_value ("sectionOne" , "test_case_folder" , temp_ini_file )
749+ CommonUtil .ExecLog (sModuleInfo , f"Deleting folder: { path } " , 5 )
750+ FL .DeleteFolder (path )
745751
746752
747753# writes the log file for a test case
@@ -754,6 +760,7 @@ def zip_and_delete_tc_folder(
754760
755761):
756762 # if settings checked, then send log file or screenshots, otherwise don't send
763+ sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
757764 if sTestCaseStatus not in passed_tag_list or sTestCaseStatus in passed_tag_list and not send_log_file_only_for_fail :
758765 if ConfigModule .get_config_value ("RunDefinition" , "local_run" ) == "False" :
759766 all_steps = CommonUtil .all_logs_json [CommonUtil .runid_index ]["test_cases" ][CommonUtil .tc_index ]["steps" ]
@@ -768,7 +775,9 @@ def zip_and_delete_tc_folder(
768775 str (Path (ConfigModule .get_config_value ("sectionOne" , "test_case_folder" , temp_ini_file )).parent / zip_name ),
769776 )
770777 # Delete the folder
771- FL .DeleteFolder (ConfigModule .get_config_value ("sectionOne" , "test_case_folder" , temp_ini_file ))
778+ path = ConfigModule .get_config_value ("sectionOne" , "test_case_folder" , temp_ini_file )
779+ CommonUtil .ExecLog (sModuleInfo , f"Deleting folder: { path } " , 5 )
780+ FL .DeleteFolder (path )
772781
773782
774783def cleanup_driver_instances (): # cleans up driver(selenium, appium) instances
@@ -1184,7 +1193,7 @@ def set_device_info_according_to_user_order(device_order, device_dict, test_cas
11841193
11851194 # Todo: check the device_order if it is mobile or web (reimagine after deploy v3)
11861195 elif "web" in device_order :
1187- print ( " found web from new device_info" )
1196+ CommonUtil . ExecLog ( "set_device_info_according_to_user_order" , " found web from new device_info", 1 )
11881197 elif "mobile" in device_order :
11891198 if "local" in device_order ["mobile" ]:
11901199 pass
@@ -1359,6 +1368,7 @@ def check_run_cancel(run_id):
13591368def upload_reports_and_zips (Userid , temp_ini_file , run_id ):
13601369 try :
13611370 if CommonUtil .debug_status : return
1371+ sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
13621372 zip_dir = Path (ConfigModule .get_config_value ("sectionOne" , "temp_run_file_path" , temp_ini_file ))/ run_id .replace (":" , "-" )/ CommonUtil .current_session_name
13631373
13641374 if ConfigModule .get_config_value ("RunDefinition" , "local_run" ) == "False" and CommonUtil .run_cancel != CANCELLED_TAG :
@@ -1384,7 +1394,7 @@ def upload_reports_and_zips(Userid, temp_ini_file, run_id):
13841394 file_name = CommonUtil .processed_performance_data ["tc_id" ].replace (":" , "-" ) + ".html"
13851395 with open (zip_dir / file_name , "w" , encoding = "utf-8" ) as file :
13861396 file .write (html )
1387- print ( "Preformance report template generated successfully!" )
1397+ CommonUtil . ExecLog ( sModuleInfo , "Preformance report template generated successfully!" , 1 )
13881398 CommonUtil .processed_performance_data .clear ()
13891399 perf_report_html = open (zip_dir / file_name , 'rb' )
13901400
@@ -1408,18 +1418,17 @@ def upload_reports_and_zips(Userid, temp_ini_file, run_id):
14081418
14091419
14101420 if res .status_code == 200 :
1411- print (f"Successfully uploaded the execution report of run_id { run_id } " )
1421+ CommonUtil .ExecLog (sModuleInfo , f"Successfully uploaded the execution report of run_id { run_id } " , 1 )
1422+
14121423 break
14131424 else :
1414- print (f"Failed to upload the execution report of run_id { run_id } " )
1415- print (f"Status: { res .status_code } " )
1416- print ("Retrying..." )
1425+ CommonUtil .ExecLog (sModuleInfo , f"Failed to upload the execution report of run_id { run_id } \n Status: { res .status_code } \n Retrying..." , 3 )
14171426 time .sleep (4 )
14181427 except :
14191428 CommonUtil .Exception_Handler (sys .exc_info ())
14201429 time .sleep (4 )
14211430 else :
1422- print ( "Could not Upload the report to server of run_id '%s'" % run_id )
1431+ CommonUtil . ExecLog ( sModuleInfo , "Could not Upload the report to server of run_id '%s'" % run_id , 3 )
14231432
14241433 zip_files = [os .path .join (zip_dir , f ) for f in os .listdir (zip_dir ) if f .endswith (".zip" )]
14251434 opened_zips = []
@@ -1437,7 +1446,7 @@ def upload_reports_and_zips(Userid, temp_ini_file, run_id):
14371446 size = str (round (size / 1024 , 3 )) + " MB"
14381447 else :
14391448 size = str (round (size , 3 )) + " KB"
1440- print ( "Uploading %s logs-screenshots of %s testcases of %s from:\n %s" % (CommonUtil .current_session_name , len (zip_files ), size , str (zip_dir )))
1449+ CommonUtil . ExecLog ( sModuleInfo , "Uploading %s logs-screenshots of %s testcases of %s from:\n %s" % (CommonUtil .current_session_name , len (zip_files ), size , str (zip_dir )), 5 )
14411450
14421451 for _ in range (5 ):
14431452 try :
@@ -1453,22 +1462,18 @@ def upload_reports_and_zips(Userid, temp_ini_file, run_id):
14531462 try :
14541463 res_json = res .json ()
14551464 except :
1456- # print("Could not Upload logs-screenshots to server")
1457- # print("\nResponse Text = " + res.text + "\n")
1458- # break
14591465 continue
14601466 if isinstance (res_json , dict ) and 'message' in res_json and res_json ["message" ]:
1461- print ( "Successfully Uploaded logs-screenshots to server of run_id '%s'" % run_id )
1467+ CommonUtil . ExecLog ( sModuleInfo , "Successfully Uploaded logs-screenshots to server of run_id '%s'" % run_id , 1 )
14621468 else :
1463- print ("Could not Upload logs-screenshots to server of run_id '%s'" % run_id )
1464- print ("\n Response Text = " + res .text + "\n " )
1469+ CommonUtil .ExecLog (sModuleInfo , f"Could not Upload logs-screenshots to server of run_id '{ run_id } '\n \n Response Text = { res .text } " , 3 )
14651470 break
14661471 except :
14671472 pass
14681473
14691474 time .sleep (4 )
14701475 else :
1471- print ( "Could not Upload logs-screenshots to server of run_id '%s'" % run_id )
1476+ CommonUtil . ExecLog ( sModuleInfo , "Could not Upload logs-screenshots to server of run_id '%s'" % run_id , 3 )
14721477
14731478 with open (zip_dir / "execution_log_old_format.json" , "w" , encoding = "utf-8" ) as f :
14741479 json .dump (CommonUtil .get_all_logs (json = True ), f , indent = 2 )
@@ -1495,7 +1500,6 @@ def split_testcases(run_id_info, max_tc_in_single_session):
14951500 len_list .append (ceil (len (testcases )/ session_num ))
14961501 for _ in range (lower_num ):
14971502 len_list .append (floor (len (testcases )/ session_num ))
1498- # print("We have split %d test cases into %d sessions: %s" % (len(testcases), session_num, str(len_list)))
14991503 all_sessions = []
15001504 start = 0
15011505 for i in range (session_num ):
@@ -1547,6 +1551,7 @@ def download_attachment(attachment_info: Dict[str, Any]):
15471551
15481552def download_attachments (testcase_info ):
15491553 """Download test case and step attachments for the given test case."""
1554+ sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
15501555
15511556 temp_ini_file = os .path .join (
15521557 os .path .join (
@@ -1580,6 +1585,9 @@ def download_or_copy(attachment):
15801585 elif "global_folder" in attachment ["path" ]:
15811586 download_dir = attachment_path / "global"
15821587
1588+ if not download_dir .exists ():
1589+ CommonUtil .ExecLog (sModuleInfo , f"Creating folder: { download_dir } " , 5 )
1590+
15831591 download_dir .mkdir (parents = True , exist_ok = True )
15841592
15851593 entry = db .exists (attachment ["hash" ])
@@ -1610,7 +1618,7 @@ def download_or_copy(attachment):
16101618
16111619 results = ThreadPool (4 ).imap_unordered (download_attachment , urls )
16121620 for r in results :
1613- print ( "Downloaded: %s" % r )
1621+ CommonUtil . ExecLog ( sModuleInfo , f "Downloaded: { r } " , 5 )
16141622
16151623 # Copy into the attachments db.
16161624 attachment_path_in_db = attachment_db_path / r ["path" ].name
@@ -1673,6 +1681,7 @@ def main(device_dict, all_run_id_info):
16731681
16741682 # Write testcase json
16751683 path = ConfigModule .get_config_value ("sectionOne" , "temp_run_file_path" , temp_ini_file ) / Path (run_id .replace (":" , "-" ))
1684+ CommonUtil .ExecLog (sModuleInfo , f"Creating folder: { path } " , 5 )
16761685 FL .CreateFolder (path )
16771686
16781687 if run_id .lower ().startswith ("debug" ):
@@ -1712,11 +1721,6 @@ def main(device_dict, all_run_id_info):
17121721 }
17131722 device_order = formated_device_order
17141723
1715- final_dependency = run_id_info ["dependency_list" ]
1716- shared .Set_Shared_Variables ("dependency" , final_dependency , protected = True )
1717- # is_linked = run_id_info["is_linked"]
1718- final_run_params_from_server = run_id_info ["run_time" ]
1719-
17201724 runtime_settings = run_id_info ["runtime_settings" ]
17211725 if not CommonUtil .debug_status :
17221726 rem_config = {
@@ -1749,6 +1753,10 @@ def main(device_dict, all_run_id_info):
17491753 shared .Clean_Up_Shared_Variables (run_id )
17501754 driver_list = ["Not needed currently" ]
17511755
1756+ final_dependency = run_id_info ["dependency_list" ]
1757+ shared .Set_Shared_Variables ("dependency" , final_dependency , protected = True )
1758+
1759+ final_run_params_from_server = run_id_info ["run_time" ]
17521760 final_run_params = {}
17531761 for param in final_run_params_from_server :
17541762 final_run_params [param ] = CommonUtil .parse_value_into_object (list (final_run_params_from_server [param ].items ())[1 ][1 ])
@@ -1783,7 +1791,6 @@ def main(device_dict, all_run_id_info):
17831791 while i < len (all_testcases_info ):
17841792 if all_testcases_info [i ]["automatability" ] != "Automated" and all_testcases_info [i ]["automatability" ] != "Performance" :
17851793 CommonUtil .ExecLog ("" , all_testcases_info [i ]["testcase_no" ] + " is not automated so skipping" , 2 )
1786- # print(all_testcases_info[i]["testcase_no"] + " is not automated so skipping")
17871794 del all_testcases_info [i ]
17881795 i -= 1
17891796 i += 1
@@ -1814,7 +1821,6 @@ def main(device_dict, all_run_id_info):
18141821 CommonUtil .tc_nums [run_id ] = []
18151822 for i in [int (i ['testcase_no' ].split ('-' )[- 1 ]) for i in all_testcases_info ]:
18161823 i not in CommonUtil .tc_nums [run_id ] and CommonUtil .tc_nums [run_id ].append (i )
1817- # print("Starting %s with %s test cases" % (CommonUtil.current_session_name, len(all_testcases_info)))
18181824
18191825 for testcase_info in all_testcases_info :
18201826 performance_test_case = False
@@ -1900,7 +1906,6 @@ def kill(process):
19001906 finally :
19011907 my_timer .cancel () # cancel timer
19021908 except Exception as e :
1903- print ("exception" )
19041909 pass
19051910 # add log
19061911 CommonUtil .ExecLog (sModuleInfo , "Uploading Performance Test Results" , 1 )
@@ -1912,7 +1917,7 @@ def kill(process):
19121917 sModuleInfo , "Performance Test Results Uploaded Successfully" , 1
19131918 )
19141919 except Exception as e :
1915- print ( e )
1920+ CommonUtil . ExecLog ( sModuleInfo , e , 3 )
19161921 run_test_case (
19171922 test_case_no ,
19181923 sModuleInfo ,
@@ -1927,7 +1932,6 @@ def kill(process):
19271932 CommonUtil .clear_all_logs () # clear logs
19281933 if CommonUtil .run_cancel == CANCELLED_TAG :
19291934 break
1930- # print("Executed %s test cases" % cnt)
19311935 cnt += 1
19321936
19331937
@@ -1946,7 +1950,6 @@ def kill(process):
19461950 CommonUtil .clear_all_logs () # clear logs
19471951 if CommonUtil .run_cancel == CANCELLED_TAG :
19481952 break
1949- # print("Executed %s test cases" % cnt)
19501953
19511954 cnt += 1
19521955 CommonUtil .tc_index += 1
@@ -1972,15 +1975,12 @@ def kill(process):
19721975 upload_reports_and_zips (Userid , temp_ini_file , run_id )
19731976
19741977 session_cnt += 1
1975-
1976- print ("Execution time = %s sec" % round (TimeDiff , 3 ))
1977- # print("Report creation time = %s sec for %s testcases" % (round(CommonUtil.report_json_time, 3), num_of_tc))
1978- # print("Test Set Completed")
1978+ CommonUtil .ExecLog (sModuleInfo , "Execution time = %s sec" % round (TimeDiff , 3 ), 5 )
19791979
19801980 ConfigModule .add_config_value ("sectionOne" , "sTestStepExecLogId" , "MainDriver" , temp_ini_file )
19811981
19821982 if CommonUtil .run_cancel == CANCELLED_TAG :
1983- print ( "Test Set Cancelled by the User" )
1983+ CommonUtil . ExecLog ( sModuleInfo , "Test Set Cancelled by the User" , 5 )
19841984 elif not CommonUtil .debug_status :
19851985
19861986 from shutil import copytree
@@ -2009,8 +2009,6 @@ def kill(process):
20092009
20102010 # Close websocket connection.
20112011 elif CommonUtil .debug_status :
2012- # ws.close()
2013- # print("[LIVE LOG] Disconnected from Live Log service")
20142012 pass
20152013 CommonUtil .runid_index += 1
20162014
0 commit comments