@@ -1218,7 +1218,7 @@ def set_device_info_according_to_user_order(device_order, device_dict, test_cas
12181218 if "local" in device_order ["mobile" ]:
12191219 pass
12201220 elif "browser_stack" in device_order ["mobile" ]:
1221- project = f"PROJECT: { user_info_object ['project ' ]} & TEAM: { user_info_object ['team ' ]} "
1221+ project = f"PROJECT:{ user_info_object ['project_id ' ]} & TEAM:{ user_info_object ['team_id ' ]} "
12221222 # build = f"{test_case_no} : {test_case_name}"
12231223 build = kwargs ['run_id' ]
12241224 # Todo: session_name will be the run_id of the test case. So, we can reference with our zeuz better
@@ -1251,8 +1251,8 @@ def set_device_info_according_to_user_order(device_order, device_dict, test_cas
12511251 }
12521252 # Todo: remove this section. Changing this for new device_info.
12531253 # elif "browser_stack" in device_order and device_order["browser_stack"]:
1254- # project = user_info_object ["project"]
1255- # team = user_info_object ["team"]
1254+ # project ["project"]
1255+ # team ["team"]
12561256 #
12571257 # project = "PROJECT:'" + project + "' TEAM:'" + team + "'"
12581258 # build = test_case_no + " :: " + test_case_name
@@ -1421,21 +1421,19 @@ def upload_reports_and_zips(Userid, temp_ini_file, run_id):
14211421 for _ in range (5 ):
14221422 try :
14231423 if perf_report_html is None :
1424- res = requests . post (
1424+ res = RequestFormatter . request ( "post" ,
14251425 RequestFormatter .form_uri ("create_report_log_api/" ),
14261426 data = {"execution_report" : json .dumps (tc_report )},
1427- verify = False ,
1428- ** RequestFormatter .add_api_key_to_headers ({}))
1427+ verify = False )
14291428 else :
1430- res = requests . post (
1429+ res = RequestFormatter . request ( "post" ,
14311430 RequestFormatter .form_uri ("create_report_log_api/" ),
14321431 data = {"execution_report" : json .dumps (tc_report ),
14331432 "processed_tc_id" :processed_tc_id
14341433
14351434 },
14361435 files = [("file" ,perf_report_html )],
1437- verify = False ,
1438- ** RequestFormatter .add_api_key_to_headers ({}))
1436+ verify = False )
14391437
14401438
14411439 if res .status_code == 200 :
@@ -1475,12 +1473,11 @@ def upload_reports_and_zips(Userid, temp_ini_file, run_id):
14751473 files_list = []
14761474 for zips in opened_zips :
14771475 files_list .append (("file" ,zips ))
1478- res = requests . post (
1476+ res = RequestFormatter . request ( "post" ,
14791477 RequestFormatter .form_uri ("save_log_and_attachment_api/" ),
14801478 files = files_list ,
14811479 data = {"machine_name" : Userid },
1482- verify = False ,
1483- ** RequestFormatter .add_api_key_to_headers ({}))
1480+ verify = False )
14841481 if res .status_code == 200 :
14851482 try :
14861483 res_json = res .json ()
@@ -1564,7 +1561,7 @@ def download_attachment(attachment_info: Dict[str, Any]):
15641561 file_name = url [file_name_start_pos :]
15651562 file_path = attachment_info ["download_dir" ] / file_name
15661563
1567- r = requests . get ( url , stream = True )
1564+ r = RequestFormatter . request ( "get" , url , stream = True )
15681565 if r .status_code == requests .codes .ok :
15691566 with open (file_path , 'wb' ) as f :
15701567 for data in r .iter_content (chunk_size = 512 * 1024 ):
@@ -1659,7 +1656,7 @@ def download_or_copy(attachment):
16591656
16601657
16611658# main function
1662- def main (device_dict , user_info_object ):
1659+ def main (device_dict , all_run_id_info ):
16631660 try :
16641661 # get module info
16651662 sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
@@ -1679,8 +1676,6 @@ def main(device_dict, user_info_object):
16791676 # get local machine user id
16801677 Userid = (CommonUtil .MachineInfo ().getLocalUser ()).lower ()
16811678
1682- save_path = Path (ConfigModule .get_config_value ("sectionOne" , "temp_run_file_path" , temp_ini_file )) / "attachments"
1683-
16841679 # FIXME: Need to decide what to do with the following code or how to
16851680 # handle it differently in case there are residual folders from previous
16861681 # test cases inside the attachments folder.
@@ -1699,9 +1694,12 @@ def main(device_dict, user_info_object):
16991694 # TODO: Remove all_file_specific_steps at a later period. keeping this
17001695 # only for custom driver purpose
17011696
1702- json_path = save_path .glob ("*.zeuz.json" ).__next__ ()
1703- with open (json_path , "r" , encoding = "utf-8" ) as f :
1704- all_run_id_info = json .loads (f .read ())
1697+ # Ensure that the path exists
1698+ # save_path = Path(ConfigModule.get_config_value("sectionOne", "temp_run_file_path", temp_ini_file)) / "attachments"
1699+ # save_path.mkdir(exist_ok=True, parents=True)
1700+ # json_path = save_path.glob("*.zeuz.json").__next__()
1701+ # with open(json_path, "r", encoding="utf-8") as f:
1702+ # all_run_id_info = json.loads(f.read())
17051703
17061704 if len (all_run_id_info ) == 0 :
17071705 CommonUtil .ExecLog ("" , "No Test Run Schedule found for the current user : %s" % Userid , 2 )
@@ -1888,6 +1886,10 @@ def main(device_dict, user_info_object):
18881886 performance_test_case = True
18891887 test_case_no = testcase_info ["testcase_no" ]
18901888 test_case_name = testcase_info ["title" ]
1889+ user_info_object = {
1890+ "project_id" : run_id_info ["project_id" ],
1891+ "team_id" : str (run_id_info ["team_id" ]),
1892+ }
18911893 set_device_info_according_to_user_order (device_order , device_dict , test_case_no , test_case_name , user_info_object , Userid , run_id = run_id )
18921894 CommonUtil .disabled_step = []
18931895
0 commit comments