def dump(id, properties=None, lines=None, cas=defaultCas): if not properties: properties = [ 'RoutingBits', 'AcceptFraction', 'FilterDescriptor', 'Code', 'InputLocations', 'DaughtersCuts', 'CombinationCut', 'MotherCut', 'DecayDescriptor', 'OutputSelection' ] tree = execInSandbox(_getConfigTree, id, cas) def len1(line): _i = line.rfind('\n') return len(line) if _i < 0 else len(line) - (_i + 1) import re show = not lines 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) * ' ' line += '%-15s : %s' % (k, v) print line
def getTCKList(cas=defaultCas): info = execInSandbox(_getConfigurations, cas) result = [] for i in info.itervalues(): for tck in i['TCK']: result.append('0x%08x' % tck) return result
def getHlt1Decisions(id, cas=defaultCas): id = tck2id(id, cas) table = execInSandbox(_xget, [id], cas)[id] lines = eval(_lookupProperty(table, 'Hlt1', 'Members')) return [ _lookupProperty(table, i.split('/')[-1], 'DecisionName') for i in lines ]
def getAlgorithms(id, cas=defaultCas): tree = execInSandbox(_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
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
def getTCKs(release=None, hlttype=None, cas=defaultCas): info = execInSandbox(_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
def getL0Prescales(id, cas=defaultCas): tree = execInSandbox(_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
def dumpL0(id, cas=defaultCas): tree = execInSandbox(_getConfigTree, id, cas) l0s = [i for i in tree if i.leaf and i.leaf.type == 'L0DUConfigProvider'] for i in l0s: from pprint import pprint 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 * '*'
def tck2id(x, cas): if type(x) is int: x = '0x%08x' % x import re if re.compile('^[0-9a-fA-F]{32}$').match(x): # x is already a configID return x elif re.compile('^0x[0-9a-fA-F]{8}$').match(x): tck = execInSandbox(_tck2id, x, cas) if not tck: raise KeyError("not a valid TCK: " + str(x)) return tck else: raise KeyError("not a valid TCK: " + str(x))
def _orphanScan(cas=defaultCas): treeNodeDict = dict() leafNodeDict = dict() import os dir = None if 'Directory' in cas.getProperties(): dir = cas.getProp('Directory') if not dir and 'Directory' in cas.getDefaultProperties(): dir = cas.getDefaultProperty('Directory') for root, dirs, files in os.walk(dir): print 'checking ' + root import fnmatch for d in fnmatch.filter(dirs, 'CVS'): dirs.remove(d) def updateDict(d, f): if f not in d: d.update({f: list()}) for f in files: if 'PropertyConfigs' in root: updateDict(leafNodeDict, f) if 'ConfigTreeNodes' in root: updateDict(treeNodeDict, f) info = getConfigurations(cas) for (k, v) in info.iteritems(): print '\n\n' print k v.printSimple() id = v.info['id'] tree = execInSandbox(_getConfigTree, id, cas) for node in tree: def updateDict(d, id, top): if id not in d: d.update({id: list()}) if top not in d[id]: d[id] += [top] updateDict(treeNodeDict, node.digest, k) if node.leaf: updateDict(leafNodeDict, node.leaf.digest, k) print 'leafNodes orphans: ' for (k, v) in leafNodeDict.iteritems(): if not v: print k print 'treeNodes orphans: ' for (k, v) in treeNodeDict.iteritems(): if not v: print k
def getConfigTree(id, cas=defaultCas): # return execInSandbox( _getConfigTree, id, cas ) if 'forest' not in dir(getConfigTree): getConfigTree.forest = dict() if id not in getConfigTree.forest: getConfigTree.forest[id] = execInSandbox(_getConfigTree, id, cas) return getConfigTree.forest[id]
def getHltTypes(release, cas=defaultCas): info = execInSandbox(_getConfigurations, cas) return set( [i['hlttype'] for i in info.itervalues() if i['release'] == release])
def getConfigurations(cas=defaultCas): return execInSandbox(_getConfigurations, cas)
def orphanScan(cas=defaultCas): return execInSandbox(_orphanScan, cas)
def copy(source=defaultCas, target=ConfigDBAccessSvc(ReadOnly=False)): return execInSandbox(_copy, source, target)
def createTCKEntries(d, cas=defaultCas): return execInSandbox(_createTCKEntries, d, cas)