]> git.proxmox.com Git - mirror_lxc.git/commitdiff
lxc-start-ephemeral: Use argparse errors
authorStéphane Graber <stgraber@ubuntu.com>
Tue, 4 Dec 2012 21:17:07 +0000 (16:17 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 4 Dec 2012 22:31:59 +0000 (17:31 -0500)
Use argparse's error function instead of our own print + exit.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxc-start-ephemeral.in

index ccf60591ab8709201e988d7b57a2641705449472..e11919fb45df7a15561256b6c3a746baf575b8b8 100644 (file)
@@ -96,20 +96,17 @@ args = parser.parse_args()
 # Basic requirements check
 ## Check that -d and CMD aren't used at the same time
 if args.command and args.daemon:
-    print(_("You can't use -d and a command at the same time."))
-    sys.exit(1)
+    parser.error(_("You can't use -d and a command at the same time."))
 
 ## The user needs to be uid 0
 if not os.geteuid() == 0:
-    print(_("You must be root to run this script. Try running: sudo %s" %
-            (sys.argv[0])))
-    sys.exit(1)
+    parser.error(_("You must be root to run this script. Try running: sudo %s"
+                   % (sys.argv[0])))
 
 # Load the orig container
 orig = lxc.Container(args.orig)
 if not orig.defined:
-    print(_("Source container '%s' doesn't exist." % args.orig))
-    sys.exit(1)
+    parser.error(_("Source container '%s' doesn't exist." % args.orig))
 
 # Create the new container paths
 dest_path = tempfile.mkdtemp(prefix="%s-" % args.orig, dir="@LXCPATH@")