Better prompt_for_credentials() Signed-off-by: Imesh Gunaratne <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/8796febd Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/8796febd Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/8796febd Branch: refs/heads/stratos-4.1.x Commit: 8796febdd636a9712a3ea068c661846785fb4ab5 Parents: 937e5a7 Author: Milindu Sanoj Kumarage <[email protected]> Authored: Sun Aug 16 22:50:41 2015 +0530 Committer: Imesh Gunaratne <[email protected]> Committed: Tue Oct 13 16:32:49 2015 +0530 ---------------------------------------------------------------------- .../src/main/python/cli/Main.py | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/8796febd/components/org.apache.stratos.python.cli/src/main/python/cli/Main.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cli/src/main/python/cli/Main.py b/components/org.apache.stratos.python.cli/src/main/python/cli/Main.py index 78b3572..e826b07 100755 --- a/components/org.apache.stratos.python.cli/src/main/python/cli/Main.py +++ b/components/org.apache.stratos.python.cli/src/main/python/cli/Main.py @@ -22,6 +22,8 @@ from CLI import CLI import Configs # Fix Python 2.x. +from cli.Stratos import Stratos + try: input = raw_input except NameError: @@ -30,13 +32,18 @@ except NameError: def prompt_for_credentials(): """Prompt for user credentials""" - while True: - _username = input("Username: ") - _password = getpass.getpass("Password: ") - if _username is not "" and _password is not "": - Configs.stratos_username = _username - Configs.stratos_password = _password - break + while Configs.stratos_username is "" or Configs.stratos_password is "": + if Configs.stratos_username is "": + Configs.stratos_username = input("Username: ") + + if Configs.stratos_password is "": + Configs.stratos_password = getpass.getpass("Password: ") + if Stratos.authenticate(): + print("Successfully authenticated") + else: + print("Could not authenticate") + exit() + def main():
