Beispiel #1
0
    def getPathToProjectConfigurationFile(self, _strPluginName):
        """
        This method returns the path to the Project configuration file.

        @param _strPluginName: Name of the module
        @type _strPluginName: python string

        @return: The path to the project configuration file
        @type: python string
        """
        strPathToProjectConfigurationFile = None
        strCurrentDirectory = EDFactoryPluginStatic.getModuleLocation(_strPluginName)
        if strCurrentDirectory is None:
            self.WARNING("Cannot find path to configuration for plugin %s" % _strPluginName)
        else:
            with self.locked():
                bConfFileFound = False
                strPathToProjectConfigurationFile = None
                strConfigurationFileBaseName = "XSConfiguration_%s" % EDUtilsPath.EDNA_SITE
                while not bConfFileFound:
                    strPreviousDirectory = strCurrentDirectory
                    strCurrentDirectory = os.path.dirname(strCurrentDirectory)
                    if strCurrentDirectory in (EDUtilsPath.EDNA_HOME, strPreviousDirectory):
                        strPathToProjectConfigurationFile = None
                        break
                    strPathToConfigurationDirectory = os.path.abspath(os.path.join(strCurrentDirectory, "conf"))
                    for ext in [".json", ".xml"]:
                        strPathToProjectConfigurationFile = os.path.abspath(os.path.join(strPathToConfigurationDirectory, \
                                                                                    strConfigurationFileBaseName + ext))
                        self.DEBUG("Looking for configuration file for %s in %s" %
                                    (_strPluginName, strPathToProjectConfigurationFile))
                        bConfFileFound = os.path.isfile(strPathToProjectConfigurationFile)
                        if bConfFileFound:
                            break
        return strPathToProjectConfigurationFile
Beispiel #2
0
 def loadCalibratedData(self, _strElementName):
     """
     This method reads a file containing the calibrated energy spectra
     """
     calibratedData = None
     strModuleLocation = EDFactoryPluginStatic.getModuleLocation(
         self.getPluginName())
     strEnergyDataFile = os.path.join(os.path.dirname(strModuleLocation),
                                      "calibrationData",
                                      _strElementName + ".dat")
     if os.path.exists(strEnergyDataFile):
         listLines = []
         with open(strEnergyDataFile, 'r') as f:
             listLines = f.readlines()
         iSkipHeader = 0
         iSkipFooter = 0
         bIsHeader = True
         for strLine in listLines:
             if strLine.startswith('#'):
                 if bIsHeader:
                     iSkipHeader += 1
                 else:
                     iSkipFooter += 1
             else:
                 bIsHeader = False
         calibratedData = numpy.genfromtxt(strEnergyDataFile,
                                           skip_header=iSkipHeader,
                                           skip_footer=iSkipFooter)
     return calibratedData
Beispiel #3
0
 def configure(self):
     EDPluginExec.configure(self)
     EDVerbose.DEBUG("EDPluginExecOutputHTMLv1_0.configure")
     self.strEDNA2html = self.config.get(self.CONF_EDNA2html)
     if self.strEDNA2html is None and os.environ.has_key("EDNA2html"):
         self.strEDNA2html = os.environ["EDNA2html"]
     else:
         self.strEDNA2html = EDFactoryPluginStatic.getModuleLocation("EDNA2html")
     pass
Beispiel #4
0
 def configure(self):
     EDPluginExec.configure(self)
     EDVerbose.DEBUG("EDPluginExecOutputHTMLv1_0.configure")
     self.strEDNA2html = self.config.get(self.CONF_EDNA2html)
     if self.strEDNA2html is None and os.environ.has_key("EDNA2html"):
         self.strEDNA2html = os.environ["EDNA2html"]
     else:
         self.strEDNA2html = EDFactoryPluginStatic.getModuleLocation(
             "EDNA2html")
     pass
    def configure(self):
        EDPluginExec.configure(self)
        EDVerbose.DEBUG("EDPluginExecOutputHTMLv1_0.configure")
        pluginConfiguration = self.getConfiguration()

        if pluginConfiguration != None:
            self.strEDNA2html = EDConfiguration.getStringParamValue(pluginConfiguration, \
                                                               EDPluginExecOutputHTMLv1_0.CONF_EDNA2html)
        elif os.environ.has_key("EDNA2html"):
            self.strEDNA2html = os.environ["EDNA2html"]
        else:
            self.strEDNA2html = EDFactoryPluginStatic.getModuleLocation("EDNA2html")
        pass
Beispiel #6
0
    def configure(self):
        EDPluginExec.configure(self)
        EDVerbose.DEBUG("EDPluginExecOutputHTMLv1_0.configure")
        pluginConfiguration = self.getConfiguration()

        if pluginConfiguration != None:
            self.strEDNA2html = EDConfiguration.getStringParamValue(pluginConfiguration, \
                                                               EDPluginExecOutputHTMLv1_0.CONF_EDNA2html)
        elif os.environ.has_key("EDNA2html"):
            self.strEDNA2html = os.environ["EDNA2html"]
        else:
            self.strEDNA2html = EDFactoryPluginStatic.getModuleLocation(
                "EDNA2html")
        pass
Beispiel #7
0
    def getPathToProjectConfigurationFile(self, _strPluginName):
        """
        This method returns the path to the Project configuration file.

        @param _strPluginName: Name of the module
        @type _strPluginName: python string

        @return: The path to the project configuration file
        @type: python string
        """
        strPathToProjectConfigurationFile = None
        strCurrentDirectory = EDFactoryPluginStatic.getModuleLocation(
            _strPluginName)
        if strCurrentDirectory is None:
            self.WARNING("Cannot find path to configuration for plugin %s" %
                         _strPluginName)
        else:
            with self.locked():
                bConfFileFound = False
                strPathToProjectConfigurationFile = None
                strConfigurationFileBaseName = "XSConfiguration_%s" % EDUtilsPath.EDNA_SITE
                while not bConfFileFound:
                    strPreviousDirectory = strCurrentDirectory
                    strCurrentDirectory = os.path.dirname(strCurrentDirectory)
                    if strCurrentDirectory in (EDUtilsPath.EDNA_HOME,
                                               strPreviousDirectory):
                        strPathToProjectConfigurationFile = None
                        break
                    strPathToConfigurationDirectory = os.path.abspath(
                        os.path.join(strCurrentDirectory, "conf"))
                    for ext in [".json", ".xml"]:
                        strPathToProjectConfigurationFile = os.path.abspath(os.path.join(strPathToConfigurationDirectory, \
                                                                                    strConfigurationFileBaseName + ext))
                        self.DEBUG(
                            "Looking for configuration file for %s in %s" %
                            (_strPluginName,
                             strPathToProjectConfigurationFile))
                        bConfFileFound = os.path.isfile(
                            strPathToProjectConfigurationFile)
                        if bConfFileFound:
                            break
        return strPathToProjectConfigurationFile
 def loadCalibratedData(self, _strElementName):
     """
     This method reads a file containing the calibrated energy spectra
     """
     calibratedData = None
     strModuleLocation = EDFactoryPluginStatic.getModuleLocation(self.getPluginName())
     strEnergyDataFile = os.path.join(os.path.dirname(strModuleLocation), "calibrationData", _strElementName+".dat")
     if os.path.exists(strEnergyDataFile):
         listLines = []
         with open(strEnergyDataFile, 'r') as f:
             listLines = f.readlines()
         iSkipHeader = 0
         iSkipFooter = 0
         bIsHeader = True
         for strLine in listLines:
             if strLine.startswith('#'):
                 if bIsHeader:
                     iSkipHeader += 1
                 else:
                     iSkipFooter += 1
             else:
                 bIsHeader = False
         calibratedData = numpy.genfromtxt(strEnergyDataFile, skip_header=iSkipHeader, skip_footer=iSkipFooter)
     return calibratedData
from EDFactoryPluginStatic import EDFactoryPluginStatic
from EDVerbose import EDVerbose
from EDUtilsFile import EDUtilsFile
from EDPluginExec import EDPluginExec
from EDActionExecuteSystemCommand import EDActionExecuteSystemCommand
from EDConfiguration import EDConfiguration

from XSDataCommon import XSPluginItem

# import the DriverFactory - either from edna's xia2core or a separate
# one configured in the environment as XIA2CORE_ROOT.

if "XIA2CORE_ROOT" in os.environ and os.environ['XIA2CORE_ROOT'] != '':
    pathxia2core = os.path.join(os.environ['XIA2CORE_ROOT'], 'Python')
else:
    pathxia2core = EDFactoryPluginStatic.getModuleLocation('XIA2CoreVersion')
    os.environ["XIA2CORE_ROOT"] = os.path.dirname(pathxia2core)

EDVerbose.DEBUG('Found xia2core in %s' % pathxia2core)

EDFactoryPluginStatic.preImport("Driver", pathxia2core)

from Driver.DriverFactory import DriverFactory

class EDPluginExecProcessXIA2CORE(EDPluginExec):

    # static class variables

    CONF_EXEC_PROCESS_EXECUTABLE = "execProcessExecutable"
    CONF_EXEC_PROCESS_XIA2CORE_TYPE = "execProcessXIA2COREType"
    CONF_EXEC_PROCESS_VERSION_STRING = "execProcessXIA2COREVersionString"
