Index: shared/scripts/configuration/utility.py =================================================================== diff -u -ra9219e9ca0692311f23f60aa7c9b574fb449d3e6 -r7443e628b9cf908dc16917bba5b4d23b7d7f46bf --- shared/scripts/configuration/utility.py (.../utility.py) (revision a9219e9ca0692311f23f60aa7c9b574fb449d3e6) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 7443e628b9cf908dc16917bba5b4d23b7d7f46bf) @@ -23,6 +23,7 @@ import time import test +from builtins import format from builtins import int as pyInt from builtins import str as pyStr from builtins import format @@ -34,13 +35,53 @@ from dialin.protocols import DenaliMessage, DenaliCanMessenger, DenaliChannels from datetime import datetime + LOG_LOCATION = "/home/denali/Desktop/sd-card/log/*.log" hd_simulator = HDSimulator() def color_verification(exp_val = "Red", act_val = "#c53b33"): test.compare(config.COLOR_CODES[color_name],(act_val.color[name])) - + + +def start_application(app_name): + """ + Function to start application and verify application status [running] + If application does not start or running status is false, test stops + Argument: + @param app_name : (str) - Name of the application + @param app_executable : (str) - Actual application + @return: handle for the application if the application is in running state, + or error (exist the application) + """ + counter = 0 + while True: + try: + counter += 1 + test.log("Starting {}".format(app_name)) + squish.startApplication(app_name) + if counter == 1: + test.log("Application launched at the "+str(counter)+" st try.") + elif counter == 2: + test.log("Application launched at the "+str(counter)+" nd try.") + elif counter == 3: + test.log("Application launched at the "+str(counter)+" rd try.") + else: + test.log("Application launched at the "+str(counter)+" th try.") + break + except RuntimeError: + if counter == 1: + test.log("Application failed to launch after "+str(counter)+" try - Please refer logs") + elif counter == 20: + test.log("Exiting after "+str(counter)+ " tries..") + sys.exit(1) + else: + test.log("Application failed to launch after "+str(counter)+ " tries - Please refer logs") + except: + logErrorDetails("Failed to start the application") + sys.exit(1) + + def check_if_object_is_within_the_container(obj=None, container=None): """ check if an object is inside a container @@ -1330,8 +1371,6 @@ content_record.append(ack_bak_status) return content_record - raise LookupError("zone object is not in view to the user after " + \ - "trying 100 times") def vitals_interval_obj(interval): names.o_time_interval_obj["text"] = interval @@ -1562,27 +1601,7 @@ squish.mouseClick(squish.waitForObject(keypad_input(value))) test.endSection() -def pad_message_with_zeros(message): - """ - Returns a packet padded with zeros that guarantees that the packet is a multiple of 8 bytes. - @param message: packet that may or may not be multiple of 8 bytes - @return:: packet that is 8-byte multiple - - """ - PACKET_LENGTH = 4 - - message_length = len(message) - - if message_length % PACKET_LENGTH != 0: - add_these_many_zeros = math.ceil(message_length / PACKET_LENGTH) * \ - PACKET_LENGTH - message_length - - message += [0] * add_these_many_zeros - - return message - - def ui_all_publication_handler(message: dict) -> None: """ This function is the default handler of the ui received messages which only prints out the received message @@ -1631,7 +1650,20 @@ return message -def get_current_date_and_time(date_format='%Y/%b/%d - %H:%M'): - date = datetime.now() - return str(date.strftime(date_format)) +def get_extracted_error_file(): + """ + This function is the handler for getting error file from service folder. + + Application log file is automatically created on '/home/denali/Desktop/sd-card/service/ {current_date}_denaliSquish.err ' + + @return latest_file - (string) returns latest file that append on log folder from service + """ + try: + current_date = get_current_date_and_time(date_format = "%Y_%m_%d") + latest_file = '/home/denali/Desktop/sd-card/service/'+current_date+'_denaliSquish.err' + return latest_file + except: + return False + +