Пример #1
0
    def __init__(self,input):
        self.bintype = input['Architecture']
        self.comment = input['Comments']
        self.darname = input['DARFileName']
        self.status  = input['DARStatus'  ]
        self.release = input['Version'    ]
        self.project = input['Application']
        self.idNum  = input['DARFileID'  ]
        # URLs of files to be added to the users CWD:
        self.extra_url = []
        # Getting url of the external xml file from the comment:
        xml_url_pattern = re.compile('.*(http://.*\.xml).*')        
        res = xml_url_pattern.match(self.comment)
        if res:
            self.extra_url.append(res.group(1))
        # Support for both scram and scramv1: 
        # First  get scram  version for this release:
        majorV = getScramVersion(getReleaseTop(self.project, self.release))[:2]
        if majorV == "V0":
            self.scram = SCRAM('scram')
        elif majorV == "V1":
            self.scram = SCRAM('scramv1')
        else:
            sys.exit("ERROR! could not define scram executable for" + \
                     "scram version " + majorV)

        # Get current architecture.
        # Check to be added here:
        # - scram will create project area even if release is not available
        # for this platform 
        # - architecture should comply with the current system 
        # Get current architecture from scram 
        infoOut( 'scram architecture is '+ self.scram.getScramArch())
Пример #2
0
    def executeUse(self, cmd):
        """
        Request.executeUse
          Executes actions based on a user's input 'use' keyword
          Commands are given as:
            use <cmd> <argument> <input>
            where cmd can be:
              scram - get our DAR input from an existing SCRAM file
                        - if 'rte' is the argument given, we gather the runtime
                          environment from a given relative or absolute path
                        - if 'arch' is given as an argument, we use the
                          scram-defined bintype
              dar     - set some dar information
                        - if 'base' is the input argument, we check to see if
                          the input is an existing darball

                        - if 'file' is the argument given, then we use the given
                          file to get our input
                        - if 'tagname' is given, we set the version tag
                        - if 'projectname' is given, we set the project name                 
        """
        if cmd.args[0]   ==  "scram":
            if cmd.args[1]  ==  "rte":                
                # Get release location, information, etc
                if os.path.isabs(cmd.args[2]):
                    # One can specify top release directory with
                    # absolute path.
                    # Examples:
                    # use scram rte /afs/cern.ch/cms/Releases/ORCA/ORCA_8_4_0
                    # use scram rte /home/user/work/ORCA_8_4_0
                    location = cmd.args[2]
                else:
                    #Or it can be release name preceeded by a project name:
                    #      use scram rte ORCA ORCA_8_4_0
                    #In this case dar gets release top from the scram
                    #database:
                    location = getReleaseTop(cmd.args[2], cmd.args[3])
                if not os.path.isdir(location):
                    cmd.help()
                    message = "could not find release, check command syntax!"
                    raise InputError(cmd.line, message)
                # Choose scram executable name according to scram version used
                # in the project.

                majorVers = getScramVersion(location)[:-1]
                if majorVers[:2] == "V1":
                    self.scram = SCRAM("scramv1")
                elif majorVers[:2] == "V0":
                    self.scram = SCRAM("scram")
                else:
                    sys.exit("""ERROR! do not know how to define scram executable
 for scram version """ + majorVers)
                # Set attributes and additional dar input that scram can get
                # from this location:
                relMeta  =  getReleaseMetadata (location)
                self.setProjectName (getProjectName (relMeta))
                self.setVersionTag (getVersionTag (relMeta))
                self.setBaseReleaseName (getBaseReleaseName(relMeta))
                extraDarInput = self.scram.generateDarInput(location)
                # Process scram generated rte same way as variables
                # from darInput:
                for line in extraDarInput:
                    # process environment variables:
                    result  =  avariable.match(line)
                    if result:
                        vName, vValue  =  result.groups()
                        # discard surrounding whitespaces:
                        vName  =  string.strip(vName)
                        vValue  =  string.strip(vValue)
                        # Creates a variable object and puts into self.rteDict:
                        self.addVariable(vName, vValue)
                        continue
                    # process commands ( variables ignored by
                    # default in SCRAM2DAR):
                    extraCmd = DARcommand(line)
                    self.cmdList.append(extraCmd)
                    if extraCmd.name == "ignore":
                        self.executeIgnore(extraCmd)
                        continue
                    # Check if first command argument is existing variable name.
                    # Commands associated with environment variable
                    # will use corresponding variable method:
                    if self.rteDict.has_key(extraCmd.args[0]):
                        var = self.rteDict[extraCmd.args[0]]
                        self.executeVarCommand(extraCmd, var)
                        continue
                self.setArchitecture(self.scram.platf) # use scram-defined bintype
            if cmd.args[1]  ==  "arch":
                # TO DO: use extra argument to set non-default architecture, 
                # e.g. "use scram arch <some arch>".
                print "WARNING: Not implemented command: use scram arch"
                
        elif cmd.args[0]   ==  "dar":
            if cmd.args[1]   ==  "base": 
                # Command syntax :  use dar base <base dar ball>
                self.baseDar = cmd.args[2]
                # Do quick checks just  to  make sure baseDar could  be a dar;
                # return immediately if base distribution is not found:
                # It can be dar installation directory or a dar
                # distribution file:
                if os.path.isdir(self.baseDar):
                    infoOut('Use Base DAR installation from a directory:'+\
                             self.baseDar)
                elif os.path.isfile(self.baseDar):
                    infoOut('Use Base DAR distribution from file:'+\
                             self.baseDar)
                else:
                    # Lookup for base darball in the pool
                    infoOut('Base DAR is not a file or a directory: '+\
                             self.baseDar)
                    infoOut('Will be looked up later in the dar shared pool ')
            if cmd.args[1] == 'file':
                # Command syntax :  use dar file <darball path (or LFN?)>
                self.setDarFile(cmd.args[2])
            if cmd.args[1] == 'tagname':
                # Command syntax :  use dar tagname <version tag>
                # TODO: add a check that tag contains allowed characters only
                self.setVersionTag (cmd.args[2])
            elif cmd.args[1] == 'projectname':
                # Command syntax :  use dar projectname <project tag>
                # TODO: add a check that project name contains
                # allowed characters only
                self.setProjectName (cmd.args[2])
            if cmd.args[1]  ==  "arch":
                # use extra argument to set non-default architecture, 
                # e.g. "use scram arch <some arch>".
                infoOut('set Architecture to ' + cmd.args[2])
                self.setArchitecture(cmd.args[2])
        else:
            warning('unrecognized command syntax: ', cmd.line)