Commit c0b5f522 by Stéphane Graber

lxc-start-ephemeral: Use argparse errors

Use argparse's error function instead of our own print + exit. Signed-off-by: 's avatarStéphane Graber <stgraber@ubuntu.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent 7b35f3d6
......@@ -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@")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment