diff --git a/pyros.py b/pyros.py index 6f79aa8..8f3dbe1 100755 --- a/pyros.py +++ b/pyros.py @@ -815,21 +815,24 @@ def initdb(): return True - -@pyros_launcher.command(help="Install dependencies") +@pyros_launcher.command(help="Install dependencies from Observatory config DEPENDENCY section") # @global_test_options -@click.option('--observatory', '-o', help='the observatory name to be used') -@click.option('--unit', '-u', help='the unit name to be used') +@click.option('--observatory', '-o', help='the Observatory name to be used') +@click.option('--unit', '-u', help='the Unit name to be used') @click.option("--foreground","-fg", is_flag=True, help="Print stdout and error in terminal") def install_dependencies(observatory: str, unit: str, foreground: bool): - if observatory == None or len(observatory) == 0: + if (observatory is None) or (len(observatory) == 0): observatory = "default" default_obsconfig_folder = os.path.join( - os.path.abspath(PYROS_DJANGO_BASE_DIR), "../../../config/pyros_observatory/") + os.path.abspath(PYROS_DJANGO_BASE_DIR), + "../../../config/pyros_observatory/" + ) path_to_obs_config_folder = default_obsconfig_folder+"pyros_observatory_"+observatory+"/" else: observatories_configuration_folder = os.path.join( - os.path.abspath(PYROS_DJANGO_BASE_DIR), "../../../../PYROS_OBSERVATORY/") + os.path.abspath(PYROS_DJANGO_BASE_DIR), + "../../../../PYROS_OBSERVATORY/" + ) if len(glob.glob(observatories_configuration_folder+"pyros_observatory_"+observatory+"/")) != 1: # Observatory configuration folder not found print( @@ -844,15 +847,14 @@ def install_dependencies(observatory: str, unit: str, foreground: bool): # Search for observatory config file obs_config_file_name = glob.glob(os.path.join(path_to_obs_config_folder, "observatory.yml"))[0] - obs_config_file_path = os.path.join( - path_to_obs_config_folder, obs_config_file_name) + obs_config_file_path = os.path.join(path_to_obs_config_folder, obs_config_file_name) os.environ["PATH_TO_OBSCONF_FILE"] = obs_config_file_path os.environ["PATH_TO_OBSCONF_FOLDER"] = path_to_obs_config_folder os.environ["unit_name"] = unit if unit else '' # add path to pyros_django folder as the config class is supposed to work within this folder cmd_test_obs_config = f"-c \"from src.core.pyros_django.obs_config.obsconfig_class import OBSConfig\nOBSConfig('{obs_config_file_path}')\"" - if not execProcessFromVenv(cmd_test_obs_config,foreground=True): + if not execProcessFromVenv(cmd_test_obs_config, foreground=True): # Observatory configuration has an issue exit(1) else: @@ -861,12 +863,8 @@ def install_dependencies(observatory: str, unit: str, foreground: bool): from git import Repo, GitError except: pip = "pip" if IS_WINDOWS else "pip3" - if WITH_DOCKER: - process = subprocess.Popen( - pip + " install --user --upgrade GitPython", shell=True) - else: - process = subprocess.Popen( - pip + " install --upgrade GitPython", shell=True) + usermode = '--user' if WITH_DOCKER else '' + process = subprocess.Popen(pip + f" install {usermode} --upgrade GitPython", shell=True) process.wait() if process.returncode == 0: # self.addExecuted(self.current_command, command) -- libgit2 0.21.2