Prompting for user credentials when starting the interactive mode 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/26b54706 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/26b54706 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/26b54706 Branch: refs/heads/stratos-4.1.x Commit: 26b547069268f0605d8dd49c9eff71883b37a028 Parents: 0130ee9 Author: Milindu Sanoj Kumarage <[email protected]> Authored: Thu Jun 18 22:09:09 2015 +0530 Committer: Imesh Gunaratne <[email protected]> Committed: Tue Oct 13 16:32:45 2015 +0530 ---------------------------------------------------------------------- .../src/main/python/cli/Main.py | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/26b54706/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 dc4f291..f5ea323 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 @@ -1,6 +1,24 @@ import sys +import getpass from CLI import CLI -import Logging +import Configs + +# Fix Python 2.x. +try: + input = raw_input +except NameError: + pass + + +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 def main(): @@ -9,6 +27,7 @@ def main(): if len(sys.argv) > 1: cli.onecmd(' '.join(sys.argv[1:])) else: + prompt_for_credentials() cli.cmdloop() if __name__ == '__main__':
