def read_file_content()

in tools/jenkins-slave-creation-unix/scripts/deploy/slave-autoconnect.py [0:0]


def read_file_content(file_path, timeout_seconds):
    """
    Read file content
    :param path: Filepath
    :param timeout_seconds: Time to wait until file exists
    :return: File content
    """
    end_time = time.time() + timeout_seconds
    while end_time > time.time() and not os.path.exists(file_path):
        time.sleep(1)

    if end_time <= time.time():
        raise FileNotFoundError('Timeout waiting for file {} to exist'.format(file_path))

    with open(file_path, "r") as file_handle:
        content = file_handle.readline().strip()
        if not content:
            raise ValueError('{} is empty'.format(file_path))

        return content