コード例 #1
0
def getProperties( id, algname='',property='',cas = ConfigAccessSvc() ) :
    retlist= dict()
    tree = getConfigTree( id, cas )
    import re
    if algname :
        reqNode = re.compile(algname)
        matchNode = lambda x : reqNode.match(x.leaf.fullyQualifiedName)
    else :
        matchNode = None
    if property :
        reqProp = re.compile(property)
        matchProp = lambda x : reqProp.match(x)
    else :
        matchProp = None
    # generate a unique ID for this traversal, so that we do not
    # repeat leafs...
    import uuid
    sig = uuid.uuid4().hex
    for i in tree :
       if not i.leaf or (matchNode and not matchNode(i)) : continue
       if hasattr(i.leaf,sig) : continue
       setattr(i.leaf,sig,True)
       pdict = dict()
       for (k,v) in i.leaf.properties().iteritems() :
          if matchProp and not matchProp(k) : continue
          pdict[k] = v
       if pdict : retlist[  i.leaf.name ] = pdict
    return retlist
コード例 #2
0
def xget( ids , cas = ConfigAccessSvc() ) :
    if 'forest' not in dir(xget) : xget.forest = dict()
    fetch = [ id for id in ids if id not in xget.forest.keys() ]
    if fetch :
        for t in fetch : xget.forest[t] = getConfigTree(t).leafs()
    forest = dict()
    for id in ids : forest[id] = xget.forest[id]
    return forest
コード例 #3
0
def getAlgorithms( id, cas = ConfigAccessSvc() ) :
    tree =  getConfigTree( id, cas )
    tempstr = ''
    for i in tree :
       if i.leaf and i.leaf.kind =='IAlgorithm':
          s =  i.depth*3*' ' + i.leaf.name
          tempstr = tempstr + s + (80-len(s))*' ' + str(i.leaf.digest) + '\n'
    return tempstr
コード例 #4
0
def getTCKs( release = None, hlttype = None, cas = ConfigAccessSvc() ) :
    info = getConfigurations( cas )
    pred = lambda x : x['TCK'] and ( not release or x['release'] == release ) and ( not hlttype or x['hlttype'] == hlttype )
    result = []
    for i in [ x for x in info.itervalues() if pred(x) ]:
            for tck in i['TCK'] :
                result.append( ('0x%08x'%tck,i['label'])  )
    return result
コード例 #5
0
def copy( source = ConfigAccessSvc() , target = ConfigDBAccessSvc(ReadOnly=False), glob = None ) :
    if source == target :
        print 'WARNING: source and target are the same -- no-op ...'
        return
    r = AccessProxy().access( cas = ConfigStackAccessSvc( ConfigAccessSvcs = [ target.getFullName(), source.getFullName() ]
                                                        , OutputLevel=DEBUG )
                            ).rcopy(glob)
    AccessProxy().flush()
    return r
コード例 #6
0
def xget(ids, cas=ConfigAccessSvc()):
    if 'forest' not in dir(xget): xget.forest = dict()
    fetch = [id for id in ids if id not in xget.forest.keys()]
    if fetch:
        xget.forest.update(execInSandbox(_xget, fetch, cas))
    forest = dict()
    for id in ids:
        forest[id] = xget.forest[id]
    return forest
コード例 #7
0
def dumpL0( id, cas  = ConfigAccessSvc() ) :
    tree  =  getConfigTree( id, cas )
    l0s   = [ i for i in tree if i.leaf and i.leaf.type == 'L0DUConfigProvider' ]
    for i in l0s :
        print '%s TCK = %s %s' % ( 20*'*',i.leaf.props['TCK'],20 *'*' )
        print '%s Channels %s' % ( 20*'*',20 *'*' )
        pprint( _parseL0settings( eval(i.leaf.props['Channels']) ) )
        print '%s Conditions %s' % ( 19*'*',19 *'*' )
        pprint( _parseL0settings( eval(i.leaf.props['Conditions']) ) )
        print 100*'*'
コード例 #8
0
def getRoutingBits( id , cas = ConfigAccessSvc() ) :
    # should be a map... so we try to 'eval' it
    rbs = {}
    for stage in ('Hlt1', 'Hlt2', 'Hlt'):
        for p in ['RoutingBits','routingBitDefinitions'] :
            try :
                prop = getProperty(id, '%sRoutingBitsWriter' % stage, p, cas)
            except KeyError :
                continue
            rbs.update(eval(prop))
    return rbs if rbs else None
コード例 #9
0
def getL0Prescales( id, cas  = ConfigAccessSvc() ) :
    tree  =  getConfigTree( id, cas )
    l0s   = [ i for i in tree if i.leaf and i.leaf.type == 'L0DUConfigProvider' ]
    ret = dict()
    for i in l0s :
        l0tck = i.leaf.props['TCK' ]
        ret[ l0tck ]  = dict()
        settings = _parseL0settings( eval(i.leaf.props['Channels']) )
        for chan in settings.itervalues() :
            ret[ l0tck ][ chan['name'] ] = chan['rate']
    return ret
