Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
apfeiffer1 committed Sep 24, 2015
2 parents 35dbe22 + 9c87d3a commit 612d4ac
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 12 deletions.
13 changes: 9 additions & 4 deletions CondCore/CondDB/test/BuildFile.xml
Expand Up @@ -5,20 +5,25 @@
<use name="DataFormats/StdDictionaries"/>
<use name="FWCore/PluginManager"/>
<use name="FWCore/Utilities"/>
<library name="testCondDBDict" file="">
</library>
<bin file="testConditionDatabase_0.cpp" name="testConditionDatabase_0">
<lib name="testCondDBDict"/>

<bin file="testReadWritePayloads.cpp" name="testReadWritePayloads">
<lib name="testCondDBDict"/>
</bin>

<bin file="testConditionDatabase_1.cpp" name="testConditionDatabase_1">
</bin>

<bin file="testConditionDatabase_2.cpp" name="testConditionDatabase_2">
</bin>

<bin file="testRootStreaming.cpp" name="testRootStreaming">
<lib name="testCondDBDict"/>
</bin>

<bin file="testPayloadProxy.cpp" name="testPayloadProxy">
<lib name="testCondDBDict"/>
</bin>

<bin file="testFrontier.cpp" name="testFrontier">
</bin>

8 changes: 8 additions & 0 deletions CondCore/EcalPlugins/plugins/BuildFile.xml
Expand Up @@ -229,3 +229,11 @@
<use name="boost_regex"/>
<flags EDM_PLUGIN="1"/>
</library>

<flags CXXFLAGS="-Wno-sign-compare -Wno-unused-variable"/>
<library file="EcalCondObjectContainer_EcalTPGCrystalStatusCode_toXML.cc" name="EcalCondObjectContainer_EcalTPGCrystalStatusCode_toXML">
<use name="CondCore/Utilities"/>
<use name="CondCore/CondDB"/>
<use name="CondFormats/Common"/>
<use name="boost_python"/>
</library>
@@ -0,0 +1,20 @@

#include "CondCore/Utilities/interface/PayloadToXML.h"
#include "CondCore/Utilities/src/CondFormats.h"

namespace { // Avoid cluttering the global namespace.

// converter methods
std::string EcalCondObjectContainer_EcalTPGCrystalStatusCode2xml( std::string const &payloadData, std::string const &payloadType ) {
return cond::convertToXML<EcalCondObjectContainer<EcalTPGCrystalStatusCode> > (payloadData, payloadType);
}

} // end namespace


BOOST_PYTHON_MODULE( pluginEcalCondObjectContainer_EcalTPGCrystalStatusCode_toXML )
{
using namespace boost::python;
def ("EcalCondObjectContainer_EcalTPGCrystalStatusCode2xml" , &EcalCondObjectContainer_EcalTPGCrystalStatusCode2xml);

}
26 changes: 18 additions & 8 deletions CondCore/Utilities/python/cond2xml.py
Expand Up @@ -34,7 +34,7 @@
namespace { // Avoid cluttering the global namespace.
std::string %(plType)s2xml( const std::string &payloadData, const std::string &payloadType ) {
std::string %(plTypeSan)s2xml( const std::string &payloadData, const std::string &payloadType ) {
// now to convert
std::unique_ptr< %(plType)s > payload;
Expand Down Expand Up @@ -62,7 +62,7 @@
BOOST_PYTHON_MODULE(%(mdName)s)
{
using namespace boost::python;
def ("%(plType)s2xml", %(plType)s2xml);
def ("%(plTypeSan)s2xml", %(plTypeSan)s2xml);
}
"""
Expand Down Expand Up @@ -108,6 +108,10 @@ def ("%(plType)s2xml", %(plType)s2xml);
</export>
"""

# helper function
def sanitize(typeName):
return typeName.replace(' ','').replace('<','_').replace('>','')

class CondXmlProcessor(object):

def __init__(self, condDBIn):
Expand All @@ -131,24 +135,29 @@ def __del__(self):

def discover(self, payloadType):

# print "discover> checking for plugin of type %s" % payloadType

# first search in developer area:
libDir = os.path.join( os.environ["CMSSW_BASE"], 'lib', os.environ["SCRAM_ARCH"] )
pluginList = glob.glob( libDir + '/plugin%s_toXML.so' % payloadType )
pluginList = glob.glob( libDir + '/plugin%s_toXML.so' % sanitize(payloadType) )

# if nothing found there, check release:
if not pluginList:
libDir = os.path.join( os.environ["CMSSW_RELEASE_BASE"], 'lib', os.environ["SCRAM_ARCH"] )
pluginList = glob.glob( libDir + '/plugin%s_toXML.so' % payloadType )
pluginList = glob.glob( libDir + '/plugin%s_toXML.so' % sanitize(payloadType) )

# print "found plugin for %s (in %s) : %s " % (payloadType, libDir, pluginList)
# if pluginList:
# print "found plugin for %s (in %s) : %s " % (payloadType, libDir, pluginList)
# else:
# print "no plugin found for type %s" % payloadType

xmlConverter = None
if len(pluginList) > 0:
dirPath, libName = os.path.split( pluginList[0] )
sys.path.append(dirPath)
# print "going to import %s from %s" % (libName, dirPath)
xmlConverter = importlib.import_module( libName.replace('.so', '') )
# print "found : ", dir(xmlConverter)
# print "found methods: ", dir(xmlConverter)
self.doCleanup = False

return xmlConverter
Expand All @@ -162,7 +171,8 @@ def prepPayload2xml(self, session, payload):
data, plType = result

info = { "mdName" : "pl2xmlComp",
'plType' : plType,
'plType' : plType,
'plTypeSan' : sanitize(plType),
}

converter = self.discover(plType)
Expand Down Expand Up @@ -217,7 +227,7 @@ def payload2xml(self, session, payload):
result = session.query(self.conddb.Payload.data, self.conddb.Payload.object_type).filter(self.conddb.Payload.hash == payload).one()
data, plType = result

convFuncName = plType+'2xml'
convFuncName = sanitize(plType)+'2xml'
sys.path.append('.')
func = getattr(xmlConverter, convFuncName)
resultXML = func( str(data), str(plType) )
Expand Down

0 comments on commit 612d4ac

Please sign in to comment.