CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes
cond2xml.CondXmlProcessor Class Reference
Inheritance diagram for cond2xml.CondXmlProcessor:

Public Member Functions

def __del__
 
def __init__
 
def payload2xml
 
def prepPayload2xml
 

Public Attributes

 conddb
 
 doCleanup
 

Static Public Attributes

tuple buildTime = time.time()
 

Private Attributes

 _pl2xml_isPrepared
 

Detailed Description

Definition at line 105 of file cond2xml.py.

Constructor & Destructor Documentation

def cond2xml.CondXmlProcessor.__init__ (   self,
  condDBIn 
)

Definition at line 107 of file cond2xml.py.

108  def __init__(self, condDBIn):
109  self.conddb = condDBIn
self._pl2xml_isPrepared = False
def cond2xml.CondXmlProcessor.__del__ (   self)

Definition at line 113 of file cond2xml.py.

References cond2xml.CondXmlProcessor.doCleanup.

114  def __del__(self):
115 
116  if self.doCleanup:
117  shutil.rmtree( self._pl2xml_tmpDir.split('/')[0] )
118  os.unlink('./pl2xmlComp.so')
119  return

Member Function Documentation

def cond2xml.CondXmlProcessor.payload2xml (   self,
  session,
  payload 
)

Definition at line 163 of file cond2xml.py.

References cond2xml.CondXmlProcessor._pl2xml_isPrepared, alcazmumu_cfi.filter, and cond2xml.CondXmlProcessor.prepPayload2xml().

164  def payload2xml(self, session, payload):
165 
166  if not self._pl2xml_isPrepared:
167  if not self.prepPayload2xml(session, payload):
168  msg = "Error preparing code for "+payload
169  raise Exception(msg)
170  self._pl2xml_isPrepared = True
171 
172  # get payload from DB:
173  result = session.query(self.conddb.Payload.data, self.conddb.Payload.object_type).filter(self.conddb.Payload.hash == payload).one()
174  data, plType = result
175 
176  sys.path.append('.')
177  import pl2xmlComp
178  resultXML = pl2xmlComp.payload2xml( data, plType )
179  print resultXML
180 
def cond2xml.CondXmlProcessor.prepPayload2xml (   self,
  session,
  payload 
)

Definition at line 120 of file cond2xml.py.

References alcazmumu_cfi.filter.

Referenced by cond2xml.CondXmlProcessor.payload2xml().

121  def prepPayload2xml(self, session, payload):
122 
123  startTime = time.time()
124 
125  # get payload from DB:
126  result = session.query(self.conddb.Payload.data, self.conddb.Payload.object_type).filter(self.conddb.Payload.hash == payload).one()
127  data, plType = result
128 
129  info = { "mdName" : "pl2xmlComp",
130  'plType' : plType,
131  }
132 
133  code = payload2xmlCodeTemplate % info
134 
135  tmpDir = self._pl2xml_tmpDir
136  if ( os.path.exists( tmpDir.split('/')[0] ) or
137  os.path.exists( tmpDir ) ) :
138  msg = '\nERROR: %s already exists, please remove if you did not create that manually !!' % tmpDir
139  self.doCleanup = False
140  raise Exception(msg)
141 
142  os.makedirs( tmpDir+'/src' )
143 
144  buildFileName = "%s/BuildFile.xml" % (tmpDir,)
145  with open(buildFileName, 'w') as buildFile:
146  buildFile.write( buildFileTemplate )
147  buildFile.close()
148 
149  tmpFileName = "%s/src/%s" % (tmpDir, info['mdName'],)
150  with open(tmpFileName+'.cpp', 'w') as codeFile:
151  codeFile.write(code)
152  codeFile.close()
153 
154  cmd = "source /afs/cern.ch/cms/cmsset_default.sh;"
155  cmd += "(cd %s ; scram b 2>&1 >build.log && cp %s/tmp/%s/src/%s/src/%s/lib%s.so ../../pl2xmlComp.so )" % (tmpDir, os.environ["CMSSW_BASE"], os.environ["SCRAM_ARCH"], tmpDir, tmpDir.replace('/',''), tmpDir.replace('/','') )
ret = os.system(cmd)

Member Data Documentation

cond2xml.CondXmlProcessor._pl2xml_isPrepared
private

Definition at line 109 of file cond2xml.py.

Referenced by cond2xml.CondXmlProcessor.payload2xml().

tuple cond2xml.CondXmlProcessor.buildTime = time.time()
static

Definition at line 158 of file cond2xml.py.

cond2xml.CondXmlProcessor.conddb

Definition at line 108 of file cond2xml.py.

cond2xml.CondXmlProcessor.doCleanup

Definition at line 138 of file cond2xml.py.

Referenced by cond2xml.CondXmlProcessor.__del__().