WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Fix exit status for failed commands, and

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Fix exit status for failed commands, and tidy up the usage display.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 15 Dec 2006 10:50:29 +0000
Delivery-date: Fri, 15 Dec 2006 02:51:25 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Node ID 29ae139a0c72ba952a447f5b0a29538b35d97a41
# Parent  d72237b3cc37f42edd92798bcacaf89e73fe122e
Fix exit status for failed commands, and tidy up the usage display.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 tools/python/xen/xm/main.py |   31 +++++++++++--------------------
 1 files changed, 11 insertions(+), 20 deletions(-)

diff -r d72237b3cc37 -r 29ae139a0c72 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Fri Dec 15 01:42:31 2006 +0000
+++ b/tools/python/xen/xm/main.py       Fri Dec 15 02:01:38 2006 +0000
@@ -608,7 +608,7 @@ def xm_restore(args):
         (options, params) = getopt.gnu_getopt(args, 'p', ['paused'])
     except getopt.GetoptError, opterr:
         err(opterr)
-        sys.exit(1)
+        usage('restore')
 
     paused = False
     for (k, v) in options:
@@ -618,7 +618,6 @@ def xm_restore(args):
     if len(params) != 1:
         err("Wrong number of parameters")
         usage('restore')
-        sys.exit(1)
 
     savefile = os.path.abspath(params[0])
 
@@ -648,7 +647,6 @@ def xm_list(args):
     except getopt.GetoptError, opterr:
         err(opterr)
         usage('list')
-        sys.exit(1)
     
     for (k, v) in options:
         if k in ['-l', '--long']:
@@ -869,7 +867,7 @@ def xm_start(args):
         (options, params) = getopt.gnu_getopt(args, 'p', ['paused'])
     except getopt.GetoptError, opterr:
         err(opterr)
-        sys.exit(1)
+        usage('start')
 
     paused = False
     for (k, v) in options:
@@ -879,7 +877,6 @@ def xm_start(args):
     if len(params) != 1:
         err("Wrong number of parameters")
         usage('start')
-        sys.exit(1)
 
     dom = params[0]
     if serverType == SERVER_XEN_API:
@@ -910,7 +907,7 @@ def xm_resume(args):
         (options, params) = getopt.gnu_getopt(args, 'p', ['paused'])
     except getopt.GetoptError, opterr:
         err(opterr)
-        sys.exit(1)
+        usage('resume')
 
     paused = False
     for (k, v) in options:
@@ -920,7 +917,6 @@ def xm_resume(args):
     if len(params) != 1:
         err("Wrong number of parameters")
         usage('resume')
-        sys.exit(1)
 
     dom = params[0]
     if serverType == SERVER_XEN_API:
@@ -1115,7 +1111,7 @@ def xm_sched_sedf(args):
             ['period=', 'slice=', 'latency=', 'extratime=', 'weight='])
     except getopt.GetoptError, opterr:
         err(opterr)
-        sys.exit(1)
+        usage('sched-sedf')
     
     # convert to nanoseconds if needed 
     for (k, v) in options:
@@ -1176,7 +1172,6 @@ def xm_sched_credit(args):
     except getopt.GetoptError, opterr:
         err(opterr)
         usage('sched-credit')
-        sys.exit(1)
 
     domain = None
     weight = None
@@ -1194,7 +1189,6 @@ def xm_sched_credit(args):
         # place holder for system-wide scheduler parameters
         err("No domain given.")
         usage('sched-credit')
-        sys.exit(1)
 
     if weight is None and cap is None:
         print server.xend.domain.sched_credit_get(domain)
@@ -1223,7 +1217,7 @@ def xm_console(args):
         (options, params) = getopt.gnu_getopt(args, 'q', ['quiet'])
     except getopt.GetoptError, opterr:
         err(opterr)
-        sys.exit(1)
+        usage('console')
 
     for (k, v) in options:
         if k in ['-q', '--quiet']:
@@ -1234,7 +1228,6 @@ def xm_console(args):
     if len(params) != 1:
         err('No domain given')
         usage('console')
-        sys.exit(1)
 
     dom = params[0]
 
@@ -1262,7 +1255,7 @@ def xm_uptime(args):
         (options, params) = getopt.gnu_getopt(args, 's', ['short'])
     except getopt.GetoptError, opterr:
         err(opterr)
-        sys.exit(1)
+        usage('uptime')
 
     for (k, v) in options:
         if k in ['-s', '--short']:
@@ -1327,7 +1320,7 @@ def xm_dmesg(args):
         (options, params) = getopt.gnu_getopt(args, 'c', ['clear'])
     except getopt.GetoptError, opterr:
         err(opterr)
-        sys.exit(1)
+        usage('dmesg')
     
     use_clear = 0
     for (k, v) in options:
@@ -1337,7 +1330,6 @@ def xm_dmesg(args):
     if len(params) :
         err("No parameter required")
         usage('dmesg')
-        sys.exit(1)
 
     if not use_clear:
         print server.xend.node.dmesg.info()
@@ -1576,7 +1568,7 @@ def xm_vnet_list(args):
         (options, params) = getopt.gnu_getopt(args, 'l', ['long'])
     except getopt.GetoptError, opterr:
         err(opterr)
-        sys.exit(1)
+        usage('vnet-list')
     
     use_long = 0
     for (k, v) in options:
@@ -1743,8 +1735,7 @@ def main(argv=sys.argv):
         # strip off prog name and subcmd
         args = argv[2:]
         _, rc = _run_cmd(cmd, cmd_name, args)
-        if rc:
-            usage(cmd_name)
+        sys.exit(rc)
     else:
         usage()
 
@@ -1780,8 +1771,8 @@ def _run_cmd(cmd, cmd_name, args):
             err("Most commands need root access.  Please try again as root.")
         else:
             err("Unable to connect to xend: %s." % ex[1])
-    except SystemExit:
-        return True, ''
+    except SystemExit, code:
+        return code == 0, code
     except XenAPI.Failure, exn:
         err(str(exn))
     except xmlrpclib.Fault, ex:

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Fix exit status for failed commands, and tidy up the usage display., Xen patchbot-unstable <=