if not os.environ.has_key("EDNA_HOME"):
    strProgramPath = os.path.abspath(sys.argv[0])
    pyListPath = strProgramPath.split(os.sep)
    if len(pyListPath) > 5:
        strEdnaHomePath = os.sep.join(pyListPath[:-5])
    else:
        print ("Problem in the EDNA_HOME path ..." + strEdnaHomePath)
        sys.exit()
    os.environ["EDNA_HOME"] = strEdnaHomePath

sys.path.append(os.path.join(strEdnaHomePath, "src"))
from EDFactoryPluginStatic import EDFactoryPluginStatic

strXsdFileName="XSDataSimpleHTMLPagev1_0.edml"

strPluginDir = EDFactoryPluginStatic.getModuleLocation("EDPluginExecSimpleHTMLPagev1_0")
strMXv1DatamodelHomeDir = os.path.join(strEdnaHomePath, "mxv1", "datamodel")
strXsdHomeDir  = os.path.join(os.path.dirname(strPluginDir), "datamodel")

strKernelDatamodelHomeDir = os.path.join(strEdnaHomePath, "kernel", "datamodel")


strCommand = "java -jar %s/EDGenerateDS.jar -includepaths %s,%s,%s -sourceDir %s -sourceFile %s -targetdir %s" % (\
          strKernelDatamodelHomeDir, strKernelDatamodelHomeDir, strMXv1DatamodelHomeDir, strXsdHomeDir,\
          strXsdHomeDir, strXsdFileName, strPluginDir)

print strCommand
os.system("java -version")
os.chdir(strXsdHomeDir)
os.system(strCommand)
if not os.environ.has_key("EDNA_HOME"):
    strProgramPath = os.path.abspath(sys.argv[0])
    pyListPath = strProgramPath.split(os.sep)
    if len(pyListPath) > 5:
        strEdnaHomePath = os.sep.join(pyListPath[:-5])
    else:
        print("Problem in the EDNA_HOME path ..." + strEdnaHomePath)
        sys.exit()
    os.environ["EDNA_HOME"] = strEdnaHomePath

sys.path.append(os.path.join(strEdnaHomePath, "src"))
from EDFactoryPluginStatic import EDFactoryPluginStatic

strXsdFileName = "XSDataSimpleHTMLPagev1_0.edml"

strPluginDir = EDFactoryPluginStatic.getModuleLocation(
    "EDPluginExecSimpleHTMLPagev1_0")
strMXv1DatamodelHomeDir = os.path.join(strEdnaHomePath, "mxv1", "datamodel")
strXsdHomeDir = os.path.join(os.path.dirname(strPluginDir), "datamodel")

strKernelDatamodelHomeDir = os.path.join(strEdnaHomePath, "kernel",
                                         "datamodel")


strCommand = "java -jar %s/EDGenerateDS.jar -includepaths %s,%s,%s -sourceDir %s -sourceFile %s -targetdir %s" % (\
          strKernelDatamodelHomeDir, strKernelDatamodelHomeDir, strMXv1DatamodelHomeDir, strXsdHomeDir,\
          strXsdHomeDir, strXsdFileName, strPluginDir)

print strCommand
os.system("java -version")
os.chdir(strXsdHomeDir)
os.system(strCommand)
from EDFactoryPluginStatic import EDFactoryPluginStatic
from EDVerbose import EDVerbose
from EDUtilsFile import EDUtilsFile
from EDPluginExec import EDPluginExec
from EDActionExecuteSystemCommand import EDActionExecuteSystemCommand
from EDConfiguration import EDConfiguration

from XSDataCommon import XSPluginItem

# import the DriverFactory - either from edna's xia2core or a separate
# one configured in the environment as XIA2CORE_ROOT.

if "XIA2CORE_ROOT" in os.environ and os.environ['XIA2CORE_ROOT'] != '':
    pathxia2core = os.path.join(os.environ['XIA2CORE_ROOT'], 'Python')
else:
    pathxia2core = EDFactoryPluginStatic.getModuleLocation('XIA2CoreVersion')
    os.environ["XIA2CORE_ROOT"] = os.path.dirname(pathxia2core)

EDVerbose.DEBUG('Found xia2core in %s' % pathxia2core)

EDFactoryPluginStatic.preImport("Driver", pathxia2core)

from Driver.DriverFactory import DriverFactory


class EDPluginExecProcessXIA2CORE(EDPluginExec):

    # static class variables

    CONF_EXEC_PROCESS_EXECUTABLE = "execProcessExecutable"
    CONF_EXEC_PROCESS_XIA2CORE_TYPE = "execProcessXIA2COREType"