Configs.py added, Using the constants in Configs.py On branch python-cli modified: cli/CLI.py new file: cli/Configs.py modified: cli/Logging.py
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/129fd5d5 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/129fd5d5 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/129fd5d5 Branch: refs/heads/stratos-4.1.x Commit: 129fd5d5613d7490b9d4eb474eddcbccf2057ab5 Parents: a9f82d5 Author: Milindu Sanoj Kumarage <[email protected]> Authored: Fri May 22 17:16:11 2015 +0530 Committer: Imesh Gunaratne <[email protected]> Committed: Tue Oct 13 16:32:44 2015 +0530 ---------------------------------------------------------------------- .../src/main/python/cli/CLI.py | 12 ++++++++++-- .../src/main/python/cli/Configs.py | 10 ++++++++++ .../src/main/python/cli/Logging.py | 13 +++++++------ 3 files changed, 27 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/129fd5d5/components/org.apache.stratos.python.cli/src/main/python/cli/CLI.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cli/src/main/python/cli/CLI.py b/components/org.apache.stratos.python.cli/src/main/python/cli/CLI.py index 4060e2c..eccd2ab 100755 --- a/components/org.apache.stratos.python.cli/src/main/python/cli/CLI.py +++ b/components/org.apache.stratos.python.cli/src/main/python/cli/CLI.py @@ -1,12 +1,16 @@ from cmd2 import * from Utils import * from Stratos import * +import Configs class CLI(Cmd): """Apache Stratos CLI""" - prompt = 'stratos> ' + prompt = Configs.stratos_prompt + # resolving the '-' issue + Cmd.legalChars += '-' + Cmd.shortcuts.update({'deploy-user': 'deploy_user'}) @options([ make_option('-u', '--username', type="str", help="Username of the user"), @@ -32,4 +36,8 @@ class CLI(Cmd): table.print_table() else: - print("Some required argument(s) missing") \ No newline at end of file + print("Some required argument(s) missing") + + def do_deploy_user(self, line , opts=None): + """Illustrate the base class method use.""" + print("hello User") \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/129fd5d5/components/org.apache.stratos.python.cli/src/main/python/cli/Configs.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cli/src/main/python/cli/Configs.py b/components/org.apache.stratos.python.cli/src/main/python/cli/Configs.py new file mode 100644 index 0000000..e98dcb6 --- /dev/null +++ b/components/org.apache.stratos.python.cli/src/main/python/cli/Configs.py @@ -0,0 +1,10 @@ +import os + +stratos_prompt = "stratos> " + +stratos_dir = "~/.stratos" +log_file_name = "stratos-cli.log" + +Stratos_url = os.getenv('STRATOS_URL', None) +Stratos_username = os.getenv('STRATOS_USERNAME', None) +Stratos_password = os.getenv('STRATOS_PASSWORD', None) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/129fd5d5/components/org.apache.stratos.python.cli/src/main/python/cli/Logging.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cli/src/main/python/cli/Logging.py b/components/org.apache.stratos.python.cli/src/main/python/cli/Logging.py index 20583ad..f149913 100644 --- a/components/org.apache.stratos.python.cli/src/main/python/cli/Logging.py +++ b/components/org.apache.stratos.python.cli/src/main/python/cli/Logging.py @@ -1,16 +1,17 @@ import logging import os +import Configs -stratos_dir = os.path.expanduser('~/.stratos') -log_file_path = stratos_dir+"stratos-cli.log" +stratos_dir_path = os.path.expanduser(Configs.stratos_dir) +log_file_path = stratos_dir_path+Configs.log_file_name -if not os.path.exists(stratos_dir): +if not os.path.exists(stratos_dir_path): try: - os.makedirs(stratos_dir) - logging.info("Created directory: "+stratos_dir) + os.makedirs(stratos_dir_path) + logging.info("Created directory: "+stratos_dir_path) except OSError: - logging.warning("Failed to create directory: "+stratos_dir) + logging.warning("Failed to create directory: "+stratos_dir_path) logging.basicConfig(filename=log_file_path, level=logging.DEBUG)
