Updated Branches: refs/heads/master c8926de01 -> 1551b982c
cli: Handle command breaks, ctrl+c, don't break the shell - Fix handles shell loop - Handles any control breaks without breaking the shell - Handles ctrl+c to start afresh on the shell Signed-off-by: Rohit Yadav <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/1551b982 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/1551b982 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/1551b982 Branch: refs/heads/master Commit: 1551b982c4f733bd85a72f48c9f7eb9782462ddd Parents: c8926de Author: Rohit Yadav <[email protected]> Authored: Wed Dec 12 15:21:03 2012 -0800 Committer: Rohit Yadav <[email protected]> Committed: Wed Dec 12 15:21:03 2012 -0800 ---------------------------------------------------------------------- tools/cli/cloudmonkey/cloudmonkey.py | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1551b982/tools/cli/cloudmonkey/cloudmonkey.py ---------------------------------------------------------------------- diff --git a/tools/cli/cloudmonkey/cloudmonkey.py b/tools/cli/cloudmonkey/cloudmonkey.py index 8ceba4a..250ea68 100644 --- a/tools/cli/cloudmonkey/cloudmonkey.py +++ b/tools/cli/cloudmonkey/cloudmonkey.py @@ -65,7 +65,7 @@ logger = logging.getLogger(__name__) completions = cloudstackAPI.__all__ -class CloudStackShell(cmd.Cmd): +class CloudStackShell(cmd.Cmd, object): intro = ("â Apache CloudStack ðµ cloudmonkey " + __version__ + ". Type help or ? to list commands.\n") ruler = "=" @@ -133,6 +133,15 @@ class CloudStackShell(cmd.Cmd): def emptyline(self): pass + def cmdloop(self, intro=None): + print self.intro + while True: + try: + super(CloudStackShell, self).cmdloop(intro = "") + self.postloop() + except KeyboardInterrupt: + print("^C") + def print_shell(self, *args): try: for arg in args: @@ -273,7 +282,6 @@ class CloudStackShell(cmd.Cmd): x.partition("=")[2]], args[1:])[x] for x in range(len(args) - 1)) - # FIXME: With precaching, dynamic loading can be removed api_cmd_str = "%sCmd" % api_name api_mod = self.get_api_module(api_name, [api_cmd_str]) if api_mod is None: @@ -466,7 +474,7 @@ class CloudStackShell(cmd.Cmd): """ Quit on Ctrl+d or EOF """ - return True + sys.exit() def main():
