示例#1
0
    def execute(self, dataDict):
        """ Given a dictionary of resolved input data, this will creates a POOL XML slice.
    """
        poolXMLCatName = self.fileName
        try:
            poolXMLCat = PoolXMLCatalog()
            self.log.verbose('Creating POOL XML slice')

            for lfn, mdataList in dataDict.items():
                # lfn,pfn,se,guid tuple taken by POOL XML Catalogue
                if not isinstance(mdataList, list):
                    mdataList = [mdataList]
                # As a file may have several replicas, set first the file, then the replicas
                poolXMLCat.addFile(
                    (lfn, None, None, mdataList[0]['guid'], None))
                for mdata in mdataList:
                    path = ''
                    if 'path' in mdata:
                        path = mdata['path']
                    elif os.path.exists(os.path.basename(mdata['pfn'])):
                        path = os.path.abspath(os.path.basename(mdata['pfn']))
                    else:
                        path = mdata['turl']
                    poolXMLCat.addReplica((lfn, path, mdata['se'], False))

            xmlSlice = poolXMLCat.toXML()
            self.log.verbose('POOL XML Slice is: ')
            self.log.verbose(xmlSlice)
            with open(poolXMLCatName, 'w') as poolSlice:
                poolSlice.write(xmlSlice)
            self.log.info('POOL XML Catalogue slice written to %s' %
                          (poolXMLCatName))
            try:
                # Temporary solution to the problem of storing the SE in the Pool XML slice
                poolSlice_temp = open('%s.temp' % (poolXMLCatName), 'w')
                xmlSlice = poolXMLCat.toXML(True)
                poolSlice_temp.write(xmlSlice)
                poolSlice_temp.close()
            except Exception as x:
                self.log.warn(
                    'Attempted to write catalog also to %s.temp but this failed'
                    % (poolXMLCatName))
        except Exception as x:
            self.log.error(str(x))
            return S_ERROR('Exception during construction of POOL XML slice')

        return S_OK('POOL XML Slice created')
示例#2
0
    def execute(self, dataDict):
        """Given a dictionary of resolved input data, this will creates a POOL XML slice."""
        poolXMLCatName = self.fileName
        try:
            poolXMLCat = PoolXMLCatalog()
            self.log.verbose("Creating POOL XML slice")

            for lfn, mdataList in dataDict.items():
                # lfn,pfn,se,guid tuple taken by POOL XML Catalogue
                if not isinstance(mdataList, list):
                    mdataList = [mdataList]
                # As a file may have several replicas, set first the file, then the replicas
                poolXMLCat.addFile(
                    (lfn, None, None, mdataList[0]["guid"], None))
                for mdata in mdataList:
                    path = ""
                    if "path" in mdata:
                        path = mdata["path"]
                    elif os.path.exists(os.path.basename(mdata["pfn"])):
                        path = os.path.abspath(os.path.basename(mdata["pfn"]))
                    else:
                        path = mdata["turl"]
                    poolXMLCat.addReplica((lfn, path, mdata["se"], False))

            xmlSlice = poolXMLCat.toXML()
            self.log.verbose("POOL XML Slice is: ")
            self.log.verbose(xmlSlice)
            with open(poolXMLCatName, "w") as poolSlice:
                poolSlice.write(xmlSlice)
            self.log.info("POOL XML Catalogue slice written to %s" %
                          (poolXMLCatName))
            try:
                # Temporary solution to the problem of storing the SE in the Pool XML slice
                with open("%s.temp" % (poolXMLCatName), "w") as poolSlice_temp:
                    xmlSlice = poolXMLCat.toXML(True)
                    poolSlice_temp.write(xmlSlice)
            except Exception as x:
                self.log.warn(
                    "Attempted to write catalog also to %s.temp but this failed"
                    % (poolXMLCatName))
        except Exception as x:
            self.log.error(str(x))
            return S_ERROR("Exception during construction of POOL XML slice")

        return S_OK("POOL XML Slice created")
示例#3
0
  def execute( self, dataDict ):
    """ Given a dictionary of resolved input data, this will creates a POOL XML slice.
    """
    poolXMLCatName = self.fileName
    try:
      poolXMLCat = PoolXMLCatalog()
      self.log.verbose( 'Creating POOL XML slice' )

      for lfn, mdataList in dataDict.items():
        # lfn,pfn,se,guid tuple taken by POOL XML Catalogue
        if type( mdataList ) != types.ListType:
          mdataList = [mdataList]
        # As a file may have several replicas, set first the file, then the replicas
        poolXMLCat.addFile( ( lfn, None, None, mdataList[0]['guid'], None ) )
        for mdata in mdataList:
          path = ''
          if 'path' in mdata:
            path = mdata['path']
          elif os.path.exists( os.path.basename( mdata['pfn'] ) ):
            path = os.path.abspath( os.path.basename( mdata['pfn'] ) )
          else:
            path = mdata['turl']
          poolXMLCat.addReplica( ( lfn, path, mdata['se'], False ) )

      xmlSlice = poolXMLCat.toXML()
      self.log.verbose( 'POOL XML Slice is: ' )
      self.log.verbose( xmlSlice )
      with open( poolXMLCatName, 'w' ) as poolSlice:
        poolSlice.write( xmlSlice )
      self.log.info( 'POOL XML Catalogue slice written to %s' % ( poolXMLCatName ) )
      try:
        # Temporary solution to the problem of storing the SE in the Pool XML slice
        poolSlice_temp = open( '%s.temp' % ( poolXMLCatName ), 'w' )
        xmlSlice = poolXMLCat.toXML( True )
        poolSlice_temp.write( xmlSlice )
        poolSlice_temp.close()
      except Exception as x:
        self.log.warn( 'Attempted to write catalog also to %s.temp but this failed' % ( poolXMLCatName ) )
    except Exception as x:
      self.log.error( str( x ) )
      return S_ERROR( 'Exception during construction of POOL XML slice' )

    return S_OK( 'POOL XML Slice created' )
示例#4
0
    def execute(self, dataDict):
        """ Given a dictionary of resolved input data, this will creates a POOL XML slice.
    """
        poolXMLCatName = self.fileName
        mdata = dataDict
        try:
            poolXMLCat = PoolXMLCatalog()
            self.log.verbose('Creating POOL XML slice')

            for lfn, mdata in dataDict.items():
                # lfn,pfn,se,guid tuple taken by POOL XML Catalogue
                if mdata.has_key('path'):
                    poolXMLCat.addFile((lfn, mdata['path'], mdata['se'],
                                        mdata['guid'], mdata['pfntype']))
                elif os.path.exists(os.path.basename(mdata['pfn'])):
                    poolXMLCat.addFile(
                        (lfn, os.path.abspath(os.path.basename(mdata['pfn'])),
                         mdata['se'], mdata['guid'], mdata['pfntype']))
                else:
                    poolXMLCat.addFile((lfn, mdata['turl'], mdata['se'],
                                        mdata['guid'], mdata['pfntype']))

            xmlSlice = poolXMLCat.toXML()
            self.log.verbose('POOL XML Slice is: ')
            self.log.verbose(xmlSlice)
            poolSlice = open(poolXMLCatName, 'w')
            poolSlice.write(xmlSlice)
            poolSlice.close()
            self.log.info('POOL XML Catalogue slice written to %s' %
                          (poolXMLCatName))
            try:
                # Temporary solution to the problem of storing the SE in the Pool XML slice
                poolSlice_temp = open('%s.temp' % (poolXMLCatName), 'w')
                xmlSlice = poolXMLCat.toXML(True)
                poolSlice_temp.write(xmlSlice)
                poolSlice_temp.close()
            except Exception, x:
                self.log.warn(
                    'Attempted to write catalog also to %s.temp but this failed'
                    % (poolXMLCatName))
        except Exception, x:
            self.log.error(str(x))
            return S_ERROR('Exception during construction of POOL XML slice')
示例#5
0
  def execute(self,dataDict):
    """Given a dictionary of resolved input data, this will create a POOL
       XML slice.
    """
    poolXMLCatName = self.fileName
    mdata = dataDict
    try:
      poolXMLCat = PoolXMLCatalog()
      self.log.verbose('Creating POOL XML slice')

      for lfn,mdata in dataDict.items():
        #lfn,pfn,size,se,guid tuple taken by POOL XML Catalogue
        if mdata.has_key('path'):
          poolXMLCat.addFile((lfn,mdata['path'],0,mdata['se'],mdata['guid'],mdata['pfntype']))
        elif os.path.exists(os.path.basename(mdata['pfn'])):
          poolXMLCat.addFile((lfn,os.path.abspath(os.path.basename(mdata['pfn'])),0,mdata['se'],mdata['guid'],mdata['pfntype']))
        else:
          poolXMLCat.addFile((lfn,mdata['turl'],0,mdata['se'],mdata['guid'],mdata['pfntype']))

      xmlSlice = poolXMLCat.toXML()
      self.log.verbose('POOL XML Slice is: ')
      self.log.verbose(xmlSlice)
      poolSlice = open(poolXMLCatName,'w')
      poolSlice.write(xmlSlice)
      poolSlice.close()
      self.log.info('POOL XML Catalogue slice written to %s' %(poolXMLCatName))
      try:
        # Temporary solution to the problem of storing the SE in the Pool XML slice
        poolSlice_temp = open('%s.temp' %(poolXMLCatName),'w')
        xmlSlice = poolXMLCat.toXML(True)
        poolSlice_temp.write(xmlSlice)
        poolSlice_temp.close()
      except Exception,x:
        self.log.warn('Attempted to write catalog also to %s.temp but this failed' %(poolXMLCatName))  
    except Exception,x:
      self.log.error(str(x))
      return S_ERROR('Exception during construction of POOL XML slice')