From 87fc188d5a210b406355d159ea3e84f90ff8cb38 Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Thu, 13 Apr 2017 15:06:33 +0100 Subject: Handle error case when creating destination folder `OSError: [Errno 17] File exists: ...` error occurs when trying to create the destination directory specified from the user without checking if it already exists. --- virt-bootstrap.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'virt-bootstrap.py') diff --git a/virt-bootstrap.py b/virt-bootstrap.py index 36902f5..8540d98 100644 --- a/virt-bootstrap.py +++ b/virt-bootstrap.py @@ -66,7 +66,8 @@ def set_root_password(rootfs, password): def bootstrap(args): source = get_source(args) - os.makedirs(args.dest) + if not os.path.exists(args.dest): + os.makedirs(args.dest) source.unpack(args.dest) if args.root_password is not None: -- cgit