8 def addAndRemove(dbname,folder,tag,ts1,ts2,chansToAdd=dict(),chansToRemove=()):
10 print (
"Add:",chansToAdd)
11 print (
"Rem:",chansToRemove)
13 dbSvc = cool.DatabaseSvcFactory.databaseService()
16 db1= dbSvc.openDatabase(dbname,
False)
17 except Exception
as e:
18 print (
"Problems connecting to database:",e)
22 if not db1.existsFolder(folder):
23 print (
"ERROR folder",folder,
"does not exist in",dbname)
26 fd1=db1.getFolder(folder)
28 itr=fd1.browseObjects(ts1,ts2,cool.ChannelSelection.all(),tag)
38 bcBlob=payload[
"Blob"]
43 toAdd=deepcopy(chansToAdd[cc])
49 for i
in range(
int(bcBlob.size()/8)):
50 (ch,bc)=
unpack(
'II',bcBlob.read(8))
51 if ch
in chansToRemove:
52 print (
"Removing entry [0x%x 0x%x] from COOL channel %i, IOV start run %i" % (ch,bc,cc, since>>32))
58 print (
"Augmenting existing channel 0x%x to 0x%x in COOL channel %i, IOV start run %i" % (ch,bc,cc, since>>32))
63 for (ch,bc)
in toAdd.items():
64 print (
"Adding entry [0x%x 0x%x] to COOL channel %i, IOV start run %i" % (ch,bc,cc, since>>32))
69 bcBlob.resize(8*len(newData))
71 for i
in range(len(newData)):
72 bcBlob.write(pack(
"II",newData[i][0],newData[i][1]))
74 print (
"Storing changed object channel %i, valid from run %i to %i" % (cc,since>>32,obj.until()>>32))
75 fd1.storeObject(since,obj.until(),payload,cc,tag,
True)