Commit 475f4765d3ba4e592a317cff3c194b850df667bf

Authored by Alexis Koralewski
1 parent ee9b76c1
Exists in dev

Fixing assignation of environment variables, add obsconfig app in tests, instant…

…iate obs config class in the virtual environment
Showing 1 changed file with 8 additions and 5 deletions   Show diff stats
pyros.py
... ... @@ -12,7 +12,7 @@ import subprocess
12 12 import sys
13 13 import time
14 14 import re
15   -from src.core.pyros_django.obsconfig.configpyros import ConfigPyros
  15 +
16 16  
17 17  
18 18  
... ... @@ -322,9 +322,9 @@ def set_environment_variables_if_not_configured(env_path: str,env_sample_path: s
322 322 line = line.rstrip()
323 323 key,value = line.split("=")
324 324 # setting variables as environment variables
325   - if os.environ[key] != value:
  325 + if WITH_DOCKER and os.environ[key] != value:
326 326 print(f"WARNING: Environment value for '{key}' needs to be uptaded (To remove this message : restart docker container to update them). PyROS will take the value from '{env_path}'")
327   - os.environ[key] = value
  327 + os.environ[key] = value
328 328 except:
329 329 print(f".env not found at {env_path} or is empty, creating a file at this path from the .env-sample file stored at {ENV_SAMPLE_PATH}\nvalues from .env-sample will be used as environment variables")
330 330 with open(env_sample_path,'r') as env_sample_file:
... ... @@ -511,7 +511,7 @@ def install_or_update(UPDATE:bool=False, packages_only:bool=False, database_only
511 511 def test():
512 512 print("Running tests")
513 513 #start_dir = os.getcwd()
514   - apps = ['common', 'scheduler', 'routine_manager', 'user_manager', 'alert_manager.tests.TestStrategyChange']
  514 + apps = ['obsconfig','common', 'scheduler', 'routine_manager', 'user_manager', 'alert_manager.tests.TestStrategyChange']
515 515 for app in apps:
516 516 _loaddata() or die()
517 517 change_dir(PYROS_DJANGO_BASE_DIR)
... ... @@ -608,7 +608,10 @@ def start(agent:str, configfile:str):
608 608 #if test_mode(): print("in test mode")
609 609 #if verbose_mode(): print("in verbose mode")
610 610 # add path to pyros_django folder as the config class is supposed to work within this folder
611   - ConfigPyros(PYROS_DJANGO_BASE_DIR+"/"+os.environ.get("PATH_TO_OBSCONF_FILE"))
  611 + cmd_test_obs_config = f"-c \"from src.core.pyros_django.obsconfig.configpyros import ConfigPyros\nConfigPyros('{os.path.join(PYROS_DJANGO_BASE_DIR,os.environ.get('PATH_TO_OBSCONF_FILE'))}')\""
  612 + if not execProcessFromVenv(cmd_test_obs_config):
  613 + # Observatory configuration has an issue
  614 + exit(1)
612 615 # Check each agent in the given list
613 616 agents = agent.split(",") if "," in agent else [agent]
614 617 for a in agents:
... ...