Index: shared/scripts/configuration/utility.py =================================================================== diff -u -rcd63acd00fab420ba8683b71843b75b0f8bf503a -re620a9fd664c96a736c0d7ca2ffe03d98a913189 --- shared/scripts/configuration/utility.py (.../utility.py) (revision cd63acd00fab420ba8683b71843b75b0f8bf503a) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision e620a9fd664c96a736c0d7ca2ffe03d98a913189) @@ -30,8 +30,6 @@ date = datetime.now() return str(date.strftime(date_format)) - - def append_cloudsync_credentials_file(): try: @@ -45,61 +43,54 @@ except OSError as error: test.log("Directory can not be created") -def get_extracted_input_buf_file(): +def get_cloud_sync_input_file(): """ - 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 + 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 """ try: current_date = get_current_date_and_time(date_format = "%Y_%m_%d") - latest_file = '/home/denali/Desktop/sd-card/cloudsync/'+current_date+'_inp.buf' + latest_file = CLOUD_SYNC_LOG_LOCATION+current_date+'_inp.buf' return latest_file except: - return False - - -def get_cloud_sync_output_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}_out.log' - @return latest_file - (string) returns latest file that append on log folder from sd-data - """ - try: - current_date = get_current_date_and_time(date_format = "%Y_%m_%d") - latest_file = CLOUD_SYNC_LOG_LOCATION+current_date+'_out.buf' - return latest_file - except: - return False + return False - -def retrive_log_data(readline_count): +def retrive_log_data(readline_count = 16): """ - 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 + 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}_out.log' + @return latest_file - (list) returns latest file that append on log folder from sd-data """ cloudsync_data = [] count = 0 - file_name = get_extracted_input_buf_file() + file_name = get_cloud_sync_input_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 +def get_epoch_value_consistancy(current_epoch_value, expected_epoch_value): + """ + This function is verify consistancy of epoch value. + @input current_epoch_value (float) - current epoch time + @input expected_epoch_value (str) - epoch time from the cloud-sync log. + @return (bool) - True/False + """ + expected_epoch_value = int(expected_epoch_value) + maximum_epoch_value = int(current_epoch_value + 25) + minimum_epoch_value = int(current_epoch_value - 25) + + if expected_epoch_value > minimum_epoch_value and expected_epoch_value < maximum_epoch_value : + return True + return False \ No newline at end of file