Repository: cloudstack-cloudmonkey Updated Branches: refs/heads/master 2fcc12d68 -> e0e53ba51
cloudmonkey: add case to handle exception when quiting cloudmonkey Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com> Project: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/commit/e0e53ba5 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/tree/e0e53ba5 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/diff/e0e53ba5 Branch: refs/heads/master Commit: e0e53ba512f7e8e4a3242c8d1fd45cfc7fe2527f Parents: 2fcc12d Author: Rohit Yadav <rohit.ya...@shapeblue.com> Authored: Tue Aug 12 12:33:17 2014 +0200 Committer: Rohit Yadav <rohit.ya...@shapeblue.com> Committed: Tue Aug 12 12:33:17 2014 +0200 ---------------------------------------------------------------------- cloudmonkey/cloudmonkey.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/e0e53ba5/cloudmonkey/cloudmonkey.py ---------------------------------------------------------------------- diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py index dedbb3e..206e8f9 100644 --- a/cloudmonkey/cloudmonkey.py +++ b/cloudmonkey/cloudmonkey.py @@ -123,6 +123,8 @@ class CloudMonkeyShell(cmd.Cmd, object): for verb in self.verbs: def add_grammar(verb): def grammar_closure(self, args): + if args is None: + return if self.pipe_runner("%s %s" % (verb, args)): return if ' --help' in args or ' -h' in args: @@ -432,10 +434,13 @@ class CloudMonkeyShell(cmd.Cmd, object): """ Logout of session started with login with username and password """ - url = "%s://%s:%s%s" % (self.protocol, self.host, self.port, self.path) - logout(url, self.credentials.get('session')) - self.credentials['session'] = None - self.credentials['sessionkey'] = None + try: + url = "%s://%s:%s%s" % (self.protocol, self.host, self.port, self.path) + logout(url, self.credentials.get('session')) + self.credentials['session'] = None + self.credentials['sessionkey'] = None + except TypeError: + pass def pipe_runner(self, args): if args.find(' |') > -1: