9 payload2xmlCodeTemplate =
"""
15 #include <boost/python/class.hpp>
16 #include <boost/python/module.hpp>
17 #include <boost/python/init.hpp>
18 #include <boost/python/def.hpp>
23 #include "boost/archive/xml_oarchive.hpp"
24 #include "CondFormats/Serialization/interface/Serializable.h"
25 #include "CondFormats/Serialization/interface/Archive.h"
27 #include "CondCore/Utilities/src/CondFormats.h"
29 namespace { // Avoid cluttering the global namespace.
31 std::string payload2xml( const std::string &payloadData, const std::string &payloadType ) {
34 std::unique_ptr< %(plType)s > payload;
36 std::stringbuf sdataBuf;
37 sdataBuf.pubsetbuf( const_cast<char *> ( payloadData.c_str() ), payloadData.size() );
39 std::istream inBuffer( &sdataBuf );
40 eos::portable_iarchive ia( inBuffer );
41 payload.reset( new %(plType)s );
44 // now we have the object in memory, convert it to xml in a string and return it
46 std::ostringstream outBuffer;
47 boost::archive::xml_oarchive xmlResult( outBuffer );
48 xmlResult << boost::serialization::make_nvp( "cmsCondPayload", *payload );
50 return outBuffer.str();
56 BOOST_PYTHON_MODULE(%(mdName)s)
58 using namespace boost::python;
59 def ("payload2xml", payload2xml);
64 buildFileTemplate =
"""
65 <flags CXXFLAGS="-Wno-sign-compare -Wno-unused-variable -Os"/>
67 <use name="boost_python"/>
68 <use name="boost_iostreams"/>
69 <use name="boost_serialization"/>
70 <use name="boost_program_options"/>
71 <use name="CondCore/DBCommon"/>
72 <use name="CondCore/IOVService"/>
73 <use name="CondCore/MetaDataService"/>
74 <use name="CondCore/TagCollection"/>
75 <use name="CondCore/CondDB"/>
76 <use name="CondFormats/HLTObjects"/>
77 <use name="CondFormats/Alignment"/>
78 <use name="CondFormats/BeamSpotObjects"/>
79 <use name="CondFormats/CastorObjects"/>
80 <use name="CondFormats/HIObjects"/>
81 <use name="CondFormats/CSCObjects"/>
82 <use name="CondFormats/DTObjects"/>
83 <use name="CondFormats/ESObjects"/>
84 <use name="CondFormats/EcalObjects"/>
85 <use name="CondFormats/EgammaObjects"/>
86 <use name="CondFormats/Luminosity"/>
87 <use name="CondFormats/HcalObjects"/>
88 <use name="CondFormats/JetMETObjects"/>
89 <use name="CondFormats/L1TObjects"/>
90 <use name="CondFormats/PhysicsToolsObjects"/>
91 <use name="CondFormats/GeometryObjects"/>
92 <use name="CondFormats/RecoMuonObjects"/>
93 <use name="CondFormats/RPCObjects"/>
94 <use name="CondFormats/RunInfo"/>
95 <use name="CondFormats/SiPixelObjects"/>
96 <use name="CondFormats/SiStripObjects"/>
97 <use name="CondFormats/Common"/>
98 <use name="CondFormats/BTauObjects"/>
99 <use name="CondFormats/MFObjects"/>
110 self._pl2xml_tmpDir =
"fakeSubSys4pl/fakePkg4pl"
116 shutil.rmtree( self._pl2xml_tmpDir.split(
'/')[0] )
117 os.unlink(
'./pl2xmlComp.so')
122 startTime = time.time()
125 result = session.query(self.conddb.Payload.data, self.conddb.Payload.object_type).
filter(self.conddb.Payload.hash == payload).
one()
126 data, plType = result
128 info = {
"mdName" :
"pl2xmlComp",
132 code = payload2xmlCodeTemplate % info
134 tmpDir = self._pl2xml_tmpDir
135 if ( os.path.exists( tmpDir.split(
'/')[0] )
or
136 os.path.exists( tmpDir ) ) :
137 msg =
'\nERROR: %s already exists, please remove if you did not create that manually !!' % tmpDir
141 os.makedirs( tmpDir+
'/src' )
143 buildFileName =
"%s/BuildFile.xml" % (tmpDir,)
144 with open(buildFileName,
'w')
as buildFile:
145 buildFile.write( buildFileTemplate )
148 tmpFileName =
"%s/src/%s" % (tmpDir, info[
'mdName'],)
149 with open(tmpFileName+
'.cpp',
'w')
as codeFile:
153 cmd =
"source /afs/cern.ch/cms/cmsset_default.sh;"
154 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(
'/',
'') )
158 buildTime = time.time()-startTime
159 print >> sys.stderr,
"buillding done in ", buildTime,
'sec., return code from build: ', ret
167 msg =
"Error preparing code for "+payload
172 result = session.query(self.conddb.Payload.data, self.conddb.Payload.object_type).
filter(self.conddb.Payload.hash == payload).
one()
173 data, plType = result
177 resultXML = pl2xmlComp.payload2xml( data, plType )