Repository: stratos
Updated Branches:
  refs/heads/stratos-4.1.x 34c9d560f -> 3a6d92d9e


Python CLI - Added connection log and debug option


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/37814177
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/37814177
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/37814177

Branch: refs/heads/stratos-4.1.x
Commit: 37814177ef84479c66dfdc42c84efa7405d8b93b
Parents: 34c9d56
Author: Chamila de Alwis <[email protected]>
Authored: Wed Oct 14 00:47:00 2015 +0530
Committer: Chamila de Alwis <[email protected]>
Committed: Wed Oct 14 00:47:00 2015 +0530

----------------------------------------------------------------------
 .../src/main/python/cli/Configs.py                            | 1 +
 .../org.apache.stratos.python.cli/src/main/python/cli/Main.py | 3 ++-
 .../src/main/python/cli/Stratos.py                            | 7 +++++--
 3 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/37814177/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
index bc813a4..c4076ba 100644
--- 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
@@ -29,3 +29,4 @@ stratos_url = os.getenv('STRATOS_URL', 
"https://localhost:9443/";)
 stratos_api_url = stratos_url + "api/"
 stratos_username = os.getenv('STRATOS_USERNAME', "")
 stratos_password = os.getenv('STRATOS_PASSWORD', "")
+debug_cli = os.getenv('STRATOS_CLI_DEBUG', "false")

http://git-wip-us.apache.org/repos/asf/stratos/blob/37814177/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 27fc283..c4ad036 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
@@ -40,7 +40,8 @@ def prompt_for_credentials():
         if Configs.stratos_password is "":
             Configs.stratos_password = getpass.getpass("Password: ")
     if Stratos.authenticate():
-        print("Successfully authenticated")
+        print("Successfully authenticated.")
+        print("Connected to Stratos [%s]" % Configs.stratos_url)
     else:
         print("Could not authenticate")
         exit()

http://git-wip-us.apache.org/repos/asf/stratos/blob/37814177/components/org.apache.stratos.python.cli/src/main/python/cli/Stratos.py
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.python.cli/src/main/python/cli/Stratos.py 
b/components/org.apache.stratos.python.cli/src/main/python/cli/Stratos.py
index 2b3dd29..fa30679 100755
--- a/components/org.apache.stratos.python.cli/src/main/python/cli/Stratos.py
+++ b/components/org.apache.stratos.python.cli/src/main/python/cli/Stratos.py
@@ -467,8 +467,11 @@ class Stratos:
 
     @staticmethod
     def response(r):
-        # print(r)
-        # print(r.text)
+        if Configs.debug_cli:
+            # print responses if debug is turned on
+            print(r)
+            print(r.text)
+
         if r.status_code == 200:
             return r.json()
         elif r.status_code == 201:

Reply via email to