604 def register(self, since=(MINRUN,MINLBK), until=(MAXRUN,MAXLBK), tag=
"", option=0):
605 """
606 Registers the folder in the database.
607 - since: lower limit of IOV
608 - until: upper limit of IOV
609 - tag : The cool folder tag to write to
610
611 The interpretation of the 'since' and 'until' inputs depends on their type:
612 - tuple(int,int) : run and lbk number
613 - integer : Values are interpreted as unix time stamps
614 If since<0, current time is assumed
615 If until<0, infinity is assumed
616 - string : time stamp of format 'yyyy-mm-dd hh:mm:ss'
617 """
618
619
621 raise Exception(
"Inconsistent types: since=%s, until=%s" % (
type(since),
type(until)))
622
623
624 userTagOnly = True
625 if self.__folder.versioningMode()==cool.FolderVersioning.SINGLE_VERSION:
626 userTagOnly = False
627
628 if tag!="":
629 self.log().warning( "Trying to store with tag \"%s\" to SINGLE_VERSION folder", tag )
630 self.log().warning( "... resetting tag to \"\"!" )
631 tag=""
632
633
634 sinceCool = getCoolValidityKey(since, True )
635 untilCool = getCoolValidityKey(until, False)
636 if untilCool <= sinceCool:
637 raise Exception("Until(%i) <= Since(%i)" % (untilCool,sinceCool))
638
639
640 iovString = ""
641 if isinstance(since, tuple):
642 iovString = "[%i,%i] - [%i,%i]" % (since[0],since[1],until[0],until[1])
643 else:
644 sinceInfo = time.localtime( sinceCool//UNIX2COOL )
645 untilInfo = time.localtime(
min(UNIXTMAX, (untilCool//UNIX2COOL)))
646 untilStr = "<infinity>"
647 if untilCool<cool.ValidityKeyMax:
648 untilStr = time.asctime(untilInfo)
649 if (untilCool//UNIX2COOL)>UNIXTMAX:
650 untilStr = " > "+untilStr
651 iovString = "[%s] - [%s]" % (time.asctime(sinceInfo), untilStr)
652
653
654 folderTag=tag
655
656
657 comment=self.getComment()
658 onlyComment = (option<0)
659 noComment = (comment is None) or (comment == "None") or (comment.startswith("None") and comment.endswith("None")) or (option>0)
660 self.log().info( "Registering folder %s with tag \"%s\"", self.__folder.fullPath(),folderTag)
661 self.log().info( "... with IOV : %s" , iovString )
662 if noComment:
663 if (option<=0):
664 self.log().info( "... WITHOUT comment field" )
665 else:
666 self.log().info( "... with comment field: \"%s\"", self.getComment() )
667
668
669 if onlyComment:
670 chanList = [1000]
671 else:
672 chanList = sorted(self.__chanDictRecord.keys())
673 cnt=0
674 for chanNum in chanList:
675 if chanNum==1000 and noComment:
676 continue
677 data = self.__chanDictRecord[chanNum]
678 strout = "cool channel=%4i" % chanNum
679 self.log().
debug(
"Registering %s %s", strout, data)
680 channelId = cool.ChannelId(chanNum)
681 self.__folder.storeObject(sinceCool, untilCool, data, channelId, folderTag, userTagOnly)
682 cnt+=1
683 if noComment:
684 self.log().info( "... %d cool channels have been written in total", cnt )
685 elif onlyComment:
686 self.log().info( "... 1 cool channel with comment field has been written" )
687 else:
688 self.log().info( "... %d cool channels have been written in total (including comment field)", cnt )
689