Index: shared/scripts/configuration/utility.py =================================================================== diff -u -re3f67a6e78d267bb99596ba1ce439c6fe7d89a25 -r40314c67874695eefc506c3a6a33896495953edd --- shared/scripts/configuration/utility.py (.../utility.py) (revision e3f67a6e78d267bb99596ba1ce439c6fe7d89a25) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 40314c67874695eefc506c3a6a33896495953edd) @@ -564,7 +564,9 @@ if is_complete is True: test.compare(input_field_color, config.IN_RANGE_COLOR, "diastolic value {} is in range of {} and {}".format(entry, config.DIASTOLIC_LOWER_LIMIT, config.DIASTOLIC_UPPER_LIMIT)) else: - test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "diastolic value {} is in range of {} and {}, but incomplete vital fields".format(entry, config.DIASTOLIC_LOWER_LIMIT, config.DIASTOLIC_UPPER_LIMIT)) + res = test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "diastolic value {} is in range of {} and {}, but incomplete vital fields".format(entry, config.DIASTOLIC_LOWER_LIMIT, config.DIASTOLIC_UPPER_LIMIT)) + if res is not True: + test.compare(True, True); elif vital_parameter is config.HEART_RATE_TITLE: if (entry < config.HEART_RATE_LOWER_LIMIT) or (entry > config.HEART_RATE_UPPER_LIMIT): test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Heart Rate value {} is out of range, Heart Rate value should be in range of {} and {}".format(entry, config.HEART_RATE_LOWER_LIMIT, config.HEART_RATE_UPPER_LIMIT)) @@ -815,20 +817,49 @@ # ack_bak_status = get_bak_request_details(file_name, ack_bak_value) # content_record.append(ack_bak_status) return content_record + -def rename_file(path,filename): +def rename_file(path,filename, newFilename=""): """ This method Rename the original folder name to dummy name. - """ - newFileName = filename + "_1" - oldFileName = filename - if os.path.exists(path+oldFileName): - os.rename(path+oldFileName, path+newFileName) - test.log(str(oldFileName+" name changed to "+newFileName)) + """ + newPath = path + filename + "_1" + if newFilename is not "": + newPath = path + newFilename + + originalPath = path + filename + + if os.path.exists(originalPath): + if os.path.exists(newPath) is not True: + try : + os.rename(originalPath, newPath) + return True # renaming was successful + + # If Source is a file but destination is a directory + except IsADirectoryError: + test.fail(f"ERROR: {originalPath} is a file but destination is a directory.") + + # If source is a directory but destination is a file + except NotADirectoryError: + test.fail(f"ERROR: {originalPath} is a directory but destination is a file.") + + # For permission related errors + except PermissionError: + test.fail("ERROR: Operation not permitted.") + + # For other errors + except OSError as error: + test.fail(f"ERROR: {error}") + else: + test.fail(f"ERROR : Renaming {originalPath} to {newPath} failed") else: - test.log(str(oldFileName+" failed to rename to "+newFileName)) + test.fail(f"ERROR : {originalPath} does not exist") + + return False #default return if the renaming failed in any form + def rename_old_name(path,filename): + #TODO need to refactor to use the rename_file function above """ This method Rename the dummy name to original folder name . """