From 4d0c5e067027d4700fd185a8f89bfc7df24a3569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20David?= Date: Mon, 20 Jun 2022 21:07:57 +0200 Subject: [PATCH] Fix: Stopping error if local folder already exists --- src/pulse/api.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pulse/api.py b/src/pulse/api.py index ac7e32b..b5f5a7a 100644 --- a/src/pulse/api.py +++ b/src/pulse/api.py @@ -925,7 +925,7 @@ def get_work(self): except PulseError: return None - def checkout(self, index="last", destination_folder=None, recreate_products=True, resolve_conflict="error"): + def checkout(self, index="last", destination_folder:Union[str, Path]=None, recreate_products=True, resolve_conflict="error"): """ Download the resource work files in the user work space. Download related dependencies if they are not available in user products space @@ -947,6 +947,7 @@ def checkout(self, index="last", destination_folder=None, recreate_products=True if not destination_folder: destination_folder = self.sandbox_path + destination_folder = Path(destination_folder) # create the work object work.version = self.last_version + 1 @@ -982,7 +983,8 @@ def checkout(self, index="last", destination_folder=None, recreate_products=True # if no source has been found, just create empty work folder if not source_commit: - os.makedirs(destination_folder) + if not destination_folder.is_dir(): + destination_folder.mkdir(parents=True) else: self.project.cnx.repositories[source_resource.repository].download_work(source_commit, destination_folder) out_product_list = source_commit.products