Commit b5838447aa3c3f0fa8119790c0572c22f8dfe01a

Authored by Alexis Koralewski
1 parent 19fd5023
Exists in dev

install_observatory now copy default observatory if repository doesn't exists

Showing 2 changed files with 17 additions and 6 deletions   Show diff stats
CHANGELOG
1 1 21-07-2023 (AKo): V0.6.27.0
  2 + - install_observatory now copy default observatory if repository doesn't exists
  3 +
  4 +21-07-2023 (AKo): V0.6.27.0
2 5 - Fix issues due to deletion of modules (utils)
3 6 - Fix various obsconfig (add mandatory agents for default, tests obsconfig)
4 7 - Fix dockerfile & docker-compose.yml
... ...
pyros.py
... ... @@ -1575,11 +1575,14 @@ def install_packages():
1575 1575 @click.argument("observatory")
1576 1576 def install_observatory(observatory):
1577 1577 pyros_observatory_path = "../PYROS_OBSERVATORY"
  1578 + pyros_observatory_default_path = os.path.join(os.path.abspath(
  1579 + PYROS_DJANGO_BASE_DIR), "../../../config/pyros_observatory/pyros_observatory_default/")
  1580 +
1578 1581 if not os.path.exists(pyros_observatory_path):
1579 1582 os.mkdir(pyros_observatory_path)
1580 1583  
1581 1584 try:
1582   - from git import Repo
  1585 + from git import Repo, GitError
1583 1586 except:
1584 1587 pip = "pip" if IS_WINDOWS else "pip3"
1585 1588 if WITH_DOCKER:
... ... @@ -1591,17 +1594,22 @@ def install_observatory(observatory):
1591 1594 process.wait()
1592 1595 if process.returncode == 0:
1593 1596 # self.addExecuted(self.current_command, command)
1594   - from git import Repo
  1597 + from git import Repo, GitError
1595 1598 else:
1596 1599 log.error("GitPython package (required for obsconfig class) installation failed")
1597   - print(os.path.join(pyros_observatory_path, f"pyros_observatory_{observatory}"))
1598 1600 if os.path.exists(os.path.join(pyros_observatory_path, f"pyros_observatory_{observatory}")):
1599 1601 print("Observatory already cloned")
1600 1602 else:
1601 1603 print("Cloning repository")
1602   - cloned_repo = Repo.clone_from(
1603   - f"https://gitlab.irap.omp.eu/pyros-irap/pyros_observatory_{observatory}.git", os.path.join(pyros_observatory_path, f"pyros_observatory_{observatory}"))
1604   - print("Cloned successfully: ", cloned_repo.__class__ is Repo)
  1604 + try:
  1605 + cloned_repo = Repo.clone_from(
  1606 + f"https://gitlab.irap.omp.eu/pyros-irap/pyros_observatory_{observatory}.git", os.path.join(pyros_observatory_path, f"pyros_observatory_{observatory}"))
  1607 + print("Cloned successfully: ", cloned_repo.__class__ is Repo)
  1608 + except GitError:
  1609 + if not os.path.exists(os.path.join(pyros_observatory_path, f"pyros_observatory_{observatory}")):
  1610 + print("No repository found. PyROS will create a copy of an default observatory that you can modify.")
  1611 + shutil.copytree(pyros_observatory_default_path, os.path.join(pyros_observatory_path, f"pyros_observatory_{observatory}"))
  1612 + print(f"Observatory created at {os.getcwd()}/{pyros_observatory_path}/pyros_observatory_observatory")
1605 1613  
1606 1614  
1607 1615 def install_database(venv):
... ...