def __init__(self): EDLogging.__init__(self) strEdnaHome = EDUtilsPath.EDNA_HOME # Default plugin root directory: $EDNA_HOME self.__listPluginRootDirectory = [ strEdnaHome ] self.__dictModuleLocation = None self.__strPathToModuleCache = None
def __init__(self, _strPluginName, _functXMLin, \ _functXMLout=None, _functXMLerr=None, \ _iNbThreads=None, _fDelay=1.0, _bVerbose=None, _bDebug=None): """ This is the constructor of the edna plugin launcher. @param _strPluginName: the name of the ENDA plugin @type _strPluginName: python string @param _functXMLin: a function taking a path in input and returning the XML string for input in the EDNA plugin. @type _functXMLin: python function @param _functXMLOut: a function to be called each time a plugin gas finished his job sucessfully, it should take two option: strXMLin an strXMLout @type _functXMLOut: python function @param _functXMLErr: a function to be called each time a plugin gas finished his job and crashed, it should take ONE option: strXMLin @type _functXMLErr: python function @param _iNbThreads: The number of parallel threads to be used by EDNA, usually the number of Cores of the computer. If 0 or None, the number of cores will be auto-detected. @type _iNbThreads: python integer @param _fDelay: The delay in seconds between two directories analysis @type _fDelay: python float @param _bVerbose: Do you want the EDNA plugin execution to be verbose ? @type _bVerbose: boolean @param _bDebug: Do you want EDNA plugin execution debug output (OBS! very verbose) ? @type _bDebug: boolean """ EDLogging.__init__(self) self.__iNbThreads = EDUtilsParallel.detectNumberOfCPUs(_iNbThreads) EDUtilsParallel.initializeNbThread(self.__iNbThreads) ################################################################################ # #We are not using the one from EDUtilsParallel to leave it to control the number of execPlugins. ################################################################################ self.__semaphoreNbThreads = Semaphore(self.__iNbThreads) self.__strPluginName = _strPluginName self.__functXMLin = _functXMLin self.__functXMLout = _functXMLout self.__functXMLerr = _functXMLerr self.__strCurrWorkDir = os.getcwd() self.__strTempDir = None self.__listInputPaths = [] self.__dictCurrentlyRunning = {} if _bVerbose is not None: if _bVerbose: self.setVerboseDebugOn() else: self.setVerboseOff() if _bDebug is not None: if _bDebug: self.setVerboseDebugOn() else: self.setVerboseDebugOff() self.__fDelay = _fDelay #default delay between two directory checks. self.__bQuit = False # To check if we should quit the application self.__bIsFirstExecute = True signal.signal(signal.SIGTERM, self.handleKill) signal.signal(signal.SIGINT, self.handleKill)
def __init__(self, _strFileName=None): """"Set up semaphore for thread safeness and dictionary for config files""" EDLogging.__init__(self) self._dictConfigurationFiles = {} self._dictPluginConfiguration = {} if _strFileName is not None: self.addConfigurationFile(_strFileName)
def __init__(self, _strPluginName): """ Constructor of the class @param strPluginName: name of the plugin @type strPluginName: string """ EDLogging.__init__(self) self.__strPluginName = _strPluginName self.__edPlugin = None self.__edSlotCallBack = EDSlot() self.__edSlotSUCCESS = EDSlot() self.__edSlotFAILURE = EDSlot() self.__pathXSDInput = None self.__pathXSDOutput = None self.__bXmlInputSet = False self.__status = None self.__name = None self.__runtime = None self.__edPlugin = EDJob.__edFactoryPlugin.loadPlugin( self.__strPluginName) if self.__edPlugin is None: raise RuntimeError("Unable to create plugin %s" % self.__strPluginName) self.__jobId = "%s-%08i" % (self.__strPluginName, self.__edPlugin.getId()) with self.__class__.__semaphore: self.__class__.__dictJobs[self.__jobId] = self if (self.__edPlugin is None): self.WARNING("Instantiation of plugin %s failed!!!" % _strPluginName) else: self.__status = EDJob.PLUGIN_STATE_UNITIALIZED
def __init__(self, _strPluginName): """ Constructor of the class @param strPluginName: name of the plugin @type strPluginName: string """ EDLogging.__init__(self) self.__strPluginName = _strPluginName self.__edPlugin = None self.__edSlotCallBack = EDSlot() self.__edSlotSUCCESS = EDSlot() self.__edSlotFAILURE = EDSlot() self.__pathXSDInput = None self.__pathXSDOutput = None self.__bXmlInputSet = False self.__status = None self.__name = None self.__runtime = None self.__edPlugin = EDJob.__edFactoryPlugin.loadPlugin(self.__strPluginName) if self.__edPlugin is None: raise RuntimeError("Unable to create plugin %s" % self.__strPluginName) self.__jobId = "%s-%08i" % (self.__strPluginName, self.__edPlugin.getId()) with self.__class__.__semaphore: self.__class__.__dictJobs[self.__jobId] = self if (self.__edPlugin is None): self.WARNING("Instantiation of plugin %s failed!!!" % _strPluginName) else: self.__status = EDJob.PLUGIN_STATE_UNITIALIZED
def __init__(self): EDLogging.__init__(self) #EDSession is a static class self._backend = BACKEND self._filename = None self._storage = None self._listKeys = []
def __init__(self): EDLogging.__init__(self) # Default plugin root directory: $EDNA_HOME self.__listPluginRootDirectory = [EDUtilsPath.EDNA_HOME] for oneProjectDir in EDUtilsPath._EDNA_PROJECTS.values(): if os.path.isdir(oneProjectDir): self.__listPluginRootDirectory.append(os.path.abspath(oneProjectDir)) self.__dictModuleLocation = None
def __init__(self): EDLogging.__init__(self) #EDSession is a static class self._backend = BACKEND self._filename = None self._storage = None self._listKeys = [] self._dictAttrs = {} #attr are metadata associated to an entry. The values are always cached
def __init__(self): EDLogging.__init__(self) #EDSession is a static class self._backend = BACKEND self._filename = None self._storage = None self._listKeys = [] self._dictAttrs = { } #attr are metadata associated to an entry. The values are always cached
def __init__(self, _strModuleName, _strMethodVersion=None): EDLogging.__init__(self) self.DEBUG("EDModule.__init__ on %s" % _strModuleName) self.__name = _strModuleName self.__module = None self.__path = None self.__dictSubModules = {} self.__version = None self.__strMethodVersion = _strMethodVersion
def __init__(self, _strTestName="Test"): EDLogging.__init__(self) if _strTestName is None: self.__strTestName = self.getClassName() else: self.__strTestName = _strTestName self.__listTest = [] self.__bIsVerbose = False self.__bIsDebug = False self.__bIsAssert = False self.__bIsLogFile = False self.__bIsProfile = False
def __init__(self, code=None, comment=None, \ maskFile=None, normalization=None, imageSize=None, detector="pilatus", detectorDistance=None, pixelSize_1=None, pixelSize_2=None, beamCenter_1=None, beamCenter_2=None, wavelength=None,): EDLogging.__init__(self) self.comment = comment self.code = code self.maskFile = maskFile self.normalization = normalization self.detector = detector self.detectorDistance = detectorDistance if (detector == "pilatus") and (pixelSize_1 is None) and (pixelSize_2 is None): self.pixelSize_1 = 1.72e-4 self.pixelSize_2 = 1.72e-4 else: self.pixelSize_1 = pixelSize_1 self.pixelSize_2 = pixelSize_2 if (detector == "pilatus") and (beamCenter_1 is None): self.imageSize = 4000000 else: self.imageSize = imageSize self.beamCenter_1 = beamCenter_1 self.beamCenter_2 = beamCenter_2 self.wavelength = wavelength self.timeStamp = time.strftime("-%Y%m%d%H%M%S", time.localtime()) self.dest1D = "1d" + self.timeStamp self.dest2D = "2d" + self.timeStamp self.destMisc = "misc" + self.timeStamp self.sample = XSDataBioSaxsSample() if code is not None: self.sample.code = XSDataString(code) if comment is not None: self.sample.comment = XSDataString(comment) self.experimentSetup = XSDataBioSaxsExperimentSetup() if self.detector: self.experimentSetup.detector = XSDataString(self.detector) if self.detectorDistance: self.experimentSetup.detectorDistance = XSDataLength( self.detectorDistance) if self.pixelSize_1: self.experimentSetup.pixelSize_1 = XSDataLength(self.pixelSize_1) if self.pixelSize_2: self.experimentSetup.pixelSize_2 = XSDataLength(self.pixelSize_2) if self.beamCenter_1: self.experimentSetup.beamCenter_1 = XSDataDouble(self.beamCenter_1) if self.beamCenter_2: self.experimentSetup.beamCenter_2 = XSDataDouble(self.beamCenter_2) if self.wavelength: self.experimentSetup.wavelength = XSDataWavelength(self.wavelength)
def __init__(self, cl, name): EDLogging.__init__(self) PyTango.Device_4Impl.__init__(self, cl, name) self.init_device() if isinstance(iNbCpu, int): self.screen("Initializing tangoDS with max %i jobs in parallel." % iNbCpu) self.__semaphoreNbThreads = threading.Semaphore(iNbCpu) else: self.__semaphoreNbThreads = threading.Semaphore(EDUtilsParallel.detectNumberOfCPUs()) self.jobQueue = Queue() self.processingSem = threading.Semaphore() self.statLock = threading.Lock() self.lastStatistics = "No statistics collected yet, please use the 'collectStatistics' method first" self.lastFailure = "No job Failed (yet)" self.lastSuccess = "No job succeeded (yet)"
def __init__(self, code=None, comment=None, \ maskFile=None, normalization=None, imageSize=None, detector="pilatus", detectorDistance=None, pixelSize_1=None, pixelSize_2=None, beamCenter_1=None, beamCenter_2=None, wavelength=None,): EDLogging.__init__(self) self.comment = comment self.code = code self.maskFile = maskFile self.normalization = normalization self.detector = detector self.detectorDistance = detectorDistance if (detector == "pilatus") and (pixelSize_1 is None) and (pixelSize_2 is None): self.pixelSize_1 = 1.72e-4 self.pixelSize_2 = 1.72e-4 else: self.pixelSize_1 = pixelSize_1 self.pixelSize_2 = pixelSize_2 if (detector == "pilatus") and (beamCenter_1 is None) : self.imageSize = 4000000 else: self.imageSize = imageSize self.beamCenter_1 = beamCenter_1 self.beamCenter_2 = beamCenter_2 self.wavelength = wavelength self.timeStamp = time.strftime("-%Y%m%d%H%M%S", time.localtime()) self.dest1D = "1d" + self.timeStamp self.dest2D = "2d" + self.timeStamp self.destMisc = "misc" + self.timeStamp self.sample = XSDataBioSaxsSample() if code is not None: self.sample.code = XSDataString(code) if comment is not None: self.sample.comment = XSDataString(comment) self.experimentSetup = XSDataBioSaxsExperimentSetup() if self.detector: self.experimentSetup.detector = XSDataString(self.detector) if self.detectorDistance: self.experimentSetup.detectorDistance = XSDataLength(self.detectorDistance) if self.pixelSize_1: self.experimentSetup.pixelSize_1 = XSDataLength(self.pixelSize_1) if self.pixelSize_2: self.experimentSetup.pixelSize_2 = XSDataLength(self.pixelSize_2) if self.beamCenter_1: self.experimentSetup.beamCenter_1 = XSDataDouble(self.beamCenter_1) if self.beamCenter_2: self.experimentSetup.beamCenter_2 = XSDataDouble(self.beamCenter_2) if self.wavelength: self.experimentSetup.wavelength = XSDataWavelength(self.wavelength)
def __init__(self, cl, name): EDLogging.__init__(self) PyTango.Device_4Impl.__init__(self, cl, name) self.init_device() if isinstance(iNbCpu, int): self.screen("Initializing tangoDS with max %i jobs in parallel." % iNbCpu) self.__semaphoreNbThreads = threading.Semaphore(iNbCpu) else: self.__semaphoreNbThreads = threading.Semaphore( EDUtilsParallel.detectNumberOfCPUs()) self.jobQueue = Queue() self.processingSem = threading.Semaphore() self.statLock = threading.Lock() self.lastStatistics = "No statistics collected yet, please use the 'collectStatistics' method first" self.lastFailure = "No job Failed (yet)" self.lastSuccess = "No job succeeded (yet)"
def __init__(self, strPluginName, iNbCpu=None): EDLogging.__init__(self) self.pluginName = strPluginName self.startTime = time.time() try: self.iNbCpu = int(iNbCpu) except: self.iNbCpu = EDUtilsParallel.detectNumberOfCPUs() self.screen("Initializing Reprocess with max %i jobs in parallel." % self.iNbCpu) self.__semaphoreNbThreads = Semaphore(self.iNbCpu) EDUtilsParallel.initializeNbThread(self.iNbCpu) self.jobQueue = Queue() self.processingSem = Semaphore() self.statLock = Semaphore() self.lastStatistics = "No statistics collected yet, please use the 'collectStatistics' method first" self.lastFailure = "No job Failed (yet)" self.lastSuccess = "No job succeeded (yet)"
def __init__(self): EDLogging.__init__(self) Thread.__init__(self) self.__edSlotPreProcess = EDSlot() self.__edSlotProcess = EDSlot() self.__edSlotPostProcess = EDSlot() self.__edSlotSUCCESS = EDSlot() self.__edSlotFAILURE = EDSlot() self.__edSlotFinallyProcess = EDSlot() self.__bIsFailure = False self.__bIsTimeOut = False self.__fTimeOutInSeconds = None self.__fDefaultTimeOutInSeconds = 600.0 self.__bIsAbort = False # Reference to the object which calls execute or executeSynchronous self.__edObject = None self.__lExtraTime = [] # list of extra allowed time for execution (in second) self.__bLogTiming = False
def __init__(self, cl, name): EDLogging.__init__(self) PyTango.Device_4Impl.__init__(self, cl, name) self.init_device() if isinstance(iNbCpu, int): self.screen("Initializing tangoDS with max %i jobs in parallel." % iNbCpu) self.__semaphoreNbThreads = threading.Semaphore(iNbCpu) else: self.__semaphoreNbThreads = threading.Semaphore(EDUtilsParallel.detectNumberOfCPUs()) self.quit = False self.jobQueue = Queue() # queue containing jobs to process self.eventQueue = Queue() # queue containing finished jobs self.statLock = threading.Lock() self.lastStatistics = "No statistics collected yet, please use the 'collectStatistics' method first" self.lastFailure = "No job Failed (yet)" self.lastSuccess = "No job succeeded (yet)" self.processingThread = threading.Thread(target=self.startProcessing) self.processingThread.start() self.finishingThread = threading.Thread(target=self.process_event) self.finishingThread.start()
class EDVerbose(object): """ This class is meant to be used statically for all logging purposes in the EDNA framework. All methods are thread safe. """ __edLogging = EDLogging() def setTestOn(): """ turn on the test mode: all assertions become verbose (->screen) """ EDVerbose.__edLogging.setTestOn() setTestOn = staticmethod(setTestOn) def setTestOff(): """ turn off the test mode: all assertions become silent (->screen) """ EDVerbose.__edLogging.setTestOff() setTestOff = staticmethod(setTestOff) def setVerboseOn(): """ This method turns on verbose logging to standard output (stdout) """ EDVerbose.__edLogging.setVerboseOn() setVerboseOn = staticmethod(setVerboseOn) def setVerboseOff(): """ This method turns off verbose logging to standard output (stdout) """ EDVerbose.__edLogging.setVerboseOff() setVerboseOff = staticmethod(setVerboseOff) def setVerboseDebugOn(): """ This method turns on debug messages to standard output and log file """ EDVerbose.__edLogging.setVerboseDebugOn() setVerboseDebugOn = staticmethod(setVerboseDebugOn) def setVerboseDebugOff(): """ This method turns off debug messages to standard output and log file """ EDVerbose.__edLogging.setVerboseDebugOff() setVerboseDebugOff = staticmethod(setVerboseDebugOff) def isVerboseDebug(): """ This method returns the current status of debugging @return: if debug output to standard output and log file is enabled. @type: boolean """ return EDVerbose.__edLogging.isVerboseDebug() isVerboseDebug = staticmethod(isVerboseDebug) def log(_strMessage=""): """ This method writes a message only to the log file. @param _strMessage: The string to be written to the log file @type _strMessage: python string """ EDVerbose.__edLogging.log(_strMessage) log = staticmethod(log) def screen(_strMessage=""): """ This method writes a message to standard output and to the log file. @param _strMessage: The string to be written to the log file @type _strMessage: python string """ EDVerbose.__edLogging.screen(_strMessage) screen = staticmethod(screen) def DEBUG(_strDebugMessage=""): """ This method writes a debug message to standard output and to the log file if debugging is enabled. The message will be written with the prefix [DEBUG] @param _strDebugMessage: The debug message to be written to standard output and log file @type _strDebugMessage: python string """ EDVerbose.__edLogging.DEBUG(_strDebugMessage) DEBUG = staticmethod(DEBUG) def unitTest(_strMessage=""): """ This method is meant to be used by the testing framework. The message will be written to standard output and the log file with the prefix [UnitTest] @param _strMessage: The message to be written to standard output and log file @type _strMessage: python string """ EDVerbose.__edLogging.unitTest(_strMessage) unitTest = staticmethod(unitTest) def ERROR(_strMessage=""): """ This method writes a message to standard error and the log file with the prefix [ERROR]. @param _strMessage: The error message to be written to standard output and log file @type _strMessage: python string """ EDVerbose.__edLogging.ERROR(_strMessage) ERROR = staticmethod(ERROR) def error(_strMessage=""): """ This method writes a message to standard error and the log file with the prefix [ERROR]. @param _strMessage: The error message to be written to standard output and log file @type _strMessage: python string """ EDVerbose.__edLogging.error(_strMessage) error = staticmethod(error) def WARNING(_strMessage=""): """ This method writes a warning message to standard output and the log file with the prefix [Warning]. @param _strMessage: The error message to be written to standard output and log file @type _strMessage: python string """ EDVerbose.__edLogging.WARNING(_strMessage) WARNING = staticmethod(WARNING) def warning(_strMessage=""): """ This method writes a warning message to standard output and the log file with the prefix [Warning]. @param _strMessage: The error message to be written to standard output and log file @type _strMessage: python string """ EDVerbose.__edLogging.warning(_strMessage) warning = staticmethod(warning) def ASSERT(_strMessage): """ This method writes an assert message to standard output and the log file with the prefix [ASSERT]. @param _strMessage: The error message to be written to standard output and log file @type _strMessage: python string """ EDVerbose.__edLogging.ASSERT(_strMessage) ASSERT = staticmethod(ASSERT) def writeErrorTrace(_strPrefix=" "): """ This method writes an error trace to standard output and the log file. The error trace has the same formatting as normal Python error traces. @param _strPrefix: A prefix which can be customized, e.g. the testing framework uses ' [UnitTest]' @type _strPrefix: python string """ EDVerbose.__edLogging.writeErrorTrace(_strPrefix) writeErrorTrace = staticmethod(writeErrorTrace) def getLogFileName(): """ @return: the path to the current log file. @type: string """ return EDVerbose.__edLogging.getLogFileName() getLogFileName = staticmethod(getLogFileName) def setLogFileName(_strLogFileName): """ This method can be used for customising the file name of the log file. @param _strLogFileName: A file name for the log file. @type _strLogFileName: python string """ EDVerbose.__edLogging.setLogFileName(_strLogFileName) setLogFileName = staticmethod(setLogFileName) def setLogFileOff(): """ This method turns off output to the log file. """ EDVerbose.__edLogging.setLogFileOff() setLogFileOff = staticmethod(setLogFileOff)