Cheat list for BK database
Access the BK client
$ SetupLHCbDirac
$ python
>>> from DIRAC.Core.Base import Script
>>> Script.parseCommandLine( ignoreErrors = True )
>>> from LHCbDIRAC.BookkeepingSystem.Client.BookkeepingClient import BookkeepingClient
>>> bk = BookkeepingClient()
Get list of runs between two dates
Dates are stored using the datetime class
>>> import datetime
>>> dt = datetime.datetime(2102,8,17,16,05)
dt corresponds to 17/8/2012, 16:05
After choosing a start and an end date, call the getRunsForAGivenPeriod method of bk:
>>> st = datetime.datetime(2102,1,1,0,0)
>>> et = datetime.datetime(2102,12,31,23,59)
>>> runs = bk.getRunsForAGivenPeriod({'StartDate':st,'EndDate':et})['Value']['Runs']
Create a dictionary with fills and corresponding runs
>>> fills = []
>>> for run in runs:
>>> fill = bk.getRunInformation({'Fields':['FillNumber'],'RunNumber':run})['Value'][run]['FillNumber']
>>> if not fill in fills.keys(): fills.update({fill: [run]})
>>> else: fills[fill] += [run]
Store the dictionary to file if needed:
>>> import json
>>> with open('runsPerFills.json', 'wb') as fp: json.dump(fills, fp)
--
MaurizioMartinelli - 2014-11-05