File indexing completed on 2026-04-11 08:41:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 import os
0011
0012
0013 from pilot.common.errorcodes import ErrorCodes
0014
0015 import logging
0016 logger = logging.getLogger(__name__)
0017
0018 errors = ErrorCodes()
0019
0020
0021 def verify_setup_command(cmd):
0022 """
0023 Verify the setup command.
0024
0025 :param cmd: command string to be verified (string).
0026 :return: pilot error code (int), diagnostics (string).
0027 """
0028
0029 ec = 0
0030 diagnostics = ""
0031
0032 return ec, diagnostics
0033
0034
0035 def get_setup_command(job, prepareasetup):
0036 """
0037 Return the path to asetup command, the asetup command itself and add the options (if desired).
0038 If prepareasetup is False, the function will only return the path to the asetup script. It is then assumed
0039 to be part of the job parameters.
0040
0041 Handle the case where environmental variables are set -
0042 HARVESTER_CONTAINER_RELEASE_SETUP_FILE, HARVESTER_LD_LIBRARY_PATH, HARVESTER_PYTHONPATH
0043 This will create the string need for the pilot to execute to setup the environment.
0044
0045 :param job: job object.
0046 :param prepareasetup: not used.
0047 :return: setup command (string).
0048 """
0049
0050 cmd = ""
0051
0052
0053 if job.swrelease == 'NULL' or '--containerImage' in job.jobparams:
0054 logger.debug('get_setup_command return value: {0}'.format(str(cmd)))
0055 return cmd
0056
0057
0058 setupfile = os.environ.get('HARVESTER_CONTAINER_RELEASE_SETUP_FILE', '')
0059 if setupfile != "":
0060 cmd = "source {};".format(setupfile)
0061
0062 if os.environ.get('HARVESTER_LD_LIBRARY_PATH', '') != "":
0063 cmd += "export LD_LIBRARY_PATH=$HARVESTER_LD_LIBRARY_PATH:$LD_LIBRARY_PATH;"
0064
0065 if os.environ.get('HARVESTER_PYTHONPATH', '') != "":
0066 cmd += "export PYTHONPATH=$HARVESTER_PYTHONPATH:$PYTHONPATH;"
0067
0068 cmd += "unset FRONTIER_SERVER"
0069
0070 logger.debug('get_setup_command return value: {0}'.format(str(cmd)))
0071
0072 return cmd