コード例 #1
0
def setProps(propsDict, className):
    """
    Adds to the passed dictionary, the properties to be passed to all java/scala
    executables.
    
    These properties are common to all IAS executables and can for example 
    be configuration properties.
    
    @param propsDict: A dictionary of properties in the form name:value
    @param className The name of the class to run 
    """
    # Environment variables
    propsDict["ias.root.folder"] = os.environ["IAS_ROOT"]
    propsDict["ias.logs.folder"] = os.environ["IAS_LOGS_FOLDER"]
    propsDict["ias.tmp.folder"] = os.environ["IAS_TMP_FOLDER"]
    propsDict["ias.logs.filename"] = className
    propsDict["ias.config.folder"] = os.environ["IAS_CONFIG_FOLDER"]

    # Set the config file for sl4j (defined in Logging)
    logbackConfigFileName = "logback.xml"
    fs = FileSupport(logbackConfigFileName, "config")
    try:
        path = fs.findFile()
        propsDict["logback.configurationFile"] = path
    except:
        print "No log4j config file (" + logbackConfigFileName + ") found: using defaults"
コード例 #2
0
def setProps(propsDict, className, logFileNameId):
    """
    Adds to the passed dictionary, the properties to be passed to all java/scala
    executables.

    These properties are common to all IAS executables and can for example
    be configuration properties.

    @param propsDict: A dictionary of properties in the form name:value
    @param className The name of the class to run
    @param logFileNameId A string identifier to append to the name of the log file
    """
    # Environment variables
    propsDict["ias.root.folder"] = os.environ["IAS_ROOT"]
    propsDict["ias.logs.folder"] = os.environ["IAS_LOGS_FOLDER"]
    propsDict["ias.tmp.folder"] = os.environ["IAS_TMP_FOLDER"]

    # The name of the host where the tool runs
    propsDict["ias.hostname"] = socket.gethostname()

    # get the name of the class without dots
    # i.e. if className = "org.eso.ias.supervisor.Supervisor" we want
    # the file to be named "Supervisor"
    if "scalatest" in className:
        # logs generated by scalatest are named "org.scalatest.run-2018-03-05T15-55-21.log"
        # so we catch this case here to have a more meaningful name then just "run"
        logFileName = "ScalaTest"
    else:
        temp = className.rsplit(".", 1)
        logFileName = temp[len(temp) - 1]

    # Append the log identifier if it has been passed in the command line
    if len(logFileNameId.strip()) > 0:
        logFileName = logFileName + "-" + logFileNameId.strip()
    propsDict["ias.logs.filename"] = logFileName

    propsDict["ias.config.folder"] = os.environ["IAS_CONFIG_FOLDER"]

    # Set the config file for sl4j (defined in Logging)
    logbackConfigFileName = "logback.xml"
    fs = FileSupport(logbackConfigFileName, "config")
    try:
        path = fs.findFile()
        propsDict["logback.configurationFile"] = path
    except:
        logger.info("No log4j config file (%s) found: using defaults",
                    logbackConfigFileName)

    # JVM always uses UTC
    propsDict["user.timezone"] = "UTC"
コード例 #3
0
def setProps(propsDict):
    """
    Define default properties to be passed to all java.scala executable.
    
    These properties are common to all IAS executables and can for example 
    be configuration properties.
    
    @param propsDict: A dictionary of properties in the form name:value
    @return: A dictionary properties like { "p1name":"p1value", "p2":"v2"}
    """
    # Environment variables
    propsDict["ias.root.folder"]=os.environ["IAS_ROOT"]
    propsDict["ias.logs.folder"]=os.environ["IAS_LOGS_FOLDER"]
    
    # Set the config file for sl4j (defined in Logging)
    logbackConfigFileName="logback.xml"
    fs = FileSupport(logbackConfigFileName,"config")
    try:
        path = fs.findFile()
        propsDict["logback.configurationFile"]=path
    except:
        print "No log4j config file ("+logbackConfigFileName+") found: using defaults"
コード例 #4
0
ファイル: testCreateModule.py プロジェクト: nicosingh/ias
 def testTemplateExists(self):
     fileSupport = FileSupport("FoldersOfAModule.template", "config")
     template = fileSupport.findFile()
     self.assertTrue(exists(template), "Template not found")
     self.assertTrue(isfile(template), "Template not file")
     self.assertTrue(access(template, R_OK), "Cannot read template file")
コード例 #5
0
    else:
        for opt in javaOptions:
            if verbose:
                print "Adding", opt, "java option"
            cmd.append(opt)

    # Is the environment ok?
    # Fail fast!
    if not CommonDefs.checkEnvironment():
        print "Some setting missing in IAS environment."
        print "Set the environment with ias-bash_profile before running IAS applications"
        print
        sys.exit(-1)

    # Create tmp and logs folders if not exists already
    FileSupport.createLogsFolder()
    FileSupport.createTmpFolder()

    # Add the properties
    #
    # Default and user defined properties are in a dictionary:
    # this way it is easy for the user to overrride default properties.
    props = {}
    setProps(props, args.className)
    if args.jProp is not None:
        addUserProps(props, args.jProp)
    if len(props) > 0:
        stingOfPros = formatProps(props)
        # Sort to enhance readability
        stingOfPros.sort()
        cmd.extend(formatProps(props))
コード例 #6
0
@author: acaproni
'''
import argparse
from IASTools.FileSupport import FileSupport

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Search for a file in the hierarchy of IAS folders.')
    parser.add_argument(
        '-t',
        '--type',
        help='The type of files to search for: '+str(FileSupport.iasFileType),
        dest="fileType",
        action='store',
        default=None)
    parser.add_argument(
        dest='fileName', 
        help='The name of the file to search for')
    args = parser.parse_args()
    
    try:
        if not args.fileType is None:
            fileSupport = FileSupport(args.fileName, args.fileType)
            filePath=fileSupport.findFile()
        else:
            fileSupport = FileSupport(args.fileName)
            filePath=fileSupport.findFile()
        print filePath
    except IOError as e:
        print "File not found"