Beispiel #1
0
 def testReadConfig(self):
     modelFile = 'resources/configurations/java_bean_example.json'
     modelFileExists = os.path.isfile(modelFile)
     self.assertTrue('model file exists: ' + modelFile, modelFileExists)
     modelDictArray = getParsedSchemaFromJson(modelFile)
     configJob = config.Job(modelDictArray[0])
     self.assertIsNotNone(configJob)
Beispiel #2
0
def getJobConfigurationsFromConfigFile(configFile,
                                       additionalVarsDict={},
                                       jobsToInclude=[],
                                       tasksToInclude=[]):
    if not doesFileExist(configFile):
        printError('\ncan not find config file: {}'.format(configFile))
        return []
    configurations = None
    if configFile.endswith('.json'):
        with open(configFile) as configFileContent:
            configurations = json.load(configFileContent)
    elif configFile.endswith('.yaml') or configFile.endswith('.yaml'):
        with open(configFile) as configFileContent:
            configurations = yaml.load(configFileContent)
    else:
        printError(
            '\nunknown config file extension, only json or yaml are supportted'
        )
        return []
    jobArray = []
    for conf in configurations:
        job = config.Job(conf)
        if (len(jobsToInclude) > 0) and (job.name not in jobsToInclude):
            continue
        __removeUndesiredTasksIfNeeded(tasksToInclude, job)
        jobArray.append(job)
    __replaceEnvVars(jobArray, additionalVarsDict)
    return jobArray
Beispiel #3
0
def _getJobConfigurationsFromArgs(args):
    job = config.Job()
    job.name = 'default'
    _putArgModelsToJob(args, job)
    templateParameters = _getTemplateParameters(args)
    blackList = __blackWhiteListEntries2Objects(args.blackListed)
    whiteList = __blackWhiteListEntries2Objects(args.whiteListed)
    __getSingleFileTemplates(args, job, templateParameters, blackList,
                             whiteList)
    __getMultiFileTemplates(args, job, templateParameters, blackList,
                            whiteList)
    return [job]
Beispiel #4
0
def _getJobConfigurationsFromArgs(args):
    job = config.Job()
    job.name = 'default'
    for modelFile in args.models:
        model = config.Model()
        model.schema = modelFile
        job.models.append(model)
    templateParameters = _getTemplateParameters(args)
    blackList = __blackWhiteListEntries2Objects(args.blackListed)
    whiteList = __blackWhiteListEntries2Objects(args.whiteListed)
    __getSingleFileTemplates(args, job, templateParameters, blackList,
                             whiteList)
    __getMultiFileTemplates(args, job, templateParameters, blackList,
                            whiteList)
    return [job]
Beispiel #5
0
def getJobConfigurationsFromConfigFile(configFile, additionalVarsDict={}):
    if not doesFileExist(configFile):
        printError('\ncan not find config file: {}'.format(configFile))
        return []
    configurations = None
    if configFile.endswith('.json'):
        with open(configFile) as configFileContent:
            configurations = json.load(configFileContent)
    elif configFile.endswith('.yaml') or configFile.endswith('.yaml'):
        with open(configFile) as configFileContent:
            configurations = yaml.load(configFileContent)
    else:
        printError('\nunknown config file extension, only json or yaml are supportted')
        return []
    jobArray = []
    for conf in configurations:
        job = config.Job(conf)
        jobArray.append(job)
    __replaceEnvVars(jobArray, additionalVarsDict)
    return jobArray