diff options
| author | Marcin Juszkiewicz <marcin.juszkiewicz+kolla@linaro.org> | 2022-09-14 15:49:48 +0200 |
|---|---|---|
| committer | Marcin Juszkiewicz <marcin.juszkiewicz+kolla@linaro.org> | 2022-09-14 15:52:28 +0200 |
| commit | 0e3a55252b04e8e81db7b0f5636fb6624824a5cb (patch) | |
| tree | f1e820f5f51a5df69a4bf18ea63b3f5f80c64ff8 | |
| parent | 0d4e8e6c11947e07953121d6009809db69f4965b (diff) | |
| download | kolla-0e3a55252b04e8e81db7b0f5636fb6624824a5cb.tar.gz kolla-0e3a55252b04e8e81db7b0f5636fb6624824a5cb.zip | |
Python 3.8+ has better shutil.copytree()
doc says:
> If dirs_exist_ok is false (the default) and dst already exists, a
> FileExistsError is raised. If dirs_exist_ok is true, the copying
> operation will continue if it encounters existing directories, and files
> within the dst tree will be overwritten by corresponding files from the
> src tree.
So we do not have to copy dirs/files one by one and tell
shutil.copytree() to handle everything.
Change-Id: I97d9c8261351b8fd88f088c1463cc508e07792e7
| -rwxr-xr-x | kolla/image/build.py | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/kolla/image/build.py b/kolla/image/build.py index 546404ab5..b03bb55d7 100755 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -744,16 +744,7 @@ class KollaWorker(object): ) def copy_dir(self, src, dest): - if not os.path.isdir(dest): - shutil.copytree(src, dest) - else: - for file in os.listdir(src): - src_path = os.path.join(src, file) - dest_path = os.path.join(dest, file) - if os.path.isdir(src_path): - self.copy_dir(src_path, dest_path) - else: - shutil.copy2(src_path, dest_path) + shutil.copytree(src, dest, dirs_exist_ok=True) def setup_working_dir(self): """Creates a working directory for use while building.""" |
