CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
cond2xml.CondXmlProcessor Class Reference
Inheritance diagram for cond2xml.CondXmlProcessor:

Public Member Functions

def __del__ (self)
 
def __init__ (self, condDBIn)
 
def discover (self, payloadType)
 
def payload2xml (self, session, payloadHash, destFile)
 
def prepPayload2xml (self, payloadType)
 

Public Attributes

 conddb
 

Detailed Description

Definition at line 50 of file cond2xml.py.

Constructor & Destructor Documentation

def cond2xml.CondXmlProcessor.__init__ (   self,
  condDBIn 
)

Definition at line 52 of file cond2xml.py.

52  def __init__(self, condDBIn):
53  self.conddb = condDBIn
54 
def __init__(self, condDBIn)
Definition: cond2xml.py:52
def cond2xml.CondXmlProcessor.__del__ (   self)

Definition at line 63 of file cond2xml.py.

References PhysicsTools::MVATrainer.doCleanup, and join().

63  def __del__(self):
64 
65  if self.doCleanup:
66  shutil.rmtree( '/'.join( self._pl2xml_tmpDir.split('/')[:-1] ) )
67  return
68 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18

Member Function Documentation

def cond2xml.CondXmlProcessor.discover (   self,
  payloadType 
)

Definition at line 69 of file cond2xml.py.

References dir, and cond2xml.localLibName().

Referenced by cond2xml.CondXmlProcessor.prepPayload2xml().

69  def discover(self, payloadType):
70 
71  libName = 'pluginUtilities_payload2xml.so'
72  # first search: developer area or main release
73  libDir = os.path.join( os.environ["CMSSW_BASE"], 'lib', os.environ["SCRAM_ARCH"] )
74  devLibDir = libDir
75  libPath = os.path.join( devLibDir, libName )
76  devCheckout = ("CMSSW_RELEASE_BASE" in os.environ)
77  if not os.path.exists( libPath ) and devCheckout:
78  # main release ( for dev checkouts )
79  libDir = os.path.join( os.environ["CMSSW_RELEASE_BASE"], 'lib', os.environ["SCRAM_ARCH"] )
80  libPath = os.path.join( libDir, libName )
81  if not os.path.exists( libPath ):
82  # it should never happen!
83  raise Exception('No built-in library found with XML converters.')
84  module = importlib.import_module( libName.replace('.so', '') )
85  functors = dir(module)
86  funcName = payloadType+'2xml'
87  if funcName in functors:
88  logging.info('XML converter for payload class %s found in the built-in library.' %payloadType)
89  return getattr( module, funcName)
90  if not devCheckout:
91  # give-up if it is a read-only release...
92  raise Exception('No XML converter suitable for payload class %s has been found in the built-in library.')
93  libName = 'plugin%s.so' %localLibName( payloadType )
94  libPath = os.path.join( devLibDir, libName )
95  if os.path.exists( libPath ):
96  logging.info('Found local library with XML converter for class %s' %payloadType )
97  module = importlib.import_module( libName.replace('.so', '') )
98  return getattr( module, funcName)
99  logging.warning('No XML converter for payload class %s found in the built-in library.' %payloadType)
100  return None
101 
def localLibName(payloadType)
Definition: cond2xml.py:43
def discover(self, payloadType)
Definition: cond2xml.py:69
dbl *** dir
Definition: mlp_gen.cc:35
def cond2xml.CondXmlProcessor.payload2xml (   self,
  session,
  payloadHash,
  destFile 
)

Definition at line 159 of file cond2xml.py.

References ALCARECOTkAlBeamHalo_cff.filter, cond2xml.CondXmlProcessor.prepPayload2xml(), cond2xml.sanitize(), and harvestTrackValidationPlots.str.

159  def payload2xml(self, session, payloadHash, destFile):
160 
161  Payload = session.get_dbtype(self.conddb.Payload)
162  # get payload from DB:
163  result = session.query(Payload.data, Payload.object_type).filter(Payload.hash == payloadHash).one()
164  data, plType = result
165  logging.info('Found payload of type %s' %plType)
166 
167  convFuncName = sanitize(plType)+'2xml'
168  xmlConverter = self.prepPayload2xml(plType)
169 
170  obj = xmlConverter()
171  resultXML = obj.write( str(data) )
172  if destFile is None:
173  print resultXML
174  else:
175  with open(destFile, 'w') as outFile:
176  outFile.write(resultXML)
177  outFile.close()
178 
def payload2xml(self, session, payloadHash, destFile)
Definition: cond2xml.py:159
def sanitize(typeName)
Definition: cond2xml.py:40
def prepPayload2xml(self, payloadType)
Definition: cond2xml.py:102
def cond2xml.CondXmlProcessor.prepPayload2xml (   self,
  payloadType 
)

Definition at line 102 of file cond2xml.py.

References cond2xml.CondXmlProcessor.discover(), PhysicsTools::MVATrainer.doCleanup, and cond2xml.localLibName().

Referenced by cond2xml.CondXmlProcessor.payload2xml().

102  def prepPayload2xml(self, payloadType):
103 
104  converter = self.discover(payloadType)
def prepPayload2xml(self, payloadType)
Definition: cond2xml.py:102
def discover(self, payloadType)
Definition: cond2xml.py:69

Member Data Documentation

cond2xml.CondXmlProcessor.conddb

Definition at line 53 of file cond2xml.py.