diff options
author | Rasmus Luha <rasmus.luha@ut.ee> | 2025-04-29 00:25:22 +0300 |
---|---|---|
committer | Rasmus Luha <rasmus.luha@ut.ee> | 2025-04-29 00:25:22 +0300 |
commit | b2e8ec86abe8089ed5fbd1655677889b6691397f (patch) | |
tree | 0982990ad217e4537e1005dbd20c63d758facc17 /main.py | |
parent | 6b3c096f6efea8855772c7faffa90f71861290bd (diff) |
add cml variables, and platform option to config
Diffstat (limited to 'main.py')
-rwxr-xr-x[-rw-r--r--] | main.py | 48 |
1 files changed, 40 insertions, 8 deletions
@@ -1,5 +1,7 @@ from modules.nifi import core as nifi from modules.telegraf import core as telegraf +import config +import sys AVAILABLE_PLATFORMS = { "1": ("Nifi", nifi), @@ -7,20 +9,50 @@ AVAILABLE_PLATFORMS = { def list_platforms(): - print("Available platforms:") + print("Platovormide valik:") for key, (name, _) in AVAILABLE_PLATFORMS.items(): print(f"{key}. {name}") def main(): - list_platforms() - plat_choice = input("Palun vali platform (number): ").strip() - - platform = AVAILABLE_PLATFORMS.get(plat_choice) - if not platform: - print("Ebaõnnestunud valik, sulgen rakenduse...") - return + ## Kontrolli kas platform andi käsureamuutujana + if len(sys.argv) >= 2: + platform = sys.argv[1].lower() + if platform not in ("telegraf", "nifi"): + print("Kasutus: main.py [nifi|telegraf]") + sys.exit(1) + if platform == "nifi": + platform = AVAILABLE_PLATFORMS.get("1") + elif platform == "telegraf": + platform = AVAILABLE_PLATFORMS.get("2") + + else: + ## Vali platvorm + try: + if config.PLATFORM.lower() == "nifi": + platform = AVAILABLE_PLATFORMS.get("1") + elif config.PLATFORM.lower() == "telegraf": + platform = AVAILABLE_PLATFORMS.get("2") + else: + raise Exception("Ebaõnnestunud platvormivalik konfiguratsioonifailis...") + except Exception as e: + ## ära prindi errorit kui platvormi pole defineeritud + if isinstance(e, AttributeError): + pass + else: + print(f"Error occurred: {e}") + + list_platforms() + plat_choice = input("Palun vali platform (number): ").strip() + + platform = AVAILABLE_PLATFORMS.get(plat_choice) + if not platform: + print("Ebaõnnestunud valik, sulgen rakenduse...") + return + + + ## Genereeri andmekonveier name, module = platform module.introduction() module.build_pipeline() |