Пример #1
0
    print 'Reading in IOVs...'
    iniovs = indb.retrieve(since=since,
                           until=until,
                           channels=channels,
                           primary_only=True,
                           nonpresent=(not opts.noabsent))
    print '%d IOVs retrieved from input database' % len(iniovs)
    #inchannels = set((x.channel for x in iniovs))
    inchannels = set(channels if channels is not None else indb.defect_names)
    outchannels = set(outdb.defect_names)
    missingchannels = inchannels - outchannels
    if len(missingchannels) != 0:
        if not opts.createdefects:
            print 'Missing defect(s) in target database:'
            print list(missingchannels)
            print 'Rerun with a restricted defect list (--defects) or with --createdefects'
            sys.exit(1)
        else:
            print 'Creating missing channels on output database'
            descriptions = indb.get_channel_descriptions(missingchannels)
            for channel in missingchannels:
                outdb.create_defect(channel, descriptions[channel])

    with outdb.storage_buffer:
        print 'Writing out IOVs...'
        for iov in iniovs:
            outdb.insert(iov.channel, iov.since, iov.until, iov.comment,
                         iov.user, iov.present, iov.recoverable)

    print 'Done.'
Пример #2
0
    spec = cool.RecordSpecification()
    #spec.extend("filename", cool.StorageType.String255)
    #spec.extend("guid", cool.StorageType.Int32)
    spec.extend("Code", cool.StorageType.Int32)
    spec.extend("deadFrac", cool.StorageType.Float)
    spec.extend("Thrust", cool.StorageType.Float)
    print "Creating folder", folderName,
    # Deprecated/dropped:  folder = db.createFolder(folderName, spec, "", cool.FolderVersioning.MULTI_VERSION, False)
    folderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION,
                                          spec)
    folder = db.createFolder(folderName, folderSpec, "", False)
    print "... Done"

print "Creating channels."
channelDict = getChannelDict()
for channelName in channelDict.keys():
    try:
        folder.createChannel(channelDict[channelName], channelName)
        print "Created channel:", channelName
    except:
        print "Channel", channelName, "already exists."

db.closeDatabase()

# create defects
from DQDefects import DefectsDB
ddb = DefectsDB(connectString, create=True, read_only=False)
chandb = DefectsDB('COOLOFL_GLOBAL/CONDBR2')
for chan in chandb.defect_names:
    ddb.create_defect(chan, chandb.get_channel_descriptions([chan]))