Пример #1
0
    def run(self, ert, arguments, verbose=False):
        """
        @type ert: res.enkf.enkf_main.EnKFMain
        @type arguments: list of str
        @type verbose: bool
        @rtype: ctypes.c_void_p
        """
        self.__running = True

        min_arg = self.minimumArgumentCount()
        if min_arg > 0 and len(arguments) < min_arg:
            raise UserWarning(
                "The job: %s requires at least %d arguments, %d given." %
                (self.name(), min_arg, len(arguments)))

        max_arg = self.maximumArgumentCount()
        if 0 < max_arg < len(arguments):
            raise UserWarning(
                "The job: %s can only have %d arguments, %d given." %
                (self.name(), max_arg, len(arguments)))

        if self.isInternalScript():
            script_obj = ErtScript.loadScriptFromFile(
                self.getInternalScriptPath())
            self.__script = script_obj(ert)
            result = self.__script.initializeAndRun(self.argumentTypes(),
                                                    arguments,
                                                    verbose=verbose)

        elif self.isInternal() and not self.isInternalScript():
            self.__script = FunctionErtScript(ert,
                                              self.functionName(),
                                              self.argumentTypes(),
                                              argument_count=len(arguments))
            result = self.__script.initializeAndRun(self.argumentTypes(),
                                                    arguments,
                                                    verbose=verbose)

        elif not self.isInternal():
            self.__script = ExternalErtScript(ert, self.executable())
            result = self.__script.initializeAndRun(self.argumentTypes(),
                                                    arguments,
                                                    verbose=verbose)

        else:
            raise UserWarning("Unknown script type!")

        self.__running = False
        return result
Пример #2
0
 def __loadPlugin(self):
     """@rtype: ErtPlugin"""
     script_obj = ErtScript.loadScriptFromFile(
         self.__workflow_job.getInternalScriptPath())
     script = script_obj(self.__ert)
     return script
Пример #3
0
 def __loadPlugin(self):
     """ @rtype: ErtPlugin """
     script_obj = ErtScript.loadScriptFromFile(self.__workflow_job.getInternalScriptPath())
     script = script_obj(self.__ert)
     return script
Пример #4
0
 def getScript(self, plugin_job):
     script_obj = ErtScript.loadScriptFromFile(plugin_job.getInternalScriptPath())
     script = script_obj(self.ert())
     return script
Пример #5
0
 def getScript(self, plugin_job):
     script_obj = ErtScript.loadScriptFromFile(
         plugin_job.getInternalScriptPath())
     script = script_obj(self.ert())
     return script