ATLAS Offline Software
dmtest_condwriter.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4 #
5 # Script to create an AthenaAttributeList with a single attribute "xint".
6 # Usage example: dmtest_condwriter.py --rs=1 --ls=1 'sqlite://;schema=test.db;dbname=OFLP200' AttrList_noTag 42
7 #
8 
9 import sys,os
10 os.environ['CLING_STANDARD_PCH'] = 'none' #See bug ROOT-10789
11 from PyCool import cool
12 from CoolConvUtilities import AtlCoolLib, AtlCoolTool
13 
14 class createTestDB(AtlCoolLib.coolTool):
15 
16  def setup(self,args):
17  # set values of non-optional parameters
18  self.tag=str(args[0])
19  self.xint=int(args[1])
20  self.folder=args[2] if len(args)>2 else '/DMTest/TestAttrList'
21 
22  def usage(self):
23  """ Define the additional syntax for options """
24  self._usage1()
25  print ('TAG xint [Folder]')
26  self._usage2()
27 
28  def execute(self):
29 
30  # do update - setup folder specification and create if needed
31  spec = cool.RecordSpecification()
32  spec.extend("xint", cool.StorageType.Int32)
33  print (">== Store object in folder", self.folder)
34  cfolder = AtlCoolLib.ensureFolder(self.db, self.folder, spec,
35  AtlCoolLib.athenaDesc(self.runLumi, 'AthenaAttributeList'),
36  cool.FolderVersioning.MULTI_VERSION)
37  if (cfolder is None): sys.exit(1)
38  # now write data
39  payload = cool.Record(spec)
40  payload['xint'] = self.xint
41  print ('>== Store object with IOV [',self.since,',',self.until,'] and tag',self.tag,'xint',self.xint)
42  try:
43  if (self.tag=="HEAD"):
44  cfolder.storeObject(self.since,self.until,payload,0)
45  else:
46  cfolder.storeObject(self.since,self.until,payload,0,self.tag)
47  print (">== Storing COOL object succeeded. Current content:")
48  except Exception:
49  import traceback
50  traceback.print_exc()
51  print ('>== Storing COOL object FAILED')
52  sys.exit(1)
53 
54  # print full content
55  act = AtlCoolTool.AtlCoolTool(self.db)
56  print (act.more(self.folder))
57 
58 mytool = createTestDB('dmtest_condwriter.py',False,3,4,[])
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
dmtest_condwriter.createTestDB.usage
def usage(self)
Definition: dmtest_condwriter.py:22
dmtest_condwriter.createTestDB.folder
folder
Definition: dmtest_condwriter.py:20
dmtest_condwriter.createTestDB.xint
xint
Definition: dmtest_condwriter.py:19
dmtest_condwriter.createTestDB
Definition: dmtest_condwriter.py:14
str
Definition: BTagTrackIpAccessor.cxx:11
dmtest_condwriter.createTestDB.execute
def execute(self)
Definition: dmtest_condwriter.py:28
dmtest_condwriter.createTestDB.tag
tag
Definition: dmtest_condwriter.py:18
dmtest_condwriter.createTestDB.setup
def setup(self, args)
Definition: dmtest_condwriter.py:16