448 def register(self, since=(MINRUN,MINLBK), until=(MAXRUN,MAXLBK), tag=
""):
449 """
450 Registers the folder in the database.
451 - since: lower limit of IOV
452 - until: upper limit of IOV
453 - tag : The cool folder tag to write to
454
455 The interpretation of the 'since' and 'until' inputs depends on their type:
456 - tuple(int,int) : run and lbk number
457 - integer : Values are interpreted as unix time stamps
458 If since<0, current time is assumed
459 If until<0, infinity is assumed
460 - string : time stamp of format 'yyyy-mm-dd hh:mm:ss'
461 """
462
463
465 raise Exception(
"Inconsistent types: since=%s, until=%s" % (
type(since),
type(until)))
466
467
468 userTagOnly = True
469 if self.__folder.versioningMode()==cool.FolderVersioning.SINGLE_VERSION:
470 userTagOnly = False
471
472 if tag!="":
473 self.log().warning( "Trying to store with tag \"%s\" to SINGLE_VERSION folder", tag )
474 self.log().warning( "... resetting tag to \"\"!" )
475 tag=""
476
477
478 sinceCool = getCoolValidityKey(since, True )
479 untilCool = getCoolValidityKey(until, False)
480 if untilCool <= sinceCool:
481 raise Exception("Until(%i) <= Since(%i)" % (untilCool,sinceCool))
482
483
484 iovString = ""
485 if isinstance(since, tuple):
486 iovString = "[%i,%i] - [%i,%i]" % (since[0],since[1],until[0],until[1])
487 else:
488 sinceInfo = time.localtime( sinceCool//UNIX2COOL )
489 untilInfo = time.localtime(
min(UNIXTMAX, (untilCool//UNIX2COOL)))
490 untilStr = "<infinity>"
491 if untilCool<cool.ValidityKeyMax:
492 untilStr = time.asctime(untilInfo)
493 if (untilCool//UNIX2COOL)>UNIXTMAX:
494 untilStr = " > "+untilStr
495 iovString = "[%s] - [%s]" % (time.asctime(sinceInfo), untilStr)
496
497
498 folderTag=tag
499
500
501 self.log().info( "Registering folder %s with tag \"%s\"", self.__folder.fullPath(),folderTag)
502 self.log().info( "... with IOV : %s", iovString )
503
504
505
506 chanList = sorted(self.__chanDictRecord.keys())
507 for chanNum in chanList:
508 data = self.__chanDictRecord[chanNum]
509 strout = "cool channel=%4i" % chanNum
510 self.log().
debug(
"Registering %s %s", strout, data)
511 channelId = cool.ChannelId(chanNum)
512 self.__folder.storeObject(sinceCool, untilCool, data, channelId, folderTag, userTagOnly)
513