Ejemplo n.º 1
0
 def prepareRegexp(self, key, value=None, opt='i'):
     """ prepare the regexp 'value' pattern to look up the 'key' Db column 
      ','   -> ')|('
      '%'   -> '*'
      '*'   -> '.*'
      '.'   -> '\.'
      '$$)' -> '$)'
   """
     if value != None:
         if not isinstance(value, str):
             raise ValueError(
                 " Non string  pattern %s to look up the %s column is not acceptable"
                 % (value, key))
         if pmUtils.isFilled(value) and not self.is_all(value):
             vars = self._vars
             where = self._where
             endclause = ''
             if not ',' in value:
                 endclause = '$'
             v = '(%s%s)' % (value.replace(
                 ',', ')|(').replace('.', '\\.').replace('%', '*').replace(
                     '*', '.*'), endclause)
             # clean up
             v = v.replace('$$)', '$)').replace('|()',
                                                '').replace('()|', '')
             qvar = self.varName(key)
             vars[qvar] = v
             where.append("REGEXP_LIKE (%(key)s,%(value)s,'%(opt)s') " % {
                 'key': key,
                 'value': qvar,
                 'opt': opt
             })
     return self
Ejemplo n.º 2
0
 def getSiteDDM(self, job,sites,nicks):
    """ Get DDM for  site from schedconfig for logfiles """
    def getDDM(site):
       siteDDM=None
       if site != None:
          siteDDM = sites.get(site)
          if siteDDM != None:
             siteDDM =siteDDM['ddm']
          if siteDDM == None:
             siteDDM = nicks.get(site)
             if siteDDM != None: siteDDM =siteDDM['ddm']   
          if siteDDM == None:
             for nick in nicks:
                if nick.startswith(site): 
                   siteDDM = nicks[nick].get('ddm')
                   break                
       return siteDDM
        
    ddmse  =  job.get('ddm')
    if not utils.isFilled(ddmse):
       computingElement =  job.get('computingElement')
       computingSite    =  job.get('computingSite')
       pilotID          =  job.get('pilotID')
       if computingSite != None and utils.isValid(pilotID) and pilotID.startswith('tp_') \
               and computingElement != None and computingElement.find('.') < 0:
            ddmse = getDDM(computingElement)
       else:
            ddmse = getDDM(computingSite)
       if sites.has_key(ddmse) and sites[ddmse].has_key('dq2Site'): \
            ddmse = sites[ddmse]['dq2Site']
    job['ddmse'] =  ddmse
    return job
Ejemplo n.º 3
0
 def cleanUserID(cls, dnid):
      """ Extract name from DN """
      if not utils.isFilled(dnid): return ""
      up = re.compile('/(DC|O|OU|C|L)=[^\/]+')
      username = up.sub('', dnid)
      up2 = re.compile('/CN=[0-9]+')
      username = up2.sub('', username)
      up3 = re.compile(' [0-9]+')
      username = up3.sub('', username)
      up4 = re.compile('_[0-9]+')
      username = up4.sub('', username)
      username = username.replace('/CN=proxy','')
      username = username.replace('/CN=limited proxy','')
      username = username.replace('limited proxy','')
      pat = re.compile('.*/CN=([^\/]+)/CN=([^\/]+)')
      mat = pat.match(username)
      if mat:
          username = mat.group(2)
          if 'Robot:' in username: username = mat.group(1)
      else:
          username = username.replace('/CN=','')
      if username.lower().find('/email') > 0: username = username[:username.lower().find('/email')]
      pat = re.compile('.*(limited.*proxy).*')
      mat = pat.match(username)
      if mat: username = mat.group(1)
      username = username.replace('(','')
      username = username.replace(')','')
      username = username.replace("'","")
      return username   
Ejemplo n.º 4
0
 def getSpaceToken(destToken, ddm, setoken):
     # print 'destToken', destToken
     spaceToken = '?'
     if utils.isFilled(destToken):
         tokenName = destToken
         ddmList = ddm.split(',')
         if utils.isFilled(setoken):
             setokenList = setoken.split(',')
         else:
             setokenList = []
         # print 'ddmList', ddmList
         # print 'setokenList', setokenList
         i=0
         for d in setokenList:
             if d == tokenName:
                 spaceToken = ddmList[i]
                 break
             i += 1
     else:
         spaceToken = ddm.split(',')[0]
     # print 'spaceToken', spaceToken
     return spaceToken
Ejemplo n.º 5
0
 def jobDq2Site(self,job,sites,nicks):
    siterow = job.get('computingSite')
    if job['jobStatus'] in ('finished','failed', 'canceled'):
       siterow = 'destinationSE'
    dqsite =  job.get(siterow);
    siteInfo = sites.get(dqsite)
    ddm = None
    tokens = None
    if siteInfo != None: 
       ddm = siteInfo.get('ddm')
       tokens = siteInfo.get('setokens')
       job['ddm'] = ddm
       job['setokens'] = tokens
       linksite = ddm
    if not utils.isFilled(ddm):
       linksite = job.get('computingSite');
       destSite =  job.get('destinationSE')
       if utils.isFilled(destSite): linksite = destSite
       if sites.has_key(linksite) and sites[linksite].has_key('dq2Site'):
          linksite = sites[linksite]['dq2Site']
    job['ddm']    = ddm   
    job['ddmsite']= linksite
    self.getSiteDDM(job,sites,nicks)
    return job
Ejemplo n.º 6
0
 def prepareRegexp(self,key,value=None,opt ='i'):
    """ prepare the regexp 'value' pattern to look up the 'key' Db column 
       ','   -> ')|('
       '%'   -> '*'
       '*'   -> '.*'
       '.'   -> '\.'
       '$$)' -> '$)'
    """
    if value != None: 
       if not isinstance(value,str):
          raise ValueError(" Non string  pattern %s to look up the %s column is not acceptable" %(value,key))
       if pmUtils.isFilled(value) and not self.is_all(value):
          vars  = self._vars
          where = self._where
          endclause =  ''
          if not ',' in value:
             endclause =  '$'
          v = '(%s%s)' % (value.replace(',',')|(').replace('.','\\.').replace('%','*').replace('*','.*'),endclause)
          # clean up
          v = v.replace('$$)','$)').replace('|()','').replace('()|','')
          qvar = self.varName(key)
          vars[qvar] = v
          where.append("REGEXP_LIKE (%(key)s,%(value)s,'%(opt)s') " % {'key': key ,'value': qvar,'opt':opt } )
    return self