From b5838447aa3c3f0fa8119790c0572c22f8dfe01a Mon Sep 17 00:00:00 2001 From: Alexis Koralewski Date: Mon, 24 Jul 2023 16:55:09 +0200 Subject: [PATCH] install_observatory now copy default observatory if repository doesn't exists --- CHANGELOG | 3 +++ pyros.py | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1d6d64f..99a817e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,7 @@ 21-07-2023 (AKo): V0.6.27.0 + - install_observatory now copy default observatory if repository doesn't exists + +21-07-2023 (AKo): V0.6.27.0 - Fix issues due to deletion of modules (utils) - Fix various obsconfig (add mandatory agents for default, tests obsconfig) - Fix dockerfile & docker-compose.yml diff --git a/pyros.py b/pyros.py index 1845632..6b10326 100755 --- a/pyros.py +++ b/pyros.py @@ -1575,11 +1575,14 @@ def install_packages(): @click.argument("observatory") def install_observatory(observatory): pyros_observatory_path = "../PYROS_OBSERVATORY" + pyros_observatory_default_path = os.path.join(os.path.abspath( + PYROS_DJANGO_BASE_DIR), "../../../config/pyros_observatory/pyros_observatory_default/") + if not os.path.exists(pyros_observatory_path): os.mkdir(pyros_observatory_path) try: - from git import Repo + from git import Repo, GitError except: pip = "pip" if IS_WINDOWS else "pip3" if WITH_DOCKER: @@ -1591,17 +1594,22 @@ def install_observatory(observatory): process.wait() if process.returncode == 0: # self.addExecuted(self.current_command, command) - from git import Repo + from git import Repo, GitError else: log.error("GitPython package (required for obsconfig class) installation failed") - print(os.path.join(pyros_observatory_path, f"pyros_observatory_{observatory}")) if os.path.exists(os.path.join(pyros_observatory_path, f"pyros_observatory_{observatory}")): print("Observatory already cloned") else: print("Cloning repository") - cloned_repo = Repo.clone_from( - f"https://gitlab.irap.omp.eu/pyros-irap/pyros_observatory_{observatory}.git", os.path.join(pyros_observatory_path, f"pyros_observatory_{observatory}")) - print("Cloned successfully: ", cloned_repo.__class__ is Repo) + try: + cloned_repo = Repo.clone_from( + f"https://gitlab.irap.omp.eu/pyros-irap/pyros_observatory_{observatory}.git", os.path.join(pyros_observatory_path, f"pyros_observatory_{observatory}")) + print("Cloned successfully: ", cloned_repo.__class__ is Repo) + except GitError: + if not os.path.exists(os.path.join(pyros_observatory_path, f"pyros_observatory_{observatory}")): + print("No repository found. PyROS will create a copy of an default observatory that you can modify.") + shutil.copytree(pyros_observatory_default_path, os.path.join(pyros_observatory_path, f"pyros_observatory_{observatory}")) + print(f"Observatory created at {os.getcwd()}/{pyros_observatory_path}/pyros_observatory_observatory") def install_database(venv): -- libgit2 0.21.2