From 1000430aa0f4b9d7c5a06bff27f690db654b9766 Mon Sep 17 00:00:00 2001 From: Nicolas Braud-Santoni Date: Sun, 7 Aug 2016 17:25:46 +0200 Subject: [PATCH] file_copy: Allow copying directories --- bootstrapvz/plugins/file_copy/__init__.py | 2 +- bootstrapvz/plugins/file_copy/tasks.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bootstrapvz/plugins/file_copy/__init__.py b/bootstrapvz/plugins/file_copy/__init__.py index eec9cb9..6bdbc60 100644 --- a/bootstrapvz/plugins/file_copy/__init__.py +++ b/bootstrapvz/plugins/file_copy/__init__.py @@ -9,7 +9,7 @@ def validate_manifest(data, validator, error): for i, file_entry in enumerate(data['plugins']['file_copy']['files']): srcfile = file_entry['src'] - if not os.path.isfile(srcfile): + if not os.path.exists(srcfile): msg = 'The source file %s does not exist.' % srcfile error(msg, ['plugins', 'file_copy', 'files', i]) diff --git a/bootstrapvz/plugins/file_copy/tasks.py b/bootstrapvz/plugins/file_copy/tasks.py index cc1a783..179cffd 100644 --- a/bootstrapvz/plugins/file_copy/tasks.py +++ b/bootstrapvz/plugins/file_copy/tasks.py @@ -47,5 +47,9 @@ class FileCopyCommand(Task): # note that we don't use os.path.join because it can't # handle absolute paths, which 'dst' most likely is. final_destination = os.path.normpath("%s/%s" % (info.root, file_entry['dst'])) - shutil.copy(file_entry['src'], final_destination) + if os.path.isfile(file_entry['src']): + shutil.copy(file_entry['src'], final_destination) + else: + shutil.copytree(file_entry['src'], final_destination) + modify_path(info, file_entry['dst'], file_entry)