File indexing completed on 2026-04-11 08:41:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 from pilot.util.container import execute
0011 from pilot.common.errorcodes import ErrorCodes
0012 from ..setup import get_asetup, get_asetup_options
0013
0014 import logging
0015 logger = logging.getLogger(__name__)
0016
0017 errors = ErrorCodes()
0018
0019
0020 def verify_setup_command(cmd):
0021 """
0022 Verify the setup command.
0023
0024 :param cmd: command string to be verified (string).
0025 :return: pilot error code (int), diagnostics (string).
0026 """
0027
0028 ec = 0
0029 diagnostics = ""
0030
0031 exit_code, stdout, stderr = execute(cmd, timeout=5 * 60)
0032 if exit_code != 0:
0033 if "No release candidates found" in stdout:
0034 logger.info('exit_code=%d' % exit_code)
0035 logger.info('stdout=%s' % stdout)
0036 logger.info('stderr=%s' % stderr)
0037 ec = errors.NORELEASEFOUND
0038 diagnostics = stdout + stderr
0039
0040 return ec, diagnostics
0041
0042
0043 def get_setup_command(job, prepareasetup):
0044 """
0045 Return the path to asetup command, the asetup command itself and add the options (if desired).
0046 If prepareasetup is False, the function will only return the path to the asetup script. It is then assumed
0047 to be part of the job parameters.
0048
0049 :param job: job object.
0050 :param prepareasetup: should the pilot prepare the asetup command itself? boolean.
0051 :return:
0052 """
0053
0054
0055
0056
0057 if job.infosys.queuedata.is_cvmfs or not job.infosys.queuedata.container_type:
0058 logger.debug('return asetup path as normal since: is_cvmfs=%s, job.container_type=%s' %
0059 (job.infosys.queuedata.is_cvmfs, job.infosys.queuedata.container_type))
0060 else:
0061
0062 logger.debug('will not return asetup path since: is_cvmfs=%s, job.container_type=%s' %
0063 (job.infosys.queuedata.is_cvmfs, job.infosys.queuedata.container_type))
0064 return ""
0065
0066
0067
0068 if job.swrelease == 'NULL' or job.swrelease == '':
0069 logger.debug('will not return asetup path since there is no swrelease set')
0070 return ""
0071
0072
0073 cmd = get_asetup(asetup=prepareasetup)
0074
0075 if prepareasetup:
0076 options = get_asetup_options(job.swrelease, job.homepackage)
0077 asetupoptions = " " + options
0078 if job.platform:
0079 asetupoptions += " --platform " + job.platform
0080
0081
0082 asetupoptions += " --makeflags=\'$MAKEFLAGS\'"
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094 cmd += asetupoptions
0095
0096 return cmd