@@ -28,6 +28,7 @@ def __init__(self, pilotParams):
2828import sys
2929import time
3030import traceback
31+ import subprocess
3132from collections import Counter
3233
3334############################
@@ -870,6 +871,63 @@ def execute(self):
870871
871872 return localArchitecture
872873
874+ class ConfigureArchitectureWithoutCLI (CommandBase ):
875+ """This command determines the platform.
876+ Separated from the ConfigureDIRAC command for easier extensibility.
877+ """
878+ def getPlatformString (self ):
879+ # Modified to return our desired platform string, R. Graciani
880+ platformTuple = (platform .system (), platform .machine ())
881+ if platformTuple [0 ] == "Linux" :
882+ platformTuple += ("-" .join (platform .libc_ver ()),)
883+ elif platformTuple [0 ] == "Darwin" :
884+ platformTuple += ("." .join (platform .mac_ver ()[0 ].split ("." )[:2 ]),)
885+ else :
886+ platformTuple += platform .release ()
887+
888+ platformString = "%s_%s_%s" % platformTuple
889+
890+ return platformString
891+
892+ @logFinalizer
893+ def execute (self ):
894+ """This is a simple command to get the platform, and add it to the configuration
895+
896+ The architecture script, as well as its options can be replaced in a pilot extension
897+ """
898+
899+ try :
900+ localArchitecture = self .getPlatformString ()
901+ except Exception as e :
902+ self .log .error ("Configuration error [ERROR %s]" % str (e ))
903+ self .exitWithError (1 )
904+
905+
906+ cfg = ["-FDMH" ] # force update, skip CA checks, skip CA download, skip VOMS
907+ if self .pp .useServerCertificate :
908+ cfg .append ("--UseServerCertificate" )
909+ if self .pp .localConfigFile :
910+ cfg .append ("-O %s" % self .pp .localConfigFile ) # our target file for pilots
911+ cfg .extend (["--cfg" , self .pp .localConfigFile ]) # this file is also an input
912+ if self .pp .debugFlag :
913+ cfg .append ("-ddd" )
914+
915+ # real options added here
916+ localArchitecture = localArchitecture .strip ().split ("\n " )[- 1 ].strip ()
917+ cfg .append ('-S "%s"' % self .pp .setup )
918+ cfg .append ("-o /LocalSite/Architecture=%s" % localArchitecture )
919+
920+ # add the local platform as determined by the platform module
921+ cfg .append ("-o /LocalSite/Platform=%s" % platform .machine ())
922+
923+ configureCmd = "%s %s" % (self .pp .configureScript , " " .join (cfg ))
924+ retCode , _configureOutData = self .executeAndGetOutput (configureCmd , self .pp .installEnv )
925+ if retCode :
926+ self .log .error ("Configuration error [ERROR %d]" % retCode )
927+ self .exitWithError (retCode )
928+
929+ return localArchitecture
930+
873931
874932class ConfigureCPURequirements (CommandBase ):
875933 """This command determines the CPU requirements. Needs to be executed after ConfigureSite"""
0 commit comments