Skip to content

Commit

Permalink
allow baseline plugin to prompt for password
Browse files Browse the repository at this point in the history
  • Loading branch information
jgstew committed May 9, 2024
1 parent ffa8901 commit 28cb450
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions examples/baseline_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import argparse
import datetime
import getpass
import logging
import logging.handlers
import os
Expand Down Expand Up @@ -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

Expand All @@ -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,
Expand All @@ -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:
Expand Down

0 comments on commit 28cb450

Please sign in to comment.