コード例 #10
0
def getConfigTree(id, cas = ConfigAccessSvc()):
    if 'forest' not in dir(getConfigTree) : getConfigTree.forest = dict()
    if id not in getConfigTree.forest :
        tree = AccessProxy().access(cas).rgetConfigTree( id )
        getConfigTree.forest[id] = tree
        if tree.digest != id :
            # in case we got a TCK, the remote side resolves this to an ID
            # and we mark this ID in our cache. Unfortunately, it doesn't work
            # the other way around (i.e. we first get an ID, then a TCK )
            # and we must rely on the remote to cache as much as possible...
            getConfigTree.forest[tree.digest] = tree
    return getConfigTree.forest[id]
コード例 #11
0
 def __init__(self,create=False,createConfigTreeEditor=False,cas=ConfigAccessSvc()) :
      if create :
         if (AccessSvcSingleton.__pcs or AccessSvcSingleton.__cas) :
                raise LogicError('re-entry of singleton creation')
         pcs = PropertyConfigSvc( ConfigAccessSvc = cas.getFullName() )
         cte = ConfigTreeEditor( PropertyConfigSvc = pcs.getFullName()
                               , ConfigAccessSvc   = cas.getFullName() )
         AccessSvcSingleton.__app = _appMgr()
         self._app().createSvc(cas.getFullName())
         AccessSvcSingleton.__cas = self._app().service(cas.getFullName(),'IConfigAccessSvc')
         self._app().createSvc(pcs.getFullName())
         AccessSvcSingleton.__pcs = self._app().service(pcs.getFullName(),'IPropertyConfigSvc')
         AccessSvcSingleton.__cte = lambda x : self._app().toolsvc().create(cte.getFullName(),interface='IConfigTreeEditor')
コード例 #12
0
def updateL0TCK(id, l0tck, label='', cas = ConfigAccessSvc(), extra = None ) :
    if not label :
        print 'please provide a reasonable label for the new configuration'
        return None
    l0tck = '0x%04X'%_tck(l0tck)
    importOptions('$L0TCK/L0DUConfig.opts')
    from Configurables import L0DUMultiConfigProvider,L0DUConfigProvider
    if l0tck not in L0DUMultiConfigProvider('L0DUConfig').registerTCK :
             raise KeyError('requested L0 TCK %s is not known to TCK/L0TCK'%l0tck)
    configProvider = L0DUConfigProvider('ToolSvc.L0DUConfig.TCK_%s'%l0tck)
    l0config = configProvider.getValuedProperties()
    l0config['TCK'] = l0tck
    ret = AccessProxy().access(cas).rupdateL0TCK(id,l0config,label,extra)
    if ret : AccessProxy().flush()
    return ret
コード例 #13
0
def diff( lhs, rhs , cas = ConfigAccessSvc() ) :
    table = xget( [ lhs, rhs ] , cas )
    setl = set( table[lhs].keys() )
    setr = set( table[rhs].keys() )
    onlyInLhs = setl - setr
    if len(onlyInLhs)>0 :
        print 'only in %s: ' % lhs
        for i in onlyInLhs : print '   ' + i
    onlyInRhs = setr - setl
    if len(onlyInRhs)>0 :
        print 'only in %s:'  % rhs
        for i in onlyInRhs : print '   ' + i
    for i in setl & setr :
        (l,r) = ( table[lhs][i], table[rhs][i] )
        if l.digest != r.digest :
            from difflib import unified_diff
            print ''.join( unified_diff(l.fmt(), r.fmt(),
                                        l.fqn(), r.fqn(),
                                        lhs, rhs, n=0) )
コード例 #14
0
def listRoutingBits( id, cas = ConfigAccessSvc() ) :
    pprint(getRoutingBits(id,cas))
コード例 #15
0
def listTCKs( release, hlttype, cas = ConfigAccessSvc() ) :
    return printTCKs( getTCKs(release,hlttype) )
コード例 #16
0
def listHltTypes( release, cas = ConfigAccessSvc() ) :
    return printHltTypes( getHltTypes(release) )
コード例 #17
0
def listReleases( cas = ConfigAccessSvc() ) :
    return printReleases( getReleases() )
コード例 #18
0
def listConfigurations( cas = ConfigAccessSvc() ) :
    return printConfigurations( getConfigurations(cas) )
コード例 #19
0
def getConfigurations( cas = ConfigAccessSvc() ) :
    return AccessProxy().access(cas).rgetConfigurations()
コード例 #20
0
def getHltTypes( release, cas = ConfigAccessSvc() ) :
    info = getConfigurations( cas )
    return set( [ i['hlttype']  for i in info.itervalues() if i['release']==release ] )
コード例 #21
0
def getHltLines( id , cas = ConfigAccessSvc() ) :
    return getHlt1Lines(id,cas) + getHlt2Lines(id,cas)
