def main():

    try: 
        parser = MyOptParser()
        parser.add_argument("-p","--processFile", dest="processFile", default="" ,
                help="""Json file with process description.""", metavar="<path>", required=True)    
        
        
        opts= AttrMap(vars(parser.parse_args()))
          
        if(opts.processFile):
            
            processFile = cF.jsonLoad(opts.processFile);

            # load process module/class
            mod, ProcessClass = iH.importClassFromModule( **processFile["processClass"] )

            process = ProcessClass( processFile, jobGenModules = {"importHelpers":iH, "commonFunctions" : cF} )
            process.doProcessing()
           
        return 0
            
    except Exception as e:
        sys.stdout.flush()
        print("====================================================================", file=sys.stderr)
        print("Exception occured here: " + str(e), file=sys.stderr)
        print("====================================================================", file=sys.stderr)
        traceback.print_exc(file=sys.stderr)
        return 1
Example #2
0
    def writeTemplates(self , generator, configDicts ):

        # iterate over all template strings
        for k,templ in self.cTemplates.items():
            
            # get output file
            outFile = self.cTemplatesOut[k]
            
            # interprete the string as a json string if the first character is a {
            # { "inputFile" : "?" , "outputFile": "??" , "configurator" : "??" }
            # otherwise it is intrepreted as a inputFile which is configurated with the standart 
            # configurator which replaces strings and the output goes into the Job:scriptDir
            # where the file is made executable
            templ = templ.strip()
            
            configurator = None
            
            if templ and templ[0] == "{":
                templ = cF.jsonParse(templ)
                
                settings = {}
                if "settings" in templ:
                    settings = templ["settings"]
                
                inFile = templ["inputFile"]
                configurator = templ["configurator"] # jobConfigurator.generatorRigidBody.adjuster or what ever
                # only load each configurator once
                configuratorHash = self.makeConfiguratorHash(**configurator)
                
                 # load the special configurator if not loaded yet
                if configuratorHash not in self.templateConfigurators:
                    
                    print("Instantiate configurator: " , configurator )
                    moduleType, classType = iH.importClassFromModule(**configurator)
                    self.templateConfigurators[configuratorHash] = classType({"commonFunctions":cF,"importHelpers":iH}) # make instance (hand over modules)

                configuratorFunc = self.templateConfigurators[configuratorHash];
                
                # configure file
                configuratorFunc(generator, inFile, outFile, self.configDict, configDicts, **settings )
                
            else:
                # use standart dictionary adjuster as default
                inFile = templ
                #configure file
                self.defaultTemplateConfigurator(generator,inFile, outFile, self.configDict, configDicts, verbose=self.cCluster.verbose, makeExecutable=True)