Repository: cloudstack-cloudmonkey Updated Branches: refs/heads/master 901154990 -> c6318fc13
cloudmonkey: display current profile in parenthesis in the prompt Signed-off-by: Rohit Yadav <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/commit/c6318fc1 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/tree/c6318fc1 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/diff/c6318fc1 Branch: refs/heads/master Commit: c6318fc13b2640af35b9b19d7355269a96e13f56 Parents: 9011549 Author: Rohit Yadav <[email protected]> Authored: Fri Oct 3 16:38:40 2014 +0200 Committer: Rohit Yadav <[email protected]> Committed: Fri Oct 3 16:38:40 2014 +0200 ---------------------------------------------------------------------- cloudmonkey/cloudmonkey.py | 10 +++++++++- cloudmonkey/requester.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/c6318fc1/cloudmonkey/cloudmonkey.py ---------------------------------------------------------------------- diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py index bd0f6c7..e137aab 100644 --- a/cloudmonkey/cloudmonkey.py +++ b/cloudmonkey/cloudmonkey.py @@ -109,6 +109,13 @@ class CloudMonkeyShell(cmd.Cmd, object): self.host = parsed_url.netloc self.port = "8080" if not parsed_url.port else parsed_url.port self.path = parsed_url.path + self.set_prompt() + + def get_prompt(self): + return self.prompt.split(") ")[-1] + + def set_prompt(self): + self.prompt = "(%s) %s" % (self.profile, self.get_prompt()) def get_attr(self, field): return getattr(self, field) @@ -175,7 +182,7 @@ class CloudMonkeyShell(cmd.Cmd, object): monkeyprint(output) else: if output.startswith("Error"): - sys.stderr.write(output) + sys.stderr.write(output + "\n") else: print output @@ -443,6 +450,7 @@ class CloudMonkeyShell(cmd.Cmd, object): print "Blank value of %s is not allowed" % key return + self.prompt = self.get_prompt() setattr(self, key, value) if key in ['host', 'port', 'path', 'protocol']: key = 'url' http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/c6318fc1/cloudmonkey/requester.py ---------------------------------------------------------------------- diff --git a/cloudmonkey/requester.py b/cloudmonkey/requester.py index 8e5e211..08876c9 100644 --- a/cloudmonkey/requester.py +++ b/cloudmonkey/requester.py @@ -114,7 +114,7 @@ def make_request_with_password(command, args, logger, url, credentials): if not (session and sessionkey): session, sessionkey = login(url, username, password) if not (session and sessionkey): - return None, 'Error authenticating' + return None, 'Authentication failed' credentials['session'] = session credentials['sessionkey'] = sessionkey
