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  releaseBase = os.environ["CMSSW_RELEASE_BASE"]
77  devCheckout = (releaseBase != '')
78  if not devCheckout:
79  logging.debug('Looks like the current working environment is a read-only release')
80  if not os.path.exists( libPath ) and devCheckout:
81  # main release ( for dev checkouts )
82  libDir = os.path.join( releaseBase, 'lib', os.environ["SCRAM_ARCH"] )
83  libPath = os.path.join( libDir, libName )
84  if not os.path.exists( libPath ):
85  if "CMSSW_FULL_RELEASE_BASE" in os.environ:
86  libDir = os.path.join( os.environ["CMSSW_FULL_RELEASE_BASE"], 'lib', os.environ["SCRAM_ARCH"] )
87  libPath = os.path.join( libDir, libName )
88  if not os.path.exists( libPath ):
89  # it should never happen!
90  raise Exception('No built-in library %s found with XML converters.' %libPath)
91  logging.debug("Importing built-in library %s" %libPath)
92  module = importlib.import_module( libName.replace('.so', '') )
93  functors = dir(module)
94  funcName = payloadType+'2xml'
95  if funcName in functors:
96  logging.info('XML converter for payload class %s found in the built-in library.' %payloadType)
97  return getattr( module, funcName)
98  if not devCheckout:
99  # give-up if it is a read-only release...
100  raise Exception('No XML converter suitable for payload class %s has been found in the built-in library.')
101  libName = 'plugin%s.so' %localLibName( payloadType )
102  libPath = os.path.join( devLibDir, libName )
103  if os.path.exists( libPath ):
104  logging.info('Found local library with XML converter for class %s' %payloadType )
105  module = importlib.import_module( libName.replace('.so', '') )
106  return getattr( module, funcName)
107  logging.warning('No XML converter for payload class %s found in the built-in library.' %payloadType)
108  return None
109 
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 168 of file cond2xml.py.

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

168  def payload2xml(self, session, payloadHash, destFile):
169 
170  Payload = session.get_dbtype(self.conddb.Payload)
171  # get payload from DB:
172  result = session.query(Payload.data, Payload.object_type).filter(Payload.hash == payloadHash).one()
173  data, plType = result
174  logging.info('Found payload of type %s' %plType)
175 
176  convFuncName = sanitize(plType)+'2xml'
177  xmlConverter = self.prepPayload2xml(plType)
178 
179  if xmlConverter is not None:
180  obj = xmlConverter()
181  resultXML = obj.write( str(data) )
182  if destFile is None:
183  print resultXML
184  else:
185  with open(destFile, 'w') as outFile:
186  outFile.write(resultXML)
187  outFile.close()
188 
def payload2xml(self, session, payloadHash, destFile)
Definition: cond2xml.py:168
def sanitize(typeName)
Definition: cond2xml.py:40
def prepPayload2xml(self, payloadType)
Definition: cond2xml.py:110
#define str(s)
def cond2xml.CondXmlProcessor.prepPayload2xml (   self,
  payloadType 
)

Definition at line 110 of file cond2xml.py.

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

Referenced by cond2xml.CondXmlProcessor.payload2xml().

110  def prepPayload2xml(self, payloadType):
111 
112  converter = self.discover(payloadType)
def prepPayload2xml(self, payloadType)
Definition: cond2xml.py:110
def discover(self, payloadType)
Definition: cond2xml.py:69

Member Data Documentation

cond2xml.CondXmlProcessor.conddb

Definition at line 53 of file cond2xml.py.