9 def addAndRemove(dbname,folder,tag,ts1,ts2,chansToAdd=dict(),chansToRemove=()):
11 print (
"Add:",chansToAdd)
12 print (
"Rem:",chansToRemove)
14 dbSvc = cool.DatabaseSvcFactory.databaseService()
17 db1= dbSvc.openDatabase(dbname,
False)
18 except Exception
as e:
19 print (
"Problems connecting to database:",e)
23 if not db1.existsFolder(folder):
24 print (
"ERROR folder",folder,
"does not exist in",dbname)
27 fd1=db1.getFolder(folder)
29 itr=fd1.browseObjects(ts1,ts2,cool.ChannelSelection.all(),tag)
39 bcBlob=payload[
"Blob"]
44 toAdd=deepcopy(chansToAdd[cc])
50 for i
in range(
int(bcBlob.size()/8)):
51 (ch,bc)=
unpack(
'II',bcBlob.read(8))
52 if ch
in chansToRemove:
53 print (
"Removing entry [0x%x 0x%x] from COOL channel %i, IOV start run %i" % (ch,bc,cc, since>>32))
59 print (
"Augmenting existing channel 0x%x to 0x%x in COOL channel %i, IOV start run %i" % (ch,bc,cc, since>>32))
64 for (ch,bc)
in toAdd.items():
65 print (
"Adding entry [0x%x 0x%x] to COOL channel %i, IOV start run %i" % (ch,bc,cc, since>>32))
70 bcBlob.resize(8*len(newData))
72 for i
in range(len(newData)):
73 bcBlob.write(pack(
"II",newData[i][0],newData[i][1]))
75 print (
"Storing changed object channel %i, valid from run %i to %i" % (cc,since>>32,obj.until()>>32))
76 fd1.storeObject(since,obj.until(),payload,cc,tag,
True)