396 def MissingFeb_CheckSavedDatabaseContent(self,dbName,dbSvc,dbFolderName,selectedTag):
397
398
399 try:
400 dbase = dbSvc.openDatabase(dbName,False)
401 except Exception as e:
402 print ('Problem opening database',e)
403 sys.exit(-1)
404 print ("Opened database",dbName)
405
406
407 try:
408 f = dbase.getFolder(dbFolderName)
409 print ("Analysing Folder " + str(dbFolderName))
410 except Exception:
411 print ("Skipping " + str(dbFolderName))
412 return
413
414
415 tags = f.listTags()
416
417
418 if tags.size()==0:
419 tags.push_back("notag")
420
421 print ("for tags ", end='')
422 for tag in tags:
423 print (tag)
424
425 bTagFound=False
426 bSavingProcessError=False
427
428 for tag in tags:
429
430 if tag!=selectedTag:
431 continue
432
433 bTagFound=True
434
435 f.countObjects( cool.ValidityKeyMin,cool.ValidityKeyMax,cool.ChannelSelection.all())
436 objs = f.browseObjects( cool.ValidityKeyMin,cool.ValidityKeyMax,cool.ChannelSelection.all())
437 i = 0
438 while objs.hasNext():
439 obj = objs.next()
440 print ("Found object", i, end='')
441 print ("since [r,l]: [", obj.since() >> 32,',',obj.since()%0x100000000,']', end='')
442 print ("until [r,l]: [", obj.until() >> 32,',',obj.until()%0x100000000,']', end='')
443 print ("payload", obj.payload(), end='')
444 print ("chan",obj.channelId() )
445
446
447 payload=obj.payload()
448 channelSize=payload['ChannelSize']
449 endianness=payload['Endianness']
450 version=payload['Version']
451 blob=payload['Blob']
452
453
454 vect_MissingFeb=self.nspace_LArBadChannelDBTools.decodeFebBlob(blob,channelSize,endianness,version,
455 self.nspace_LArBadChannelDBTools.getDefaultMsgStream())
456
457
458
459 sChannelDict,sChannelDict_Status=self.MissingFeb_TransformEntryIntoDictionnary(vect_MissingFeb)
460
461 sChannelKey=obj.channelId()
462 HWidChecked={}
463 for key in sChannelDict.keys():
464 HWidChecked[key]=0
465
466 print (" -> SQlite database content vs initial data : channel ", sChannelKey)
467
468
469 listHWidKeys=[x for x in sChannelDict.keys()]
470 for x in self.dict_vectMissingFebHWid_Status[sChannelKey].keys():
471 if x not in listHWidKeys:
472 listHWidKeys.append(x)
473 listHWidKeys.sort()
474 iChanCmpt=0
475 for keyHWid in listHWidKeys:
476
477 try:
478 sChanName,sFebStatus,sValueInit=sChannelDict[keyHWid]
479 except Exception:
480 sChanName="UNDEFINED"
481 sFebStatus=0
482
483 sSuffix=" checked"
484 if self.dict_vectMissingFebHWid_Status[sChannelKey][keyHWid]==STATUS_INIT:
485 if sChannelDict[keyHWid][1]!=self.dict_vectMissingFebHWid_Init[sChannelKey][keyHWid][1]:
486 sPrefix="ERR"
487 sSuffix=" no modification was done"+keyHWid
488 bSavingProcessError=True
489 else:
490 sPrefix=" "
491 self.MissingFeb_DisplayMissingFebLine(sPrefix,iChanCmpt,keyHWid,sChanName,sFebStatus,sSuffix)
492
493 if self.dict_vectMissingFebHWid_Status[sChannelKey][keyHWid]==STATUS_REMOVED:
494 if keyHWid in sChannelDict:
495 sPrefix="ERR"
496 sSuffix=" deletion not taken into accout"+keyHWid
497 bSavingProcessError=True
498 else:
499 sPrefix=STATUS_REMOVED
500 sChanName,sFebStatus,sValue_Init=self.dict_vectMissingFebHWid[sChannelKey][keyHWid]
501 self.MissingFeb_DisplayMissingFebLine(sPrefix,iChanCmpt,keyHWid,sChanName,sFebStatus,sSuffix)
502
503 if self.dict_vectMissingFebHWid_Status[sChannelKey][keyHWid]==STATUS_NEW:
504 if sChannelDict[keyHWid][1]!=self.dict_vectMissingFebHWid[sChannelKey][keyHWid][1]:
505 sPrefix="ERR"
506 sSuffix=" error while saving new status "+keyHWid
507 bSavingProcessError=True
508 else:
509 sPrefix=STATUS_NEW
510 self.MissingFeb_DisplayMissingFebLine(sPrefix,iChanCmpt,keyHWid,sChanName,sFebStatus,sSuffix)
511
512 if self.dict_vectMissingFebHWid_Status[sChannelKey][keyHWid]==STATUS_MODIFIED:
513 if sChannelDict[keyHWid][1]!=self.dict_vectMissingFebHWid[sChannelKey][keyHWid][1]:
514 sPrefix="ERR"
515 sSuffix=" error while saving modified status "+keyHWid
516 bSavingProcessError=True
517 else:
518 sPrefix=STATUS_MODIFIED
519 self.MissingFeb_DisplayMissingFebLine(sPrefix,iChanCmpt,keyHWid,sChanName,sFebStatus,sSuffix)
520
521 HWidChecked[keyHWid]=1
522 iChanCmpt += 1
523
524 for key in self.dict_vectMissingFebHWid_Status[sChannelKey].keys():
525 if key not in HWidChecked and self.dict_vectMissingFebHWid_Status[sChannelKey][key]!=STATUS_REMOVED:
526 print ("ERROR : initial ",key," has not been saved")
527 elif key in HWidChecked and HWidChecked[key]==0:
528 print ("ERROR : ",key," has not been checked")
529
530 i += 1
531
532
533 objs.close()
534
535 if bTagFound is False:
536 print ("ERROR : tag "+selectedTag+" not found in saved SQlite file")
537
538 if bSavingProcessError is True:
539 print ("ERROR : found while making comparison between corrected and saved datas" )
540
541
542 dbase.closeDatabase()
543
544
545
546