Commit b00bf90e authored by Maxime Hubert's avatar Maxime Hubert
Browse files

Merge remote-tracking branch 'origin/development'

parents eb26f205 8e35a65d
Pipeline #143825 passed with stage
in 29 seconds
......@@ -9,3 +9,6 @@
# Virtual environments
# Temporary environments
......@@ -9,6 +9,7 @@ import abc
import logging
import sys
from diva_evaluation_cli.bin.private_src.implementation.utils.actev_cli_environment import activate_environment
from diva_evaluation_cli.bin.private_src.implementation.resources_monitoring.monitor import Monitor
from diva_evaluation_cli.bin.private_src.implementation.status.status_factory import StatusFactory
......@@ -83,6 +84,10 @@ class ActevCommand():
try:"Starting %s" % self.command)
logging.debug('Loading environment')
StatusFactory.generate_status(self, 'start', args.__dict__)
......@@ -3,6 +3,9 @@
This file should not be modified.
import os
from diva_evaluation_cli.bin.private_src.implementation.utils.actev_cli_environment import init_environment, export_variable
from diva_evaluation_cli.bin.private_src.implementation.get_system.system_types_definition import system_types
def entry_point(url, system_type, location=None, user=None, password=None, token=None, install_cli=False, name=False):
......@@ -25,14 +28,36 @@ def entry_point(url, system_type, location=None, user=None, password=None, token
raise Exception("Unknown system type")
# Init the actev_cli_environemnt variables
# Add variables into the actev_cli_environemnt
export_variable('ACTEV_GET_SYSTEM_URL', url)
# Destination of the software
if not location:
location = "None"
if not user:
# Username
if user:
export_variable('ACTEV_GET_SYSTEM_USER', user)
user = "None"
if not password:
# Password
if password:
export_variable('ACTEV_GET_SYSTEM_PASSWORD', password)
password = "None"
if not token:
# Token
if token:
export_variable('ACTEV_GET_SYSTEM_TOKEN', token)
token = "None"
# Whether installing the CLI
if install_cli:
install_cli = "True"
"""Utils module
Can be used by any other module of the CLI
Implements functions to store a bash environment between commands
import logging, os
from dotenv import load_dotenv
ACTEV_CLI_ENVIRONMENT_FILEPATH=os.path.join(current_dir, 'actev_cli_environment.env')
def export_variable(name, value):
'''Increment the bash environment file with a key and a value
append_environment('export {}="{}";'.format(name, value))
def append_environment(content='', mode='w'):
'''Increment the bash environment file with some str content.
init_environment(content, mode='a')
def init_environment(content='', mode='w'):
'''Overwrite or create the bash environment file with some str content.
with open(ACTEV_CLI_ENVIRONMENT_FILEPATH, 'w') as env_file:
def activate_environment():
'''Loads the environment variables from ACTEV_CLI_ENVIRONMENT_FILEPATH
into the current environment.
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment