Repository: cloudstack-cloudmonkey Updated Branches: refs/heads/master 8ef5f4a6c -> 968430ef3
CLOUDSTACK-7669: Return non-zero exit code during single command run on shell 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/968430ef Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/tree/968430ef Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/diff/968430ef Branch: refs/heads/master Commit: 968430ef34d298a579780191a5c08f134125f6d7 Parents: 8ef5f4a Author: Rohit Yadav <rohit.ya...@shapeblue.com> Authored: Thu Oct 30 15:36:50 2014 +0530 Committer: Rohit Yadav <rohit.ya...@shapeblue.com> Committed: Thu Oct 30 15:36:50 2014 +0530 ---------------------------------------------------------------------- cloudmonkey/cloudmonkey.py | 5 +++++ 1 file changed, 5 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack-cloudmonkey/blob/968430ef/cloudmonkey/cloudmonkey.py ---------------------------------------------------------------------- diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py index b192708..28d6428 100644 --- a/cloudmonkey/cloudmonkey.py +++ b/cloudmonkey/cloudmonkey.py @@ -74,6 +74,7 @@ class CloudMonkeyShell(cmd.Cmd, object): config_options = [] profile_names = [] verbs = [] + error_on_last_command = False param_cache = {} prompt = "ðµ > " protocol = "http" @@ -291,12 +292,14 @@ class CloudMonkeyShell(cmd.Cmd, object): self.monkeyprint(result) def make_request(self, command, args={}, isasync=False): + self.error_on_last_command = False response, error = monkeyrequest(command, args, isasync, self.asyncblock, logger, self.url, self.credentials, self.timeout, self.expires) if error is not None: self.monkeyprint("Error %s" % error) + self.error_on_last_command = True return response def update_param_cache(self, api, result={}): @@ -704,6 +707,8 @@ def main(): shell.onecmd(" ".join(map(lambda x: x.replace("\\ ", " ") .replace(" ", "\\ "), args.commands))) + if shell.error_on_last_command: + sys.exit(1) else: shell.cmdloop()