From 28cb45021443a5a72b87bbc778c52907172fb398 Mon Sep 17 00:00:00 2001 From: jgstew Date: Thu, 9 May 2024 15:59:26 -0400 Subject: [PATCH] allow baseline plugin to prompt for password --- examples/baseline_plugin.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/baseline_plugin.py b/examples/baseline_plugin.py index 9034083..03d6058 100644 --- a/examples/baseline_plugin.py +++ b/examples/baseline_plugin.py @@ -14,6 +14,7 @@ import argparse import datetime +import getpass import logging import logging.handlers import os @@ -250,6 +251,13 @@ def main(): logging.debug("BESAPI Module version: %s", besapi.besapi.__version__) logging.debug("this plugin's version: %s", __version__) + password = args.password + + if not password: + logging.warning("Password was not provided, provide REST API password.") + print("Password was not provided, provide REST API password.") + password = getpass.getpass() + # process args, setup connection: rest_url = args.rest_url @@ -258,7 +266,7 @@ def main(): rest_url = rest_url.replace("/api", "") try: - bes_conn = besapi.besapi.BESConnection(args.user, args.password, rest_url) + bes_conn = besapi.besapi.BESConnection(args.user, password, rest_url) # bes_conn.login() except ( AttributeError, @@ -267,9 +275,7 @@ def main(): ): try: # print(args.besserver) - bes_conn = besapi.besapi.BESConnection( - args.user, args.password, args.besserver - ) + bes_conn = besapi.besapi.BESConnection(args.user, password, args.besserver) # handle case where args.besserver is None # AttributeError: 'NoneType' object has no attribute 'startswith' except AttributeError: