Exemplo n.º 1
0
 def getCwd(cls):
     """
     Returns the current directory.
     Deprecated: please use 'os.getcwd' instead
     """
     EDVerbose.log("EDUtilsPath.getCwd is deprecated, please use 'os.getcwd' instead")
     return os.getcwd()
Exemplo n.º 2
0
 def existPath(cls, _strPath):
     """
     Checks if a folder exists.
     Deprecated: please use 'os.path.exists' instead
     """
     EDVerbose.log("EDUtilsPath.existPath is deprecated, please use 'os.path.exists' instead")
     return exists(_strPath)
Exemplo n.º 3
0
 def getAbsolutePath(cls, _strPath):
     """
     Returns the absolute path.
     Deprecated: please use 'os.path.abspath' instead
     """
     EDVerbose.log("EDUtilsPath.getAbsolutePath is deprecated, please use 'os.path.abspath' instead")
     return abspath(_strPath)
Exemplo n.º 4
0
 def getCwd(cls):
     """
     Returns the current directory.
     Deprecated: please use 'os.getcwd' instead
     """
     EDVerbose.log(
         "EDUtilsPath.getCwd is deprecated, please use 'os.getcwd' instead")
     return os.getcwd()
Exemplo n.º 5
0
 def mergePath(cls, _strPath1, _strPath2):
     """
     Merges two paths and returns the absolute path.
     Deprecated: please use 'os.path.join' instead
     """
     EDVerbose.log("EDUtilsPath.mergePath is deprecated, please use 'os.path.join' instead")
     strNewPath = os.path.join(_strPath1, _strPath2)
     return abspath(strNewPath)
Exemplo n.º 6
0
 def createFolder(cls, _strFolderName):
     """
     Creates a folder (directory) if it doesn't already exists.
     This used to be deprecated but IS neverthless thread safe (see bug#681)
     """
     EDVerbose.log("EDUtilsPath.createFolder: %s" % _strFolderName)
     with cls.__semaphore:
         if (not exists(_strFolderName)):
             os.makedirs(_strFolderName)
Exemplo n.º 7
0
 def existPath(cls, _strPath):
     """
     Checks if a folder exists.
     Deprecated: please use 'os.path.exists' instead
     """
     EDVerbose.log(
         "EDUtilsPath.existPath is deprecated, please use 'os.path.exists' instead"
     )
     return exists(_strPath)
Exemplo n.º 8
0
 def createFolder(cls, _strFolderName):
     """
     Creates a folder (directory) if it doesn't already exists.
     This used to be deprecated but IS neverthless thread safe (see bug#681)
     """
     EDVerbose.log("EDUtilsPath.createFolder: %s" % _strFolderName)
     with cls.__semaphore:
         if (not exists(_strFolderName)):
             os.makedirs(_strFolderName)
Exemplo n.º 9
0
 def getAbsolutePath(cls, _strPath):
     """
     Returns the absolute path.
     Deprecated: please use 'os.path.abspath' instead
     """
     EDVerbose.log(
         "EDUtilsPath.getAbsolutePath is deprecated, please use 'os.path.abspath' instead"
     )
     return abspath(_strPath)
Exemplo n.º 10
0
 def flushAll(cls):
     """
     Write down to the disk all HDF5 files under control.
     """
     with cls.__semCls:
         for filename in cls.__dictHDF5:
             EDVerbose.log("Flushing HDF5 buffer for " + filename)
             with cls.__dictLock[filename]:
                 cls.__dictHDF5[filename].attrs.create("file_update_time", cls.getIsoTime())
                 cls.__dictHDF5[filename].flush()
Exemplo n.º 11
0
 def mergePath(cls, _strPath1, _strPath2):
     """
     Merges two paths and returns the absolute path.
     Deprecated: please use 'os.path.join' instead
     """
     EDVerbose.log(
         "EDUtilsPath.mergePath is deprecated, please use 'os.path.join' instead"
     )
     strNewPath = os.path.join(_strPath1, _strPath2)
     return abspath(strNewPath)
Exemplo n.º 12
0
 def closeAll(cls):
     """
     Write down to the disk all the HDF5 file and close them all.
     """
     with cls.__semCls:
         for filename in cls.__dictHDF5.copy():
             EDVerbose.log("Closing HDF5 file " + filename)
             with cls.__dictLock.pop(filename):
                 hdf5File = cls.__dictHDF5.pop(filename)
                 hdf5File.attrs.create("file_update_time", cls.getIsoTime())
                 hdf5File.close()
Exemplo n.º 13
0
 def closeAll(cls):
     """
     Write down to the disk all the HDF5 file and close them all.
     """
     with cls.__semCls:
         for filename in cls.__dictHDF5.copy():
             EDVerbose.log("Closing HDF5 file " + filename)
             with cls.__dictLock.pop(filename):
                 hdf5File = cls.__dictHDF5.pop(filename)
                 hdf5File.attrs.create("file_update_time", cls.getIsoTime())
                 hdf5File.close()
Exemplo n.º 14
0
 def flush(cls, filename):
     """
     Write down to the disk the HDF5 file.
     
     @param filename: path of the file to be created
     @type filename: string
     """
     if cls.__dictHDF5.has_key(filename):
         EDVerbose.log("Flushing HDF5 buffer for " + filename)
         with cls.__dictLock[filename]:
             cls.__dictHDF5[filename].attrs.create("file_update_time", cls.getIsoTime())
             cls.__dictHDF5[filename].flush()
     else:
         EDVerbose.WARNING("HDF5 Flush: %s, no such file under control" % filename)
Exemplo n.º 15
0
 def kill(cls, _iPid):
     """
     implementation of a platform independent kill method 
     
     @param _iPid: process ID
     @type _iPid: integer
     """
     EDVerbose.log("EDUtilsPlatorm.kill called on PID: %s" % _iPid)
     if os.name == "posix": #python under unix
         os.killpg(_iPid, signal.SIGKILL)
     elif cls.architecture == "posix": #jython running under unix
         os.kill(_iPid, signal.SIGKILL)
     else: #windows, ... Nota: this only works from python2.7 under windows !
         EDVerbose.WARNING("Kill Called to PID= %s with signal %s" % (_iPid, signal.SIGTERM))
         os.kill(_iPid, signal.SIGTERM)
Exemplo n.º 16
0
 def close(cls, filename):
     """
     Write down to the disk the HDF5 file and close it.
     
     @param filename: path of the file to be created
     @type filename: string
     """
     if cls.__dictHDF5.has_key(filename):
         with cls.__semCls:
             EDVerbose.log("Closing HDF5 file " + filename)
             with cls.__dictLock.pop(filename):
                 hdf5File = cls.__dictHDF5.pop(filename)
                 hdf5File.attrs.create("file_update_time", cls.getIsoTime())
                 hdf5File.close()
     else:
         EDVerbose.WARNING("HDF5 Flush: %s, no such file under control" % filename)
Exemplo n.º 17
0
 def kill(cls, _iPid):
     """
     implementation of a platform independent kill method 
     
     @param _iPid: process ID
     @type _iPid: integer
     """
     EDVerbose.log("EDUtilsPlatorm.kill called on PID: %s" % _iPid)
     if os.name == "posix":  #python under unix
         os.killpg(_iPid, signal.SIGKILL)
     elif cls.architecture == "posix":  #jython running under unix
         os.kill(_iPid, signal.SIGKILL)
     else:  #windows, ... Nota: this only works from python2.7 under windows !
         EDVerbose.WARNING("Kill Called to PID= %s with signal %s" %
                           (_iPid, signal.SIGTERM))
         os.kill(_iPid, signal.SIGTERM)
Exemplo n.º 18
0
 def close(cls, filename):
     """
     Write down to the disk the HDF5 file and close it.
     
     @param filename: path of the file to be created
     @type filename: string
     """
     if cls.__dictHDF5.has_key(filename):
         with cls.__semCls:
             EDVerbose.log("Closing HDF5 file " + filename)
             with cls.__dictLock.pop(filename):
                 hdf5File = cls.__dictHDF5.pop(filename)
                 hdf5File.attrs.create("file_update_time", cls.getIsoTime())
                 hdf5File.close()
     else:
         EDVerbose.WARNING("HDF5 Flush: %s, no such file under control" %
                           filename)
Exemplo n.º 19
0
    def flushFile(cls, filename):
        """
        Write down to the disk the HDF5 file.
        
        @param filename: path of the file to be created
        @type filename: string
        """
        if filename in cls.__dictHDF5:
            EDVerbose.log("Flushing HDF5 buffer for " + filename)
            with cls.__dictLock[filename]:
                cls.__dictHDF5[filename].attrs.create("file_update_time", cls.getIsoTime())

                if h5py.version.api_version_tuple < (1, 10):
                    cls.__dictHDF5[filename].close()
                    cls.__dictHDF5[filename] = h5py.File(filename)
                else:
                    cls.__dictHDF5[filename].flush()
        else:
            EDVerbose.WARNING("HDF5 Flush: %s, no such file under control" % filename)
Exemplo n.º 20
0
    def flushFile(cls, filename):
        """
        Write down to the disk the HDF5 file.
        
        @param filename: path of the file to be created
        @type filename: string
        """
        if filename in cls.__dictHDF5:
            EDVerbose.log("Flushing HDF5 buffer for " + filename)
            with cls.__dictLock[filename]:
                cls.__dictHDF5[filename].attrs.create("file_update_time",
                                                      cls.getIsoTime())

                if h5py.version.api_version_tuple < (1, 10):
                    cls.__dictHDF5[filename].close()
                    cls.__dictHDF5[filename] = h5py.File(filename)
                else:
                    cls.__dictHDF5[filename].flush()
        else:
            EDVerbose.WARNING("HDF5 Flush: %s, no such file under control" %
                              filename)
Exemplo n.º 21
0
 def processCommandline(self):
     """
     This method is intended to be overridden by applications who
     would like to implement their own command line handling.
     
     This default method implements the following workflow:
         - Check for debug, verbose and log file command line options
     
     """
     EDVerbose.DEBUG("EDApplication.execute")
     EDVerbose.log(self.__edCommandLine.getCommandLine())
     self.processCommandLineDebugVerboseLogFile()
     # Determine the base directory
     if (self.__strBaseDir is None):
         self.processCommandLineBaseDirectory()
     # Set the name of the log file
     self.__strPathToLogFile = os.path.abspath(
         os.path.join(self.__strBaseDir, self.__strLogFileName))
     EDVerbose.setLogFileName(self.__strPathToLogFile)
     self.processCommandLineHelp()
     if (not self.__bIsFailure):
         self.processCommandLineVersion()
     if (not self.__bIsFailure):
         # Name of the plugin to be executed
         if (self.__strPluginName is None):
             self.processCommandLinePluginName()
         # Path to the input XML file
         if (self.__strDataInputFilePath is None):
             self.processCommandLineInputFilePath()
         # Path to the output XML file
         if (self.__strDataOutputFilePath is None):
             self.processCommandLineOutputFilePath()
         if (self.__bIsFailure):
             self.usage()
     if (not self.__bIsFailure):
         # If strConfigurationFileName is None, this means that it has not been given to the constructor\
         # It has been given by the command line\
         if (self.__strConfigurationFileName is None):
             self.__strConfigurationFileName = self.getCommandLineArgument(
                 EDApplication.CONFIGURATION_PARAM_LABEL)
Exemplo n.º 22
0
 def processCommandline(self):
     """
     This method is intended to be overridden by applications who
     would like to implement their own command line handling.
     
     This default method implements the following workflow:
         - Check for debug, verbose and log file command line options
     
     """
     EDVerbose.DEBUG("EDApplication.execute")
     EDVerbose.log(self.__edCommandLine.getCommandLine())
     self.processCommandLineDebugVerboseLogFile()
     # Determine the base directory
     if(self.__strBaseDir is None):
         self.processCommandLineBaseDirectory()
     # Set the name of the log file
     self.__strPathToLogFile = os.path.abspath(os.path.join(self.__strBaseDir, self.__strLogFileName))
     EDVerbose.setLogFileName(self.__strPathToLogFile)
     self.processCommandLineHelp()
     if (not self.__bIsFailure):
         self.processCommandLineVersion()
     if (not self.__bIsFailure):
         # Name of the plugin to be executed        
         if (self.__strPluginName is None):
             self.processCommandLinePluginName()
         # Path to the input XML file
         if (self.__strDataInputFilePath is None):
             self.processCommandLineInputFilePath()
         # Path to the output XML file
         if(self.__strDataOutputFilePath is None):
             self.processCommandLineOutputFilePath()
         if (self.__bIsFailure):
             self.usage()
     if (not self.__bIsFailure):
         # If strConfigurationFileName is None, this means that it has not been given to the constructor\
         # It has been given by the command line\
         if(self.__strConfigurationFileName is None):
             self.__strConfigurationFileName = self.getCommandLineArgument(EDApplication.CONFIGURATION_PARAM_LABEL)
Exemplo n.º 23
0
 def preProcess(self):
     """
     Scans the command line.
     """
     EDVerbose.DEBUG("EDTestLauncher.preProcess")
     edCommandLine = EDCommandLine(sys.argv)
     EDVerbose.log(self.getEdCommandLine().getCommandLine())
     self.processCommandLineDebugVerboseLogFile()
     bContinue = True
     strTestName = edCommandLine.getArgument(EDTestLauncher.TEST_LABEL)
     EDVerbose.DEBUG("EDTestLauncher.preProcess: test name = %r" % strTestName)
     if (strTestName is None):
         EDVerbose.screen("ERROR - no --test argument found")
         bContinue = False
     else:
         self.__edTestCase = EDUtilsTest.getFactoryPluginTest().loadPlugin(strTestName)
     if (bContinue):
         # Determine the base directory
         if(self.getBaseDir() is None):
             self.processCommandLineBaseDirectory()
         # Create the application working directory  
         strApplicationInstanceName = strTestName + "_" + time.strftime("%Y%m%d-%H%M%S", time.localtime())
         if(self.getWorkingDir() is None):
             self.setWorkingDir(strApplicationInstanceName)
         self.createApplicationWorkingDirectory()
         # Set the name of the log file
         EDVerbose.setLogFileName(os.path.join(self.getBaseDir(), strApplicationInstanceName + ".log"))
         # The check for --quiet and --DEBUG should ideally be placed elsewhere,
         # for example in EDApplication.
         if (edCommandLine.existCommand(EDTestLauncher.QUIET_LABEL)):
             EDVerbose.setVerboseOff()
             EDVerbose.setTestOff()
         if (edCommandLine.existCommand(EDApplication.DEBUG_PARAM_LABEL_1) or \
             edCommandLine.existCommand(EDApplication.DEBUG_PARAM_LABEL_2)):
             EDVerbose.setVerboseDebugOn()
             EDVerbose.DEBUG("EDTestLauncher.preProcess: Debug mode")