diff --git a/Pilot/pilotCommands.py b/Pilot/pilotCommands.py index f8d11c68..1474ff01 100644 --- a/Pilot/pilotCommands.py +++ b/Pilot/pilotCommands.py @@ -30,6 +30,7 @@ def __init__(self, pilotParams): import socket import filecmp import shutil +import platform from collections import Counter from distutils.version import LooseVersion @@ -256,11 +257,26 @@ def _locateInstallationScript(self): except OSError: pass - def _setupFromPreinstalledLocation(self): + def _getPreinstalledEnvScript(self): + """ Get preinstalled environment script if any """ + + arch = platform.system() + "-" + platform.machine() + preinstalledEnvScript = self.pp.preinstalledEnv + if not preinstalledEnvScript and self.pp.preinstalledEnvPrefix: + version = self.pp.releaseVersion or "pro" + preinstalledEnvScript = os.path.join(self.pp.preinstalledEnvPrefix, version, arch, "diracosrc") + + if os.path.isfile(preinstalledEnvScript): + self.pp.preinstalledEnv = preinstalledEnvScript + return preinstalledEnvScript + + return None + + def _setupFromPreinstalledLocation(self, preinstalledEnvScript): """ Set up a preinstalled DIRAC client""" - # setting up the client environment - retCode, output = self.executeAndGetOutput('bash -c "source %s && env"' % self.pp.preinstalledEnv, self.pp.installEnv) + retCode, output = self.executeAndGetOutput('bash -c "source %s && env"' % preinstalledEnvScript, + self.pp.installEnv) self.pp.installEnv = {} if retCode: self.log.error("Could not parse the diracos/diracosrc file [ERROR %d]" % retCode) @@ -420,8 +436,8 @@ def _installDIRACpy3(self): def execute(self): """What is called all the time""" - if self.pp.preinstalledEnv and os.path.exists(self.pp.preinstalledEnv): - self._setupFromPreinstalledLocation() + if preinstalledEnvScript := self._getPreinstalledEnvScript(): + self._setupFromPreinstalledLocation(preinstalledEnvScript) elif self.pp.pythonVersion == "27": self._setInstallOptions() self._locateInstallationScript() diff --git a/Pilot/pilotTools.py b/Pilot/pilotTools.py index e1343cc0..1fa37098 100644 --- a/Pilot/pilotTools.py +++ b/Pilot/pilotTools.py @@ -683,6 +683,7 @@ def __init__(self): # If DIRAC is preinstalled this file will receive the updates of the local configuration self.localConfigFile = "pilot.cfg" self.preinstalledEnv = "" + self.preinstalledEnvPrefix = "" self.executeCmd = False self.configureScript = "dirac-configure" self.architectureScript = "dirac-platform" @@ -758,7 +759,8 @@ def __init__(self): ("", "pythonVersion=", "Python version of DIRAC client to install"), ("", "defaultsURL=", "user-defined URL for global config"), ("", "pilotUUID=", "pilot UUID"), - ("", "preinstalledEnv=", "preinstalled pilot environment script location") + ("", "preinstalledEnv=", "preinstalled pilot environment script location"), + ("", "preinstalledEnvPrefix=", "preinstalled pilot environment area prefix"), ) # Possibly get Setup and JSON URL/filename from command line @@ -895,6 +897,8 @@ def __initCommandLine2(self): self.defaultsURL = v elif o == "--preinstalledEnv": self.preinstalledEnv = v + elif o == "--preinstalledEnvPrefix": + self.preinstalledEnvPrefix = v def __initJSON(self): """Retrieve pilot parameters from the content of json file. The file should be something like: