Exemplo n.º 1
0
    def executePluginSynchronous(self, _edPlugin):
        """
        This method is used to start executable plugins in pipeline synchronously.
        """
        _edControlSlotSUCCESS = EDSlot()
        _edControlSlotFAILURE = EDSlot()

        map(_edControlSlotSUCCESS.connect, _edPlugin.getSlotSUCCESS().getListMethod())
        map(_edControlSlotFAILURE.connect, _edPlugin.getSlotFAILURE().getListMethod())

        _edPlugin.getSlotSUCCESS().emptyListMethod()
        _edPlugin.getSlotFAILURE().emptyListMethod()

        _edPlugin.executeSynchronous()

        if (not _edPlugin.isFailure()):
            EDVerbose.DEBUG("EDControlPlugin.executeSynchronous slotSUCCESS")
            # Check that something doesn't go wrong in the success method!
            try:
                _edControlSlotSUCCESS.call(_edPlugin)

            except Exception:
                EDVerbose.DEBUG("EDControlPlugin.executeSynchronous: ERROR in slotSUCCESS!")
                EDVerbose.writeErrorTrace()
                _edPlugin.setFailure()

        if (_edPlugin.isFailure()):
            EDVerbose.DEBUG("EDControlPlugin.executeSynchronous slotFAILURE")
            # Check that something doesn't go wrong in the success method!
            try:
                _edControlSlotFAILURE.call(_edPlugin)

            except Exception:
                EDVerbose.DEBUG("EDControlPlugin.executeSynchronous: ERROR in slotFAILURE!")
                EDVerbose.writeErrorTrace()
    def sendEmail(self, _strSubject, _strMessage):
        """Sends an email to the EDNA contact person (if configured)."""

        EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.sendEmail: Subject = %s" % _strSubject)
        EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.sendEmail: Message:")
        EDVerbose.DEBUG(_strMessage)
        if self.__strEDNAContactEmail == None:
            EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.sendEmail: No email address configured!")
        elif not EDUtilsPath.getEdnaSite().startswith("ESRF"):
            EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.sendEmail: Not executed at the ESRF! EDNA_SITE=%s" % EDUtilsPath.getEdnaSite())
        else:
            try:
                EDVerbose.DEBUG("Sending message to %s." % self.__strEDNAContactEmail)
                EDVerbose.DEBUG("Message: %s" % _strMessage)
                strMessage = """
EDNA_HOME = %s
EDNA_SITE = %s
PLUGIN_NAME = %s
working_dir = %s
%s

""" % (EDUtilsPath.getEdnaHome(), EDUtilsPath.getEdnaSite(), self.getPluginName(), self.getWorkingDirectory(), _strMessage)
                strEmailMsg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s" % (self.__strEDNAEmailSender, \
                                                                                self.__strEDNAContactEmail, \
                                                                                _strSubject, strMessage))
                server = smtplib.SMTP("localhost")
                server.sendmail(self.__strEDNAEmailSender, self.__strEDNAContactEmail, strEmailMsg)
                server.quit()
            except:
                EDVerbose.DEBUG("Error when sending email message!")
                EDVerbose.writeErrorTrace()
    def sendEmail(self, _strSubject, _strMessage):
        """Sends an email to the EDNA contact person (if configured)."""

        EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.sendEmail: Subject = %s" % _strSubject)
        EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.sendEmail: Message:")
        EDVerbose.DEBUG(_strMessage)
        if self.__strEDNAContactEmail == None:
            EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.sendEmail: No email address configured!")
        elif not EDUtilsPath.getEdnaSite().startswith("ESRF"):
            EDVerbose.DEBUG("EDPluginControlInterfaceToMXCuBEv1_2.sendEmail: Not executed at the ESRF! EDNA_SITE=%s" % EDUtilsPath.getEdnaSite())
        else:
            try:
                EDVerbose.DEBUG("Sending message to %s." % self.__strEDNAContactEmail)
                EDVerbose.DEBUG("Message: %s" % _strMessage)
                strMessage = """
EDNA_HOME = %s
EDNA_SITE = %s
PLUGIN_NAME = %s
working_dir = %s
%s

""" % (EDUtilsPath.getEdnaHome(), EDUtilsPath.getEdnaSite(), self.getPluginName(), self.getWorkingDirectory(), _strMessage)
                strEmailMsg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s" % (self.__strEDNAEmailSender, \
                                                                                self.__strEDNAContactEmail, \
                                                                                _strSubject, strMessage))
                server = smtplib.SMTP("localhost")
                server.sendmail(self.__strEDNAEmailSender, self.__strEDNAContactEmail, strEmailMsg)
                server.quit()
            except:
                EDVerbose.DEBUG("Error when sending email message!")
                EDVerbose.writeErrorTrace()
Exemplo n.º 4
0
    def processKernel(self):
        """
        Executes the test case.
        """
        EDVerbose.DEBUG("EDTestCase.processKernel")
        EDVerbose.screen()
        EDVerbose.unitTest(
            "==================================================================="
        )
        if self.getTestSuiteName() is not None:
            EDVerbose.unitTest("TEST SUITE : %s" % self.getTestSuiteName())
        EDVerbose.unitTest("TEST CASE  : %s" % self.getClassName())
        EDVerbose.unitTest(" ")
        if self.__strReasonForNotBeingExecuted == "":
            self.setTimeInit()
            iNumberMethods = self.getNumberOfTests()
            EDVerbose.unitTest("Total number of tests : %d" % iNumberMethods)
            EDVerbose.unitTest()
            iTestCaseNumber = 0
            if self.getListTest() == []:
                self.__strReasonForNotBeingExecuted = "No test methods!"
            else:
                for pyTestMethod in self.getListTest():
                    iTestCaseNumber = iTestCaseNumber + 1
                    strMethodName = EDUtilsTest.patchMethodName(pyTestMethod)
                    EDVerbose.unitTest(
                        "-------------------------------------------------------------------"
                    )
                    EDVerbose.unitTest("Test case method : %s" % strMethodName)
                    EDVerbose.unitTest()
                    try:
                        pyTestMethod()
                        self.__iNumberTestMethodSuccess += 1
                        EDVerbose.unitTest("%s executed with SUCCESS" %
                                           strMethodName)
                        EDVerbose.unitTest()

                    except AssertionError as pyException:
                        self.__dictMethodFailureMessages[strMethodName] = str(
                            pyException)
                        self.__iNumberTestMethodFailure += 1
                        EDVerbose.unitTest("Assertion Error Raised!")
                        EDVerbose.unitTest("%s executed with FAILURE" %
                                           strMethodName)
                        EDVerbose.unitTest()

                    except Exception as pyException:
                        self.__dictMethodFailureMessages[strMethodName] = str(
                            pyException)
                        self.__iNumberTestMethodFailure += 1
                        EDVerbose.unitTest("Unexpected Error!")
                        EDVerbose.unitTest("%s executed with FAILURE" %
                                           strMethodName)
                        EDVerbose.unitTest()
                        EDVerbose.writeErrorTrace()
                        EDVerbose.unitTest()
                self.__bIsExecuted = True
                self.setTimeEnd()
Exemplo n.º 5
0
    def processKernel(self):
        """
        Executes the test case.
        """
        EDVerbose.DEBUG("EDTestCase.processKernel")
        EDVerbose.screen()
        EDVerbose.unitTest("===================================================================")
        if self.getTestSuiteName() is not None:
            EDVerbose.unitTest("TEST SUITE : %s" % self.getTestSuiteName())
        EDVerbose.unitTest("TEST CASE  : %s" % self.getClassName())
        EDVerbose.unitTest(" ")
        if self.__strReasonForNotBeingExecuted == "":
            self.setTimeInit()
            iNumberMethods = self.getNumberOfTests()
            EDVerbose.unitTest("Total number of tests : %d" % iNumberMethods)
            EDVerbose.unitTest()
            iTestCaseNumber = 0
            if self.getListTest() == []:
                self.__strReasonForNotBeingExecuted = "No test methods!"
            else:
                for pyTestMethod in self.getListTest():
                    iTestCaseNumber = iTestCaseNumber + 1
                    strMethodName = EDUtilsTest.patchMethodName(pyTestMethod)
                    EDVerbose.unitTest("-------------------------------------------------------------------")
                    EDVerbose.unitTest("Test case method : %s" % strMethodName)
                    EDVerbose.unitTest()
                    try:
                        pyTestMethod()
                        self.__iNumberTestMethodSuccess += 1
                        EDVerbose.unitTest("%s executed with SUCCESS" % strMethodName)
                        EDVerbose.unitTest()

                    except AssertionError, pyException:
                        self.__dictMethodFailureMessages[strMethodName] = str(pyException)
                        self.__iNumberTestMethodFailure += 1
                        EDVerbose.unitTest("Assertion Error Raised!")
                        EDVerbose.unitTest("%s executed with FAILURE" % strMethodName)
                        EDVerbose.unitTest()

                    except Exception, pyException:
                        self.__dictMethodFailureMessages[strMethodName] = str(pyException)
                        self.__iNumberTestMethodFailure += 1
                        EDVerbose.unitTest("Unexpected Error!")
                        EDVerbose.unitTest("%s executed with FAILURE" % strMethodName)
                        EDVerbose.unitTest()
                        EDVerbose.writeErrorTrace()
                        EDVerbose.unitTest()
                self.__bIsExecuted = True
                self.setTimeEnd()
Exemplo n.º 6
0
 def failurePluginExecution(self, _edObject=None):
     """
     Method called when the execution of the plugin failed 
     """
     self.synchronizeOn()
     self.__status = EDJob.PLUGIN_STATE_FAILURE
     EDVerbose.screen("Plugin %s execution ended with failure" % self.__jobId)
     self.synchronizeOff()
     try:
         self.__edSlotFAILURE.call(self.__jobId)
     except Exception:
         EDVerbose.ERROR("Error in execution of Failure call-back for %s" % self.__jobId)
         EDVerbose.writeErrorTrace()
     try:
         self.__edSlotCallBack.call(self.__jobId)
     except Exception:
         EDVerbose.ERROR("Error in execution of Common call-back (after failure) for %s" % self.__jobId)
         EDVerbose.writeErrorTrace()
Exemplo n.º 7
0
 def successPluginExecution(self, _edObject=None):
     """
     Method called when the execution of the plugin succeeds 
     """
     self.synchronizeOn()
     self.__status = EDJob.PLUGIN_STATE_SUCCESS
     EDVerbose.screen("Plugin %s execution ended with success" % self.__jobId)
     self.synchronizeOff()
     try:
         self.__edSlotSUCCESS.call(self.__jobId)
     except Exception:
         EDVerbose.ERROR("Error in execution of Success call-back for %s" % self.__jobId)
         EDVerbose.writeErrorTrace()
     try:
         self.__edSlotCallBack.call(self.__jobId)
     except Exception:
         EDVerbose.ERROR("Error in execution of Common call-back (after success) for %s" % self.__jobId)
         EDVerbose.writeErrorTrace()
Exemplo n.º 8
0
    def executePluginSynchronous(self, _edPlugin):
        """
        This method is used to start executable plugins in pipeline synchronously.
        """
        _edControlSlotSUCCESS = EDSlot()
        _edControlSlotFAILURE = EDSlot()

        map(_edControlSlotSUCCESS.connect,
            _edPlugin.getSlotSUCCESS().getListMethod())
        map(_edControlSlotFAILURE.connect,
            _edPlugin.getSlotFAILURE().getListMethod())

        _edPlugin.getSlotSUCCESS().emptyListMethod()
        _edPlugin.getSlotFAILURE().emptyListMethod()

        _edPlugin.executeSynchronous()

        if (not _edPlugin.isFailure()):
            EDVerbose.DEBUG("EDControlPlugin.executeSynchronous slotSUCCESS")
            # Check that something doesn't go wrong in the success method!
            try:
                _edControlSlotSUCCESS.call(_edPlugin)

            except Exception:
                EDVerbose.DEBUG(
                    "EDControlPlugin.executeSynchronous: ERROR in slotSUCCESS!"
                )
                EDVerbose.writeErrorTrace()
                _edPlugin.setFailure()

        if (_edPlugin.isFailure()):
            EDVerbose.DEBUG("EDControlPlugin.executeSynchronous slotFAILURE")
            # Check that something doesn't go wrong in the success method!
            try:
                _edControlSlotFAILURE.call(_edPlugin)

            except Exception:
                EDVerbose.DEBUG(
                    "EDControlPlugin.executeSynchronous: ERROR in slotFAILURE!"
                )
                EDVerbose.writeErrorTrace()
