summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Luha <rasmus.luha@ut.ee>2025-05-14 22:31:44 +0300
committerRasmus Luha <rasmus.luha@ut.ee>2025-05-14 22:31:44 +0300
commit7bfcf9a86553f7158673758cd500eece8e9cf132 (patch)
tree91fa5eb7d894699121c73c6b0691f894d3e1b51e
parent6cb9f3eb1614f097992e27f2309bf6ca1cd37238 (diff)
Add wrong API error detection to noninteractive mode
-rw-r--r--common/core.py8
-rw-r--r--modules/nifi/core.py12
-rw-r--r--modules/telegraf/core.py9
3 files changed, 25 insertions, 4 deletions
diff --git a/common/core.py b/common/core.py
index c3e3495..e52cedd 100644
--- a/common/core.py
+++ b/common/core.py
@@ -28,9 +28,9 @@ def ask_digit_input(max_index):
def is_app_url_correct(api_url, needs_auth, username,passwd):
- """"
+ """
Checks if api url is correct, if so then returns the json
- """"
+ """
print("Teostan API kutset...\n")
try:
if needs_auth:
@@ -55,9 +55,9 @@ def is_app_url_correct(api_url, needs_auth, username,passwd):
def inspect_json_top_level(json_data):
- """"
+ """
Asks the user json item to extract and returns it as dict item-value pair, where item is name and value json path
- """"
+ """
path = ""
while True:
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