Ravi Nori has uploaded a new change for review.

Change subject: cli: ovirt-shell does not exit when using -f option(#854519)
......................................................................

cli: ovirt-shell does not exit when using -f option(#854519)

ovirt-shell does not exit when -f option is used. This option
is used by system scripts and it would be useful to exit the
ovirt-shell upon completion of the command execution.

Change-Id: I5441a401ed39fc7148b6001fb826b145ba66d6c7
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=854519
Signed-off-by: Ravi Nori <rn...@redhat.com>
---
M src/ovirtcli/shell/engineshell.py
M src/ovirtcli/shell/filecmdshell.py
2 files changed, 8 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-cli refs/changes/12/12212/1

diff --git a/src/ovirtcli/shell/engineshell.py 
b/src/ovirtcli/shell/engineshell.py
index 82a6552..8731289 100644
--- a/src/ovirtcli/shell/engineshell.py
+++ b/src/ovirtcli/shell/engineshell.py
@@ -156,7 +156,9 @@
             if opts.file:
                 cmd.Cmd.intro = None
                 self.do_file(opts.file)
-            self.cmdloop(clear=False)
+                self.exitWithStatusAndMsg(0, 'Command executed successfully.')
+            else:
+                self.cmdloop(clear=False)
         else:
             self.cmdloop()
 
@@ -264,6 +266,10 @@
         self.emptyline(no_prompt=True)
         return True
 
+    def exitWithStatusAndMsg(self, status=0, msg=None):
+        if msg: print (msg + '\n')
+        sys.exit(status)
+
     def do_exit(self, args):
         """\
         == Usage ==
diff --git a/src/ovirtcli/shell/filecmdshell.py 
b/src/ovirtcli/shell/filecmdshell.py
index 89dc4df..c2f8724 100644
--- a/src/ovirtcli/shell/filecmdshell.py
+++ b/src/ovirtcli/shell/filecmdshell.py
@@ -47,6 +47,6 @@
                     self.owner.print_line(line)
                     self.owner.onecmd(line)
         except Exception, e:
-            self._error(str(e))
+            self.exitWithStatusAndMsg(e.errno, str(e))
         finally:
             self.context.mode = ExecutionMode.SHELL


--
To view, visit http://gerrit.ovirt.org/12212
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5441a401ed39fc7148b6001fb826b145ba66d6c7
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine-cli
Gerrit-Branch: master
Gerrit-Owner: Ravi Nori <rn...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to