Commit e1b0fb96e18c40098d2b73b75a4b173c29f85bef

Authored by Etienne Pallier
1 parent b6ff102c
Exists in dev

petits reformatages

Showing 1 changed file with 14 additions and 16 deletions   Show diff stats
@@ -815,21 +815,24 @@ def initdb(): @@ -815,21 +815,24 @@ def initdb():
815 return True 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 # @global_test_options 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 @click.option("--foreground","-fg", is_flag=True, help="Print stdout and error in terminal") 822 @click.option("--foreground","-fg", is_flag=True, help="Print stdout and error in terminal")
824 def install_dependencies(observatory: str, unit: str, foreground: bool): 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 observatory = "default" 825 observatory = "default"
827 default_obsconfig_folder = os.path.join( 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 path_to_obs_config_folder = default_obsconfig_folder+"pyros_observatory_"+observatory+"/" 830 path_to_obs_config_folder = default_obsconfig_folder+"pyros_observatory_"+observatory+"/"
830 else: 831 else:
831 observatories_configuration_folder = os.path.join( 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 if len(glob.glob(observatories_configuration_folder+"pyros_observatory_"+observatory+"/")) != 1: 836 if len(glob.glob(observatories_configuration_folder+"pyros_observatory_"+observatory+"/")) != 1:
834 # Observatory configuration folder not found 837 # Observatory configuration folder not found
835 print( 838 print(
@@ -844,15 +847,14 @@ def install_dependencies(observatory: str, unit: str, foreground: bool): @@ -844,15 +847,14 @@ def install_dependencies(observatory: str, unit: str, foreground: bool):
844 # Search for observatory config file 847 # Search for observatory config file
845 obs_config_file_name = glob.glob(os.path.join(path_to_obs_config_folder, "observatory.yml"))[0] 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 os.environ["PATH_TO_OBSCONF_FILE"] = obs_config_file_path 851 os.environ["PATH_TO_OBSCONF_FILE"] = obs_config_file_path
850 os.environ["PATH_TO_OBSCONF_FOLDER"] = path_to_obs_config_folder 852 os.environ["PATH_TO_OBSCONF_FOLDER"] = path_to_obs_config_folder
851 os.environ["unit_name"] = unit if unit else '' 853 os.environ["unit_name"] = unit if unit else ''
852 854
853 # add path to pyros_django folder as the config class is supposed to work within this folder 855 # add path to pyros_django folder as the config class is supposed to work within this folder
854 cmd_test_obs_config = f"-c \"from src.core.pyros_django.obs_config.obsconfig_class import OBSConfig\nOBSConfig('{obs_config_file_path}')\"" 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 # Observatory configuration has an issue 858 # Observatory configuration has an issue
857 exit(1) 859 exit(1)
858 else: 860 else:
@@ -861,12 +863,8 @@ def install_dependencies(observatory: str, unit: str, foreground: bool): @@ -861,12 +863,8 @@ def install_dependencies(observatory: str, unit: str, foreground: bool):
861 from git import Repo, GitError 863 from git import Repo, GitError
862 except: 864 except:
863 pip = "pip" if IS_WINDOWS else "pip3" 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 process.wait() 868 process.wait()
871 if process.returncode == 0: 869 if process.returncode == 0:
872 # self.addExecuted(self.current_command, command) 870 # self.addExecuted(self.current_command, command)