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()
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)
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)
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()
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)
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)
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)
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)
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()
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)
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()
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)
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)
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)
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)
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)
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)
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")