Exemplo n.º 9
0
 def failurePluginExecution(self, _edObject=None):
     """
     Method called when the execution of the plugin failed 
     """
     self.synchronizeOn()
     self.__status = EDJob.PLUGIN_STATE_FAILURE
     EDVerbose.screen("Plugin %s execution ended with failure" %
                      self.__jobId)
     self.synchronizeOff()
     try:
         self.__edSlotFAILURE.call(self.__jobId)
     except Exception:
         EDVerbose.ERROR("Error in execution of Failure call-back for %s" %
                         self.__jobId)
         EDVerbose.writeErrorTrace()
     try:
         self.__edSlotCallBack.call(self.__jobId)
     except Exception:
         EDVerbose.ERROR(
             "Error in execution of Common call-back (after failure) for %s"
             % self.__jobId)
         EDVerbose.writeErrorTrace()
Exemplo n.º 10
0
 def successPluginExecution(self, _edObject=None):
     """
     Method called when the execution of the plugin succeeds 
     """
     self.synchronizeOn()
     self.__status = EDJob.PLUGIN_STATE_SUCCESS
     EDVerbose.screen("Plugin %s execution ended with success" %
                      self.__jobId)
     self.synchronizeOff()
     try:
         self.__edSlotSUCCESS.call(self.__jobId)
     except Exception:
         EDVerbose.ERROR("Error in execution of Success call-back for %s" %
                         self.__jobId)
         EDVerbose.writeErrorTrace()
     try:
         self.__edSlotCallBack.call(self.__jobId)
     except Exception:
         EDVerbose.ERROR(
             "Error in execution of Common call-back (after success) for %s"
             % self.__jobId)
         EDVerbose.writeErrorTrace()
Exemplo n.º 11
0
from XSDataHDF5v1_0             import XSDataInputHDF5Writer
from EDFactoryPluginStatic      import EDFactoryPluginStatic
architecture = EDUtilsPlatform.architecture
numpyPath = os.path.join(os.environ["EDNA_HOME"], "edna-libraries", "20090405-Numpy-1.3", architecture)
h5pyPath = os.path.join(os.environ["EDNA_HOME"], "edna-libraries", "H5Py-1.3.0", architecture)
fabioPath = os.path.join(os.environ["EDNA_HOME"], "edna-libraries", "FabIO-0.0.7", architecture)
imagingPath = os.path.join(os.environ["EDNA_HOME"], "edna-libraries", "20091115-PIL-1.1.7", architecture)

numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath, _strMethodVersion="__version__")
h5py = EDFactoryPluginStatic.preImport("h5py", h5pyPath, _strMethodVersion="version.api_version", _strForceVersion="1.8")
Image = EDFactoryPluginStatic.preImport("Image", imagingPath, _strMethodVersion="VERSION")
fabio = EDFactoryPluginStatic.preImport("fabio", fabioPath, _strMethodVersion="version")

if h5py is None:
    EDVerbose.error("h5py is None ... please investigate why !!!")
    EDVerbose.writeErrorTrace()
#    raise ImportError("EDPluginHDF5 cannot work without h5py !!!")


if "EDNA_SITE" not in os.environ:
    os.environ["EDNA_SITE"] = "edna-site"


class EDPluginHDF5(EDPluginExec):
    """
    This is a common part for all EDNA plugin writing HDF5. most methods are class methods 
    """
    __semCls = threading.Semaphore()
    __dictHDF5 = {} #key: filename, value: hdf5 h5py objects
    __dictLock = {} #key: filename, value:semaphores for writing
    __bConfigured = False
Exemplo n.º 12
0
                                        numpyPath,
                                        _strMethodVersion="__version__")
h5py = EDFactoryPluginStatic.preImport("h5py",
                                       h5pyPath,
                                       _strMethodVersion="version.api_version",
                                       _strForceVersion="1.8")
Image = EDFactoryPluginStatic.preImport("Image",
                                        imagingPath,
                                        _strMethodVersion="VERSION")
fabio = EDFactoryPluginStatic.preImport("fabio",
                                        fabioPath,
                                        _strMethodVersion="version")

if h5py is None:
    EDVerbose.error("h5py is None ... please investigate why !!!")
    EDVerbose.writeErrorTrace()
#    raise ImportError("EDPluginHDF5 cannot work without h5py !!!")

if "EDNA_SITE" not in os.environ:
    os.environ["EDNA_SITE"] = "edna-site"


class EDPluginHDF5(EDPlugin):
    """
    This is a common part for all EDNA plugin writing HDF5. most methods are class methods 
    """
    __semCls = Semaphore()
    __dictHDF5 = {}  #key: filename, value: hdf5 h5py objects
    __dictLock = {}  #key: filename, value:semaphores for writing
    __bConfigured = False
    HDF5_Multifiles = False