Commit e1b0fb96e18c40098d2b73b75a4b173c29f85bef
1 parent
b6ff102c
Exists in
dev
petits reformatages
Showing
1 changed file
with
14 additions
and
16 deletions
Show diff stats
pyros.py
... | ... | @@ -815,21 +815,24 @@ def initdb(): |
815 | 815 | return True |
816 | 816 | |
817 | 817 | |
818 | - | |
819 | -@pyros_launcher.command(help="Install dependencies") | |
818 | +@pyros_launcher.command(help="Install dependencies from Observatory config DEPENDENCY section") | |
820 | 819 | # @global_test_options |
821 | -@click.option('--observatory', '-o', help='the observatory name to be used') | |
822 | -@click.option('--unit', '-u', help='the unit name to be used') | |
820 | +@click.option('--observatory', '-o', help='the Observatory name to be used') | |
821 | +@click.option('--unit', '-u', help='the Unit name to be used') | |
823 | 822 | @click.option("--foreground","-fg", is_flag=True, help="Print stdout and error in terminal") |
824 | 823 | def install_dependencies(observatory: str, unit: str, foreground: bool): |
825 | - if observatory == None or len(observatory) == 0: | |
824 | + if (observatory is None) or (len(observatory) == 0): | |
826 | 825 | observatory = "default" |
827 | 826 | default_obsconfig_folder = os.path.join( |
828 | - os.path.abspath(PYROS_DJANGO_BASE_DIR), "../../../config/pyros_observatory/") | |
827 | + os.path.abspath(PYROS_DJANGO_BASE_DIR), | |
828 | + "../../../config/pyros_observatory/" | |
829 | + ) | |
829 | 830 | path_to_obs_config_folder = default_obsconfig_folder+"pyros_observatory_"+observatory+"/" |
830 | 831 | else: |
831 | 832 | observatories_configuration_folder = os.path.join( |
832 | - os.path.abspath(PYROS_DJANGO_BASE_DIR), "../../../../PYROS_OBSERVATORY/") | |
833 | + os.path.abspath(PYROS_DJANGO_BASE_DIR), | |
834 | + "../../../../PYROS_OBSERVATORY/" | |
835 | + ) | |
833 | 836 | if len(glob.glob(observatories_configuration_folder+"pyros_observatory_"+observatory+"/")) != 1: |
834 | 837 | # Observatory configuration folder not found |
835 | 838 | print( |
... | ... | @@ -844,15 +847,14 @@ def install_dependencies(observatory: str, unit: str, foreground: bool): |
844 | 847 | # Search for observatory config file |
845 | 848 | obs_config_file_name = glob.glob(os.path.join(path_to_obs_config_folder, "observatory.yml"))[0] |
846 | 849 | |
847 | - obs_config_file_path = os.path.join( | |
848 | - path_to_obs_config_folder, obs_config_file_name) | |
850 | + obs_config_file_path = os.path.join(path_to_obs_config_folder, obs_config_file_name) | |
849 | 851 | os.environ["PATH_TO_OBSCONF_FILE"] = obs_config_file_path |
850 | 852 | os.environ["PATH_TO_OBSCONF_FOLDER"] = path_to_obs_config_folder |
851 | 853 | os.environ["unit_name"] = unit if unit else '' |
852 | 854 | |
853 | 855 | # add path to pyros_django folder as the config class is supposed to work within this folder |
854 | 856 | cmd_test_obs_config = f"-c \"from src.core.pyros_django.obs_config.obsconfig_class import OBSConfig\nOBSConfig('{obs_config_file_path}')\"" |
855 | - if not execProcessFromVenv(cmd_test_obs_config,foreground=True): | |
857 | + if not execProcessFromVenv(cmd_test_obs_config, foreground=True): | |
856 | 858 | # Observatory configuration has an issue |
857 | 859 | exit(1) |
858 | 860 | else: |
... | ... | @@ -861,12 +863,8 @@ def install_dependencies(observatory: str, unit: str, foreground: bool): |
861 | 863 | from git import Repo, GitError |
862 | 864 | except: |
863 | 865 | pip = "pip" if IS_WINDOWS else "pip3" |
864 | - if WITH_DOCKER: | |
865 | - process = subprocess.Popen( | |
866 | - pip + " install --user --upgrade GitPython", shell=True) | |
867 | - else: | |
868 | - process = subprocess.Popen( | |
869 | - pip + " install --upgrade GitPython", shell=True) | |
866 | + usermode = '--user' if WITH_DOCKER else '' | |
867 | + process = subprocess.Popen(pip + f" install {usermode} --upgrade GitPython", shell=True) | |
870 | 868 | process.wait() |
871 | 869 | if process.returncode == 0: |
872 | 870 | # self.addExecuted(self.current_command, command) | ... | ... |