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

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2014-11-05 - MaurizioMartinelli
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    LHCb All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback