From 7bfcf9a86553f7158673758cd500eece8e9cf132 Mon Sep 17 00:00:00 2001 From: Rasmus Luha Date: Wed, 14 May 2025 22:31:44 +0300 Subject: Add wrong API error detection to noninteractive mode --- modules/nifi/core.py | 12 ++++++++++++ modules/telegraf/core.py | 9 +++++++++ 2 files changed, 21 insertions(+) (limited to 'modules') diff --git a/modules/nifi/core.py b/modules/nifi/core.py index 0d6ca17..2e8339b 100644 --- a/modules/nifi/core.py +++ b/modules/nifi/core.py @@ -7,6 +7,7 @@ from rich.console import Console import shutil import re +import sys def introduction(): @@ -122,6 +123,17 @@ def build_pipeline(): api_username = config.API_USERNAME api_password = config.API_PASSWORD + + ## Check that API URL is correct + needs_auth = False + if (api_username.lower() and api_username.lower() != "placeholder") and (api_password.lower() and api_password.lower() != "placeholder"): + needs_auth = True + + _, api_url_correct = common.is_app_url_correct(api_url, needs_auth, api_username, api_password) + if not api_url_correct: + print("\nEtteantud API URL-i kutsel tekkis viga, sulgen rakenduse...") + sys.exit(1) + modify_all_processors(data_values, schedulingPeriod, new_pipeline_name, api_url, api_username, api_password) print(f"✅✅✅ Valmis. Uus genereeritud andmekoveier nimega '{new_pipeline_name}' asub kaustas 'pipelines'.") diff --git a/modules/telegraf/core.py b/modules/telegraf/core.py index 69021a2..ee5ebdd 100644 --- a/modules/telegraf/core.py +++ b/modules/telegraf/core.py @@ -111,6 +111,15 @@ def build_pipeline(): api_password = config.API_PASSWORD measurement_name = config.MEASUREMENT_NAME + ## Check that API URL is correct + needs_auth = False + if (api_username.lower() and api_username.lower() != "placeholder") and (api_password.lower() and api_password.lower() != "placeholder"): + needs_auth = True + + _, api_url_correct = common.is_app_url_correct(api_url, needs_auth, api_username, api_password) + if not api_url_correct: + print("\nEtteantud API URL-i kutsel tekkis viga, sulgen rakenduse...") + sys.exit(1) ### Select template -- cgit v1.2.3