Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r043c2695cbc8e90cfe6ebde197300de94a80fbdb -r15cca0a5aa54862e11fa0d416a1d8ae1ade38e8a --- shared/scripts/configuration/utility.py (.../utility.py) (revision 043c2695cbc8e90cfe6ebde197300de94a80fbdb) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 15cca0a5aa54862e11fa0d416a1d8ae1ade38e8a) @@ -13,23 +13,24 @@ ############################################################################ from datetime import datetime +import test +import csv - def get_current_date_and_time(date_format='%Y/%b/%d - %H:%M:%S'): date = datetime.now() return str(date.strftime(date_format)) def get_extracted_input_buf_file(): """ - This function is the handler for getting file from log folder. + This function is the handler for getting file from cloudsync folder. - This handler will go inside log folder and looks for newly added log based on current time. - if it satisfied that condition, it will return the exact path of newly created log. + 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 log file is automatically created on '/home/denali/Desktop/sd-card/log/ {current_date}_denaliSquish.log' + 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 on log folder from sd-data + @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") @@ -38,3 +39,31 @@ except: return False +def retrive_log_data(readline_count): + """ + 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_extracted_input_buf_file() + try: + with open(file_name,mode = 'r') as filereader: + contents = csv.reader(filereader) + try: + for reader in reversed(list(contents)): + if readline_count == count: + return cloudsync_data + cloudsync_data.append(reader) + count = count + 1 + except: + 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.") + + + + + +