コード例 #22
0
def getHlt2Lines( id , cas = ConfigAccessSvc() ) :
    # should be a list... so we try to 'eval' it
    return eval(getProperty(id,'Hlt2','Members',cas))
コード例 #23
0
def dump( id, properties = None,  lines = None, file = None, cas = ConfigAccessSvc() ) :
    if not properties :
        properties = [ 'RoutingBits', 'AcceptFraction', 'FilterDescriptor'
                     , 'Preambulo', 'Code', 'InputLocations','Input','Inputs'
                     , 'DaughtersCuts', 'CombinationCut', 'MotherCut', 'DecayDescriptor'
                     , 'OutputSelection', 'Output' ]
    tree =  getConfigTree( id, cas )
    def len1(line):
        _i = line.rfind('\n')
        return len(line) if _i<0 else len(line)-(_i+1)

    def prettyPrintStreamer(code) :
        code.translate(None,'\n')
        return ('\n' + (_tab+25+18)*' ' + '>> ' ).join( [ i.strip() for i in code.split('>>') ] )

    def prettyPrintDict(code,trItem) :
        try :
            cuts = eval(code) # should be a dict
            return "{ "+ ('\n' + (_tab+25+18)*' ' + ', ' ).join(  [ trItem(k,v) for (k,v) in cuts.iteritems() ] ) + '\n'+(_tab+25+18)*' '+"}"
        except :
            return code

    def prettyPrintList(code,trItem = None, skipEmpty = True) :
        try :
            l = eval(code)
            if skipEmpty and not l : return ''
            if len(l)<2 : return code
            if trItem :
                l = [ trItem(i) for i in l ]
            return "[ "+('\n' + (_tab+25+18)*' ' + ', ' ).join( l )+'\n'+(_tab+25+18)*' '+']'
        except :
            return code

    trtable = { 'Code' : prettyPrintStreamer
              , 'DaughtersCuts' : lambda x : prettyPrintDict(x, lambda k,v : "'%s' : '%s'"%(k,v) )
              , 'Inputs' : prettyPrintList
              , 'InputLocations' : prettyPrintList
              , 'Preambulo' : prettyPrintList
              , 'FilterDescriptor' : lambda x : prettyPrintList(x,lambda y : "'%s'"%y, True)
              , 'RoutingBits' : lambda x : prettyPrintDict(x, lambda k,v : "%2d : \"%s\""%(k,v) )
              }

    import re
    show = not lines
    from sys import stdout
    file = open(file,'w') if file else sys.stdout
    for i in tree :
       if not i.leaf or i.leaf.kind != 'IAlgorithm' : continue
       if lines and i.leaf.type in [ 'Hlt::Line', 'HltLine' ] :
           show =  re.match(lines,i.leaf.name)
       if not show : continue
       _tab = 50
       line =  i.depth * '   ' + i.leaf.name
       if len1(line)>( _tab-1): line +=  '\n'+ _tab*' '
       else :                   line +=  (_tab-len1(line))*' '
       line +=  '%-25.25s'%i.leaf.type
       for k,v in [ (k,v) for k,v in i.leaf.props.iteritems() if k in properties and v ]:
           if _tab+25 < len1(line) : line+= '\n'+(_tab+25)*' '
           if k in trtable.keys() : v = trtable[k](v)
           if v : line += '%-15s : %s' % ( k, v)
       file.write(line+'\n')
コード例 #24
0
def updateProperties(id,updates,label='', cas = ConfigAccessSvc() ) :
    ret = AccessProxy().access(cas).rupdateProperties( id,updates,label )
    if ret : AccessProxy().flush() # explicit flush in case we wrote something
    return ret
コード例 #25
0
def listHlt2Lines( id, cas = ConfigAccessSvc() ) :
    pprint(getHlt2Lines(id,cas))
コード例 #26
0
def getHlt1Decisions( id , cas = ConfigAccessSvc() ) :
    table = xget( [ id ], cas )[id]
    lines = eval(_lookupProperty(table,'Hlt1','Members'))
    return [ _lookupProperty(table,i.split('/')[-1],'DecisionName') for i in lines ]
コード例 #27
0
def listHlt1Decisions( id, cas = ConfigAccessSvc() ) :
    pprint(getHlt1Decisions(id,cas))
コード例 #28
0
def getTCKList( cas = ConfigAccessSvc() ) :
    info = getConfigurations( cas )
    result = []
    for i in info.itervalues() :
            for tck in i['TCK'] : result.append( '0x%08x'%tck  )
    return result
コード例 #29
0
def createTCKEntries(d, cas = ConfigAccessSvc() ) :
    ret = AccessProxy().access(cas).rcreateTCKEntries(d)
    AccessProxy().flush()
    return ret
コード例 #30
0
def resolveTCK( tck, cas=ConfigAccessSvc()) :
    return AccessProxy().access(cas).rresolveTCK( tck )