Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r26be96f1f86d5823902beed32660f12cdb87d881 -rcd63acd00fab420ba8683b71843b75b0f8bf503a --- shared/scripts/configuration/utility.py (.../utility.py) (revision 26be96f1f86d5823902beed32660f12cdb87d881) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision cd63acd00fab420ba8683b71843b75b0f8bf503a) @@ -11,7 +11,7 @@ # @date (last) 08-July-2022 # ############################################################################ - +from datetime import datetime import os import csv import test @@ -45,19 +45,23 @@ except OSError as error: test.log("Directory can not be created") - -def get_cloud_sync_input_file(): +def get_extracted_input_buf_file(): """ - This function is the handler for getting file from log folder. - Application log file is automatically created on '/home/denali/Desktop/sd-card/cloudsync/ {current_date}_inp.log' - @return latest_file - (string) returns latest file that append on log folder from sd-data + This function is the handler for getting file from cloudsync folder. + + This handler will go inside cloudsync folder and looks for newly added input buf file based on current time. + if it satisfied that condition, it will return the exact path of newly created input buf file. + + Application input buf file is automatically created in '/home/denali/Desktop/sd-card/cloudsync/ {current_date}_inp.buf' + + @return latest_file - (string) returns latest file that append in cloudsync folder """ try: current_date = get_current_date_and_time(date_format = "%Y_%m_%d") - latest_file = CLOUD_SYNC_LOG_LOCATION+current_date+'_inp.buf' + latest_file = '/home/denali/Desktop/sd-card/cloudsync/'+current_date+'_inp.buf' return latest_file except: - return False + return False def get_cloud_sync_output_file(): @@ -74,27 +78,28 @@ return False -def retrive_log_data(readline_count = 1): +def retrive_log_data(readline_count): """ - This function is the handler for getting file from log folder. - Application log data is automatically appended on '/home/denali/Desktop/sd-card/cloudsync/ {current_date}_input.log' - @return latest_file - (list) returns latest file that append on log folder from sd-data + This function is the handler for getting file from cloudsync folder. + Application log data is automatically appended on '/home/denali/Desktop/sd-card/cloudsync/ {current_date}_inp.buf' + @cloudsync_data - (list) returns latest file that append in cloudsync folder """ cloudsync_data = [] count = 0 - file_name = get_cloud_sync_input_file() + file_name = get_extracted_input_buf_file() try: with open(file_name,mode = 'r') as filereader: contents = csv.reader(filereader) - try: - for reader in reversed(list(contents)): + try: + for reader in reversed(list(contents)): if readline_count == count: - return cloudsync_data - cloudsync_data.append(reader) + return cloudsync_data + cloudsync_data.append(reader) count = count + 1 except: - test.fail("application log data is corrupted") + test.fail("application log data is corrupted") except: test.fail("Log file is not created or log file is not created based on standard log naming format.") + \ No newline at end of file Index: tst_cloud_sync_hd_opmodes/test.py =================================================================== diff -u -r75a666718891bf2346f5bbdedfa9adb43fe44377 -rcd63acd00fab420ba8683b71843b75b0f8bf503a --- tst_cloud_sync_hd_opmodes/test.py (.../test.py) (revision 75a666718891bf2346f5bbdedfa9adb43fe44377) +++ tst_cloud_sync_hd_opmodes/test.py (.../test.py) (revision cd63acd00fab420ba8683b71843b75b0f8bf503a) @@ -26,8 +26,6 @@ hd_simulator = HDSimulator() - - MESSAGE_FAULT_MODE = '1639391827,1,0,1006,2,0,0' MESSAGE_SERVICE_MODE = '1639391827,1,0,1006,2,1,0' MESSAGE_INIT_MODE = '1639391827,1,0,1006,2,2,0' @@ -119,12 +117,31 @@ utils.tstStart(__file__) startApplication(config.AUT_NAME) - utils.waitForGUI(1.5) + navigate_to_hd_opmodes() - utility.get_cloud_sync_input_file() - test.log("input.buf") - utility.retrive_log_data() - test.log("file created") - get_data_from_cloud_sync_input_file(message = MESSAGE_ILLEGAL_TRANSITION_MODE) + #utility.get_cloud_sync_input_file() +# test.log("input.buf") + inp_buf_data = utility.retrive_log_data(16) + test.log(str(inp_buf_data)) + message_id_1 = inp_buf_data[0][3] + num_of_parameters_1 = inp_buf_data[0][4] + opmode_1 = inp_buf_data[0][5] + submode_1 = inp_buf_data[0][6] + + message_id_2 = inp_buf_data[1][3] + num_of_parameters_2 = inp_buf_data[1][4] + constant_2 = inp_buf_data[1][5] + + message_id_3 = inp_buf_data[2][3] + num_of_parameters_3 = inp_buf_data[2][4] + opmode_3 = inp_buf_data[2][5] + submode_3= inp_buf_data[2][6] + test.log(str(message_id_1)) +# num_of_parameters_1,opmode_1)) +# test.log(str(message_id_2,num_of_parameters_2,constant_2)) +# test.log(str(message_id_3,num_of_parameters_3,opmode_3)) +# test.log(str(submode_1,submode_3)) +# test.log("file created") +# get_data_from_cloud_sync_input_file(message = MESSAGE_ILLEGAL_TRANSITION_MODE) utils.tstDone() \ No newline at end of file