@@ -1327,31 +1327,31 @@ def write_log_file_for_test_case(
13271327            )
13281328
13291329            # upload will go here. 
1330-             upload_zip (
1331-                 ConfigModule .get_config_value ("Authentication" , "server_address" ),
1332-                 ConfigModule .get_config_value ("Authentication" , "server_port" ),
1333-                 ConfigModule .get_config_value ("sectionOne" , "temp_run_file_path" , temp_ini_file ),
1334-                 run_id ,
1335-                 ConfigModule .get_config_value ("sectionOne" , "test_case" , temp_ini_file ) +  ".zip" ,
1336-                 ConfigModule .get_config_value ("Advanced Options" , "_file_upload_path" ),
1337-             )
1338-             TCLogFile  =  (
1339-                 os .sep 
1340-                 +  ConfigModule .get_config_value ("Advanced Options" , "_file_upload_path" )
1341-                 +  os .sep 
1342-                 +  run_id .replace (":" , "-" )
1343-                 +  "/" 
1344-                 +  ConfigModule .get_config_value (
1345-                     "sectionOne" , "test_case" , temp_ini_file 
1346-                 )
1347-                 +  ".zip" 
1348-             )
1349-             FL .DeleteFile (
1350-                 ConfigModule .get_config_value (
1351-                     "sectionOne" , "test_case_folder" , temp_ini_file 
1352-                 )
1353-                 +  ".zip" 
1354-             )
1330+             #  upload_zip(
1331+             #      ConfigModule.get_config_value("Authentication", "server_address"),
1332+             #      ConfigModule.get_config_value("Authentication", "server_port"),
1333+             #      ConfigModule.get_config_value("sectionOne", "temp_run_file_path", temp_ini_file),
1334+             #      run_id,
1335+             #      ConfigModule.get_config_value("sectionOne", "test_case", temp_ini_file) + ".zip",
1336+             #      ConfigModule.get_config_value("Advanced Options", "_file_upload_path"),
1337+             #  )
1338+             #  TCLogFile = (
1339+             #      os.sep
1340+             #      + ConfigModule.get_config_value("Advanced Options", "_file_upload_path")
1341+             #      + os.sep
1342+             #      + run_id.replace(":", "-")
1343+             #      + "/"
1344+             #      + ConfigModule.get_config_value(
1345+             #          "sectionOne", "test_case", temp_ini_file
1346+             #      )
1347+             #      + ".zip"
1348+             #  )
1349+             #  FL.DeleteFile(
1350+             #      ConfigModule.get_config_value(
1351+             #          "sectionOne", "test_case_folder", temp_ini_file
1352+             #      )
1353+             #      + ".zip"
1354+             #  )
13551355        else :
13561356            TCLogFile  =  "" 
13571357        # upload the log file ID 
@@ -1433,17 +1433,19 @@ def run_test_case(
14331433    testcase_info ,
14341434    executor ,
14351435    debug_info ,
1436+     all_file_specific_steps ,
14361437    send_log_file_only_for_fail = True ,
14371438    performance = False ,
14381439    browserDriver = None ,
14391440):
14401441    shared .Set_Shared_Variables ("run_id" , run_id )
14411442    test_case  =  str (TestCaseID ).replace ("#" , "no" )
1442-     ConfigModule .add_config_value ("sectionOne" , "sTestStepExecLogId" , "MainDriver" , temp_ini_file )
1443-     file_specific_steps   =   download_attachments_for_test_case (
1443+     ConfigModule .add_config_value ("sectionOne" , "sTestStepExecLogId" , sModuleInfo , temp_ini_file )
1444+     download_attachments_for_test_case (
14441445        sModuleInfo , run_id , test_case , temp_ini_file ,
1445-         testcase_info [ "testcase_attachments_links" ],  testcase_info [ "step_attachments" ]
1446+         [],[ ]
14461447    )
1448+     file_specific_steps  =  all_file_specific_steps [TestCaseID ] if  TestCaseID  in  all_file_specific_steps  else  {}
14471449    TestCaseName  =  testcase_info ["title" ]
14481450    log_line  =  "# EXECUTING TEST CASE : %s :: %s #"  %  (test_case , TestCaseName )
14491451    print ("#" * (len (log_line )))
@@ -1471,6 +1473,13 @@ def run_test_case(
14711473        performance 
14721474    )
14731475
1476+     ConfigModule .add_config_value (
1477+         "sectionOne" ,
1478+         "sTestStepExecLogId" ,
1479+         run_id  +  "|"  +  test_case  +  "|"  +  "none"  +  "|"  +  "none" ,
1480+         temp_ini_file ,
1481+     )
1482+ 
14741483    # get test case end time 
14751484    TestCaseEndTime  =  time .time ()
14761485    sTestCaseEndTime  =  datetime .fromtimestamp (TestCaseEndTime ).strftime ("%Y-%m-%d %H:%M:%S" )
@@ -1738,19 +1747,15 @@ def get_all_run_id_info(Userid, sModuleInfo):
17381747    # return response["json"] 
17391748
17401749
1741- def  upload_json_report (Userid , temp_ini_file , run_id ):
1742-     # path = os.path.join(os.path.abspath(__file__).split("Framework")[0])/Path("AutomationLog")/Path("execution_log.json") 
1743-     path  =  ConfigModule .get_config_value ("sectionOne" , "temp_run_file_path" , temp_ini_file ) /  Path (run_id .replace (":" , "-" ))
1744-     zip_path  =  path  /  Path ("execution_log.zip" )
1745-     path  =  path  /  Path ("execution_log.json" )
1750+ def  upload_json_report (Userid , temp_ini_file , run_id , all_run_id_info ):
1751+     zip_path  =  ConfigModule .get_config_value ("sectionOne" , "temp_run_file_path" , temp_ini_file ) /  Path (run_id .replace (":" , "-" ))
1752+     path  =  zip_path  /  Path ("execution_log.json" )
17461753    json_report  =  CommonUtil .get_all_logs (json = True )
17471754    with  open (path , "w" ) as  f :
1748-         json .dump (json_report , f , indent = 2 )
1749- 
1750-     FL .ZipFile (path , zip_path )
1751-     FL .DeleteFile (path )
1755+         json .dump (json_report , f )
17521756
17531757    if  ConfigModule .get_config_value ("RunDefinition" , "local_run" ) ==  "False" :
1758+         FL .ZipFolder (str (zip_path ), str (zip_path ) +  ".zip" )
17541759        for  i  in  range (720 ):    # 1 hour 
17551760            res  =  requests .get (RequestFormatter .form_uri ("is_copied_api/" ), {"runid" : run_id }, verify = False )
17561761            r  =  res .json ()
@@ -1762,7 +1767,8 @@ def upload_json_report(Userid, temp_ini_file, run_id):
17621767                  "Get the report from below path-\n "  +  path )
17631768            return 
17641769
1765-         with  open (zip_path , "rb" ) as  fzip :
1770+         with  open (str (zip_path ) +  ".zip" , "rb" ) as  fzip :
1771+             print ("Uploading report of %s KB. Please wait"  %  (os .stat (str (zip_path ) +  ".zip" ).st_size  /  1000 ))
17661772            for  i  in  range (5 ):
17671773                res  =  requests .post (
17681774                    RequestFormatter .form_uri ("create_report_log_api/" ),
@@ -1776,17 +1782,22 @@ def upload_json_report(Userid, temp_ini_file, run_id):
17761782                        print ("Could not Upload json report to server" )
17771783                        return 
17781784                    if  isinstance (res_json , dict ) and  'message'  in  res_json  and  res_json ["message" ]:
1779-                         print ("Successfully Uploaded json  report to server"  )
1785+                         print ("Successfully Uploaded the  report to server of run_id '%s'"    %   run_id )
17801786                    else :
1781-                         print ("Could not Upload json  report to server"  )
1787+                         print ("Could not Upload the  report to server of run_id '%s'"    %   run_id )
17821788                    break 
17831789                time .sleep (1 )
17841790            else :
17851791                print ("Could not Upload json report to server" )
1786- 
1792+         os .unlink (str (zip_path ) +  ".zip" )
1793+     with  open (path , "w" ) as  f :
1794+         json .dump (json_report , f , indent = 2 )
1795+     path  =  zip_path  /  Path ("test_cases_data.json" )
1796+     with  open (path , "w" ) as  f :
1797+         json .dump (all_run_id_info , f , indent = 2 )
17871798
17881799# main function 
1789- def  main (device_dict , user_info_object ,  all_run_id_info ):
1800+ def  main (device_dict , user_info_object ):
17901801
17911802    # get module info 
17921803    sModuleInfo  =  inspect .currentframe ().f_code .co_name  +  " : "  +  MODULE_NAME 
@@ -1807,13 +1818,31 @@ def main(device_dict, user_info_object, all_run_id_info):
18071818    Userid  =  (CommonUtil .MachineInfo ().getLocalUser ()).lower ()
18081819
18091820    # all_run_id_info = get_all_run_id_info(Userid, sModuleInfo) 
1810- 
1821+     get_json , all_file_specific_steps  =  True , {}
1822+     save_path  =  Path (ConfigModule .get_config_value ("sectionOne" , "temp_run_file_path" , temp_ini_file )) /  "attachments" 
1823+     cnt  =  0 
1824+     for  i  in  os .walk (save_path ):
1825+         if  get_json :
1826+             get_json  =  False 
1827+             json_path  =  Path (i [0 ]) /  i [2 ][0 ]
1828+             folder_list  =  i [1 ]
1829+             for  j  in  folder_list :
1830+                 all_file_specific_steps [j ] =  {}
1831+         else :
1832+             for  j  in  i [2 ]:
1833+                 all_file_specific_steps [folder_list [cnt ]][j ] =  str (Path (i [0 ]) /  j )
1834+             cnt  +=  1 
1835+     with  open (json_path , "r" ) as  f :
1836+         all_run_id_info  =  json .loads (f .read ())
1837+     with  open (Path .cwd ().parent  /  "Projects"  /  "Local_run.json" , "w" ) as  f :
1838+         f .write (json .dumps (all_run_id_info ))
18111839    if  len (all_run_id_info ) ==  0 :
18121840        CommonUtil .ExecLog ("" , "No Test Run Schedule found for the current user : %s"  %  Userid , 2 )
18131841        return  False 
18141842
18151843    executor  =  CommonUtil .GetExecutor ()
18161844    for  run_id_info  in  all_run_id_info :
1845+         run_id_info ["base_path" ] =  ConfigModule .get_config_value ("Advanced Options" , "_file_upload_path" )
18171846        run_id  =  run_id_info ["run_id" ]
18181847        run_cancelled  =  "" 
18191848        debug_info  =  "" 
@@ -1822,9 +1851,7 @@ def main(device_dict, user_info_object, all_run_id_info):
18221851        # Write testcase json 
18231852        path  =  ConfigModule .get_config_value ("sectionOne" , "temp_run_file_path" , temp_ini_file ) /  Path (run_id .replace (":" , "-" ))
18241853        FL .CreateFolder (path )
1825-         path  =  path  /  Path ("test_cases_data.json" )
1826-         with  open (path , "w" ) as  f :
1827-             json .dump (all_run_id_info , f , indent = 2 )
1854+ 
18281855
18291856        # Start websocket server if we're in debug mode. 
18301857        if  run_id .lower ().startswith ("debug" ):
@@ -1884,7 +1911,7 @@ def main(device_dict, user_info_object, all_run_id_info):
18841911        else :
18851912            CommonUtil .ExecLog ("" , "No Automated test cases found for the current user : %s"  %  Userid , 2 )
18861913            return  "pass" 
1887- 
1914+          num_of_tc   =   len ( all_testcases_info ) 
18881915        CommonUtil .all_logs_json  =  all_run_id_info 
18891916        cnt  =  1 
18901917        for  testcase_info  in  all_testcases_info :
@@ -1986,6 +2013,7 @@ def kill(process):
19862013                    testcase_info ,
19872014                    executor ,
19882015                    debug_info ,
2016+                     all_file_specific_steps ,
19892017                    send_log_file_only_for_fail ,
19902018                )
19912019                CommonUtil .clear_all_logs ()  # clear logs 
@@ -2008,14 +2036,15 @@ def kill(process):
20082036            "duration" : TestSetDuration 
20092037        }
20102038        CommonUtil .CreateJsonReport (setInfo = after_execution_dict )
2039+         print ("Report creation time = %s sec for %s testcases"  %  (CommonUtil .report_json_time , num_of_tc ))
20112040        CommonUtil .ExecLog ("" , "Test Set Completed" , 4 , False )
20122041
20132042        ConfigModule .add_config_value ("sectionOne" , "sTestStepExecLogId" , "MainDriver" , temp_ini_file )
20142043
20152044        if  run_cancelled  ==  CANCELLED_TAG :
20162045            CommonUtil .ExecLog (sModuleInfo , "Test Set Cancelled by the User" , 1 )  # add log 
20172046        elif  not  run_id .startswith ("debug" ):
2018-             upload_json_report (Userid , temp_ini_file , run_id )
2047+             upload_json_report (Userid , temp_ini_file , run_id ,  all_run_id_info )
20192048            # executor.submit(upload_json_report) 
20202049
20212050        # Close websocket connection. 
0 commit comments