From 2b4e74ac47e30e4b39cef4d32b15226e880ff3e5 Mon Sep 17 00:00:00 2001 From: Etienne Pallier Date: Mon, 14 Mar 2022 12:27:48 +0100 Subject: [PATCH] sphinx autodoc v5 --- Dockerfile | 3 ++- pyros.py | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------- 2 files changed, 55 insertions(+), 44 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0684619..9226818 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ RUN apt-get update && apt-get install -y \ nano \ vim \ # for PNG diagrams generation with pyreverse (pylint) - graphviz + graphviz graphviz-dev # Get IRAP self signed certificate RUN echo | openssl s_client -connect gitlab.irap.omp.eu:443 -servername gitlab.irap.omp.eu 2>/dev/null | openssl x509 > /etc/ssl/certs/gitlab.irap.omp.eu.crt @@ -37,3 +37,4 @@ RUN pip install --user click # installing packages required for PyROS RUN pip install --user -r ./install/requirements.txt +RUN pip install --user -r ./install/requirements_dev.txt diff --git a/pyros.py b/pyros.py index c5d7b4a..faf67e0 100755 --- a/pyros.py +++ b/pyros.py @@ -501,33 +501,69 @@ def dbshell(): return True +@pyros_launcher.command(help="Update (only if necessary) the python packages AND the source code AND the DB structure") +def update(): + install_or_update(UPDATE=True) + ''' + print("Running update command") + # 1) Update source code (git pull) + printFullTerm(Colors.BLUE, "1) UPDATING SOURCE CODE: Running git pull") + _gitpull() or die() + + # Re-install VENV if disappeared + install_venv(False) + + # 2) Update python packages (pip upgrade AND pip install requirements) + printFullTerm(Colors.BLUE, "2) UPDATING PYTHON PACKAGES") + ##_update_python_packages_from_requirements() or die() + install_packages() + print(os.getcwd()) + # 3) Update PlantUML diagrams + printFullTerm(Colors.BLUE, "3) UPDATING PLANTUML DIAGRAMS") + _update_plantuml_diags() or die() + print(os.getcwd()) + + # 4) Update database structure (make migrations + migrate) + printFullTerm(Colors.BLUE, "4) UPDATING DATABASE") + _updatedb() or die() + return True + ''' + + @pyros_launcher.command(help="Install the pyros software") @click.option('--packages_only', '-p', is_flag=True, help='install only the python packages (no database installation)') @click.option('--database_only', '-d', is_flag=True, help='install only the pyros database (no python packages installation)') # @global_test_options def install(packages_only, database_only): - install_or_update(UPDATE=False, packages_only=packages_only, - database_only=database_only) + with_packages = not database_only + with_database = not packages_only + install_or_update(UPDATE=False, with_packages=with_packages, with_database=with_database) + #install_or_update(UPDATE=False, with_packages=packages_only, with_database=database_only) + #install_or_update(UPDATE=False, packages_only=packages_only, database_only=database_only) -def install_or_update(UPDATE: bool = False, packages_only: bool = False, database_only: bool = False): +#def install_or_update(UPDATE: bool = False, with_packages: bool = False, with_database: bool = False): +def install_or_update(UPDATE: bool = False, with_packages: bool = True, with_database: bool = True): SQL_USER = os.environ.get("MYSQL_PYROS_LOGIN").strip() SQL_PSWD = os.environ.get("MYSQL_PYROS_PWD").strip() os.environ["PATH_TO_OBSCONF_FOLDER"] = os.path.join(os.path.abspath( PYROS_DJANGO_BASE_DIR), "../../../privatedev/config/default/") ACTION = "UPDATING" if UPDATE else "INSTALLING" - if WITH_DOCKER: - database_only = True - if not packages_only and not database_only: - packages_only = database_only = True + #if WITH_DOCKER: with_database = True + #if not with_packages and not with_database: with_packages = with_database = True + print("- with_packages:", with_packages) + print("- with_database:", with_database) + if UPDATE: + print("Running UPDATE command") + else: + print("Running INSTALL command") + exit() if UPDATE: print("Running UPDATE command") else: print("Running INSTALL command") - print("- packages_only:", packages_only) - print("- database_only:", database_only) # Git clone Guitastro if not already cloned: try: from git import Repo @@ -557,8 +593,7 @@ def install_or_update(UPDATE: bool = False, packages_only: bool = False, databas print("Installing/Updating Guitastro python package dependencies") # Upgrade pip if new version available os.system(VENV_PYTHON + ' -m pip install --user --upgrade pip') - venv_pip_install2( - GUITASTRO_PATH + '/install/requirements.txt', '-r') + venv_pip_install2(GUITASTRO_PATH + '/install/requirements.txt', '-r') #if test_mode(): print("in test mode") # self.execProcess("python3 install/install.py install") @@ -574,7 +609,7 @@ def install_or_update(UPDATE: bool = False, packages_only: bool = False, databas _gitpull() or die() # 2) Update python packages (pip upgrade AND pip install requirements) - if packages_only: + if with_packages: num += 1 printFullTerm(Colors.BLUE, f"{num}) {ACTION} PYTHON PACKAGES") # (UPDATE) Re-install VENV if disappeared @@ -591,10 +626,9 @@ def install_or_update(UPDATE: bool = False, packages_only: bool = False, databas num += 1 printFullTerm(Colors.BLUE, f"{num}) UPDATING API DOC (with Sphinx)") _update_api_doc() or die() - exit() # 5) Install/Update database structure (make migrations + migrate) - if database_only: + if with_database: num += 1 printFullTerm(Colors.BLUE, f"{num}) {ACTION} DATABASE") if UPDATE: @@ -659,33 +693,6 @@ def testall(): return True -@pyros_launcher.command(help="Update (only if necessary) the python packages AND the source code AND the DB structure") -def update(): - install_or_update(UPDATE=True) - ''' - print("Running update command") - # 1) Update source code (git pull) - printFullTerm(Colors.BLUE, "1) UPDATING SOURCE CODE: Running git pull") - _gitpull() or die() - - # Re-install VENV if disappeared - install_venv(False) - - # 2) Update python packages (pip upgrade AND pip install requirements) - printFullTerm(Colors.BLUE, "2) UPDATING PYTHON PACKAGES") - ##_update_python_packages_from_requirements() or die() - install_packages() - print(os.getcwd()) - # 3) Update PlantUML diagrams - printFullTerm(Colors.BLUE, "3) UPDATING PLANTUML DIAGRAMS") - _update_plantuml_diags() or die() - print(os.getcwd()) - - # 4) Update database structure (make migrations + migrate) - printFullTerm(Colors.BLUE, "4) UPDATING DATABASE") - _updatedb() or die() - return True - ''' def _gitpull(): @@ -1241,8 +1248,11 @@ def install_packages(): #os.system(VENV_PIP+' install -r ../install' + os.sep + REQUIREMENTS) # DEV only packages - print(Colors.LOG_BLUE + "-----------------------------Installing DEV python packages via pip-----------------------------" + Colors.END) - venv_pip_install('../install/'+REQUIREMENTS_DEV, '-r') + if DEV: + print(Colors.LOG_BLUE + "-----------------------------Installing DEV python packages via pip-----------------------------" + Colors.END) + venv_pip_install('../install/'+REQUIREMENTS_DEV, '-r') + print("FIN INSTALL PACKAGES") + exit() #print(Colors.LOG_BLUE + "-----------------------------cd ../install-----------------------------" + Colors.END) -- libgit2 0.21.2