Exemplo n.º 1
0
class EnkfPrototype(Prototype):
    lib = ert.load("libenkf")

    def __init__(self, prototype, bind=True):
        super(EnkfPrototype, self).__init__(EnkfPrototype.lib,
                                            prototype,
                                            bind=bind)
Exemplo n.º 2
0
class _TestSpawnPrototype(Prototype):
    lib = ert.load('libert_util')

    def __init__(self, prototype, bind=True):
        super(_TestSpawnPrototype, self).__init__(_TestSpawnPrototype.lib,
                                                  prototype,
                                                  bind=bind)
Exemplo n.º 3
0
    def __init__(self, ert, function_name, argument_types, argument_count):
        super(FunctionErtScript, self).__init__(ert)

        lib = ert_module.load(None)
        wrapper = CWrapper(lib)

        parsed_argument_types = []

        if ert is not None:
            self.__function = wrapper.prototype("c_void_p %s(c_void_p, stringlist)" % function_name)

        else:
            for arg in argument_types:
                if arg is bool:
                    parsed_argument_types.append("bool")
                elif arg is str:
                    parsed_argument_types.append("char*")
                elif arg is int:
                    parsed_argument_types.append("int")
                elif arg is float:
                    parsed_argument_types.append("float")
                else:
                    raise TypeError("Unknown type: %s" % arg)

            self.__function = wrapper.prototype("c_void_p %s(%s)" % (function_name, ", ".join(parsed_argument_types[:argument_count])))
Exemplo n.º 4
0
class TestUtilPrototype(Prototype):
    lib = ert.load("libert_util")

    def __init__(self, prototype, bind=False):
        super(TestUtilPrototype, self).__init__(TestUtilPrototype.lib,
                                                prototype,
                                                bind=bind)
Exemplo n.º 5
0
class ConfigPrototype(Prototype):
    lib = ert.load("libconfig")

    def __init__(self, prototype, bind=True):
        super(ConfigPrototype, self).__init__(ConfigPrototype.lib,
                                              prototype,
                                              bind=bind)
Exemplo n.º 6
0
class SchedulePrototype(Prototype):
    lib = ert.load("libsched")

    def __init__(self, prototype, bind=True):
        super(SchedulePrototype, self).__init__(SchedulePrototype.lib,
                                                prototype,
                                                bind=bind)
Exemplo n.º 7
0
class QueuePrototype(Prototype):
    lib = ert.load("libjob_queue")

    def __init__(self, prototype, bind=True):
        super(QueuePrototype, self).__init__(QueuePrototype.lib,
                                             prototype,
                                             bind=bind)
Exemplo n.º 8
0
class UtilPrototype(Prototype):
    lib = ert.load("libert_util")

    def __init__(self, prototype, bind=True):
        super(UtilPrototype, self).__init__(UtilPrototype.lib,
                                            prototype,
                                            bind=bind)
Exemplo n.º 9
0
class TestConfigPrototype(Prototype):
    lib = ert.load("libconfig")

    def __init__(self, prototype, bind=False):
        super(TestConfigPrototype, self).__init__(TestConfigPrototype.lib,
                                                  prototype,
                                                  bind=bind)
Exemplo n.º 10
0
class GeoPrototype(Prototype):
    lib = ert.load("libert_geometry")

    def __init__(self, prototype, bind=True):
        super(GeoPrototype, self).__init__(GeoPrototype.lib,
                                           prototype,
                                           bind=bind)
Exemplo n.º 11
0
class _TestWorkflowJobPrototype(Prototype):
    lib = ert.load('libjob_queue')

    def __init__(self, prototype, bind=True):
        super(_TestWorkflowJobPrototype,
              self).__init__(_TestWorkflowJobPrototype.lib,
                             prototype,
                             bind=bind)
Exemplo n.º 12
0
def setenv(var, value):
    if not os.getenv(var):
        os.environ[var] = value


# Set up the full LSF environment - based onf LSF_HOME
LSF_HOME = os.getenv("LSF_HOME")
if LSF_HOME:
    setenv("LSF_BINDIR", "%s/bin" % LSF_HOME)
    setenv("LSF_LIBDIR", "%s/lib" % LSF_HOME)
    setenv("XLSF_UIDDIR", "%s/lib/uid" % LSF_HOME)
    setenv("LSF_SERVERDIR", "%s/etc" % LSF_HOME)
    setenv("LSF_ENVDIR",
           "%s/conf" % LSF_HOME)  # This is wrong: Statoil: /prog/LSF/conf

JOB_QUEUE_LIB = ert.load("libjob_queue")


class QueuePrototype(Prototype):
    lib = ert.load("libjob_queue")

    def __init__(self, prototype, bind=True):
        super(QueuePrototype, self).__init__(QueuePrototype.lib,
                                             prototype,
                                             bind=bind)


#from .job_status_type_enum import JobStatusType
from .job_status_type_enum import JobStatusType
from .job import Job
from .queue import JobQueue
Exemplo n.º 13
0
import ert.ecl
import ert.rms
import ert.analysis
import ert.sched
import ert.config
import ert.job_queue

class EnkfPrototype(Prototype):
    lib = ert.load("libenkf")

    def __init__(self, prototype, bind=True):
        super(EnkfPrototype, self).__init__(EnkfPrototype.lib, prototype, bind=bind)

        

ENKF_LIB = ert.load("libenkf")

from .enums import *

from .node_id import NodeId

from .enkf_linalg import EnkfLinalg
from .util import TimeMap
from .state_map import StateMap
from .summary_key_set import SummaryKeySet
from .summary_key_matcher import SummaryKeyMatcher
from .custom_kw_config_set import CustomKWConfigSet
from .enkf_fs import EnkfFs

from .ert_workflow_list import ErtWorkflowList
from .active_list import ActiveList
Exemplo n.º 14
0
class _NonePrototype(Prototype):
    lib = ert_module.load(None)

    def __init__(self, prototype, bind=True):
        super(_NonePrototype, self).__init__(_NonePrototype.lib, prototype, bind=bind)
Exemplo n.º 15
0
import ert
import ert.util
import ert.geo
import ert.ecl

RMS_LIB = ert.load("librms")
Exemplo n.º 16
0
import ctypes
import ert
from ert.test import ExtendedTestCase
from ert.util import CThreadPool, startCThreadPool

TEST_LIB = ert.load("libtest_util")


class CThreadPoolTest(ExtendedTestCase):
    def test_cfunc(self):
        with self.assertRaises(TypeError):
            func = CThreadPool.lookupCFunction("WRONG-TYPE",
                                               "no-this-does-not-exist")

        with self.assertRaises(AttributeError):
            func = CThreadPool.lookupCFunction(TEST_LIB,
                                               "no-this-does-not-exist")

    def test_create(self):
        pool = CThreadPool(32, start=True)
        job = CThreadPool.lookupCFunction(TEST_LIB, "thread_pool_test_func1")
        arg = ctypes.c_int(0)

        N = 256
        for i in range(N):
            pool.addTask(job, ctypes.byref(arg))
        pool.join()
        self.assertEqual(arg.value, N)

    def test_context(self):
        N = 256
Exemplo n.º 17
0
import ert
from cwrap import clib, CWrapper
from ert.enkf.data.enkf_node import EnkfNode
from ert.enkf.node_id import NodeId
from ert.test import ErtTestContext
from ert.test.extended_testcase import ExtendedTestCase
from ert.util import BoolVector

test_lib = ert.load("libenkf")
cwrapper = CWrapper(test_lib)


class GenDataTest(ExtendedTestCase):
    def setUp(self):
        self.config_file = self.createTestPath(
            "Statoil/config/with_GEN_DATA/config")

    def test_create(self):
        with ErtTestContext("gen_data_test", self.config_file) as test_context:
            ert = test_context.getErt()
            fs1 = ert.getEnkfFsManager().getCurrentFileSystem()
            config_node = ert.ensembleConfig().getNode("TIMESHIFT")

            data_node = EnkfNode(config_node)
            data_node.tryLoad(fs1, NodeId(60, 0))

            gen_data = data_node.asGenData()
            data = gen_data.getData()

            self.assertEqual(len(data), 2560)
Exemplo n.º 18
0
import ert
from ert_gui.shell import ErtShellCollection
from ert_gui.shell.libshell import splitArguments, getPossibleFilenameCompletions, extractFullArgument

import ctypes
import os

NO_SORT = 0
STRING_SORT = 1
OFFSET_SORT = 2

import cwrap.clib as clib
UTIL_LIB = ert.load("libert_util")

UTIL_LIB.block_fs_is_mount.restype = ctypes.c_bool
UTIL_LIB.block_fs_mount.restype = ctypes.c_void_p
UTIL_LIB.block_fs_alloc_filelist.restype = ctypes.c_void_p
UTIL_LIB.block_fs_close.restype = ctypes.c_void_p

UTIL_LIB.vector_get_size.restype = ctypes.c_int
UTIL_LIB.vector_iget_const.restype = ctypes.c_void_p
UTIL_LIB.vector_free.restype = ctypes.c_void_p

UTIL_LIB.user_file_node_get_filename.restype = ctypes.c_char_p
UTIL_LIB.user_file_node_get_data_size.restype = ctypes.c_int
UTIL_LIB.user_file_node_get_node_offset.restype = ctypes.c_long


class Storage(ErtShellCollection):
    def __init__(self, parent):
        super(Storage, self).__init__("storage", parent)
Exemplo n.º 19
0
import ctypes
import ert
from ert.test import ExtendedTestCase
from ert.util import CThreadPool, startCThreadPool

TEST_LIB = ert.load("libert_util")


class CThreadPoolTest(ExtendedTestCase):
    def test_cfunc(self):
        with self.assertRaises(TypeError):
            func = CThreadPool.lookupCFunction("WRONG-TYPE", "no-this-does-not-exist")

        with self.assertRaises(AttributeError):
            func = CThreadPool.lookupCFunction(TEST_LIB, "no-this-does-not-exist")

    def test_create(self):
        pool = CThreadPool(32, start=True)
        job = CThreadPool.lookupCFunction(TEST_LIB, "thread_pool_test_func1")
        arg = ctypes.c_int(0)

        N = 256
        for i in range(N):
            pool.addTask(job, ctypes.byref(arg))
        pool.join()
        self.assertEqual(arg.value, N)

    def test_context(self):
        N = 256
        arg = ctypes.c_int(0)
        job = CThreadPool.lookupCFunction(TEST_LIB, "thread_pool_test_func1")
Exemplo n.º 20
0
import ert
import ert.util
import ert.geo
import ert.ecl

ECL_WELL_LIB = ert.load("libecl_well")

from .well_type_enum import WellTypeEnum
from .well_connection_direction_enum import WellConnectionDirectionEnum
from .well_connection import WellConnection
from .well_segment import WellSegment
from .well_state import WellState
from .well_time_line import WellTimeLine
from .well_info import WellInfo
Exemplo n.º 21
0
from cwrap import Prototype

def setenv( var, value):
    if not os.getenv(var):
        os.environ[var] = value

# Set up the full LSF environment - based onf LSF_HOME
LSF_HOME = os.getenv("LSF_HOME")
if LSF_HOME:
    setenv("LSF_BINDIR", "%s/bin" % LSF_HOME)
    setenv("LSF_LIBDIR", "%s/lib" % LSF_HOME)
    setenv("XLSF_UIDDIR", "%s/lib/uid" % LSF_HOME)
    setenv("LSF_SERVERDIR", "%s/etc" % LSF_HOME)
    setenv("LSF_ENVDIR", "%s/conf" % LSF_HOME)   # This is wrong: Statoil: /prog/LSF/conf

JOB_QUEUE_LIB = ert.load("libjob_queue")

class QueuePrototype(Prototype):
    lib = ert.load("libjob_queue")

    def __init__(self, prototype, bind=True):
        super(QueuePrototype, self).__init__(QueuePrototype.lib, prototype, bind=bind)

    
#from .job_status_type_enum import JobStatusType
from .job_status_type_enum import JobStatusType
from .job import Job
from .queue import JobQueue
from .job_queue_manager import JobQueueManager
from .driver import QueueDriverEnum, Driver, LSFDriver, RSHDriver, LocalDriver
from .ext_job import ExtJob
Exemplo n.º 22
0
import ert
from cwrap import CWrapper
from ert.job_queue import WorkflowJob
from ert.test import TestAreaContext, ExtendedTestCase
from .workflow_common import WorkflowCommon

test_lib = ert.load("libjob_queue")  # create a local namespace
cwrapper = CWrapper(test_lib)

alloc_config = cwrapper.prototype("c_void_p workflow_job_alloc_config()")
alloc_from_file = cwrapper.prototype(
    "workflow_job_obj workflow_job_config_alloc(char*, c_void_p, char*)")


class WorkflowJobTest(ExtendedTestCase):
    def test_workflow_job_creation(self):
        workflow_job = WorkflowJob("Test")

        self.assertTrue(workflow_job.isInternal())
        self.assertEqual(workflow_job.name(), "Test")

    def test_read_internal_function(self):
        with TestAreaContext("python/job_queue/workflow_job") as work_area:
            WorkflowCommon.createInternalFunctionJob()
            WorkflowCommon.createErtScriptsJob()

            config = alloc_config()
            workflow_job = alloc_from_file("SELECT_CASE", config,
                                           "select_case_job")

            self.assertEqual(workflow_job.name(), "SELECT_CASE")
Exemplo n.º 23
0
class AnalysisPrototype(Prototype):
    lib = ert.load("libanalysis")

    def __init__(self, prototype, bind=True):
        super(AnalysisPrototype, self).__init__(AnalysisPrototype.lib, prototype, bind=bind)
Exemplo n.º 24
0
#  (at your option) any later version.
#
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.
#
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.
import ert
import ert.ecl
import ert.util
import ert.geo

from cwrap import Prototype


class SchedulePrototype(Prototype):
    lib = ert.load("libsched")

    def __init__(self, prototype, bind=True):
        super(SchedulePrototype, self).__init__(SchedulePrototype.lib,
                                                prototype,
                                                bind=bind)


SCHED_LIB = ert.load("libsched")

from .sched_file import SchedFile
from .history_source_enum import HistorySourceEnum
from .history import History
Exemplo n.º 25
0
import ctypes
import ert
from ert.test import ExtendedTestCase
from ert.util import CThreadPool, startCThreadPool

TEST_LIB = ert.load("libtest_util")


class CThreadPoolTest(ExtendedTestCase):
    def test_cfunc(self):
        with self.assertRaises(TypeError):
            func = CThreadPool.lookupCFunction("WRONG-TYPE", "no-this-does-not-exist")

        with self.assertRaises(AttributeError):
            func = CThreadPool.lookupCFunction(TEST_LIB, "no-this-does-not-exist")

    def test_create(self):
        pool = CThreadPool(32, start=True)
        job = CThreadPool.lookupCFunction(TEST_LIB, "thread_pool_test_func1")
        arg = ctypes.c_int(0)

        N = 256
        for i in range(N):
            pool.addTask(job, ctypes.byref(arg))
        pool.join()
        self.assertEqual(arg.value, N)

    def test_context(self):
        N = 256
        arg = ctypes.c_int(0)
        job = CThreadPool.lookupCFunction(TEST_LIB, "thread_pool_test_func1")
Exemplo n.º 26
0
#  it under the terms of the GNU General Public License as published by 
#  the Free Software Foundation, either version 3 of the License, or 
#  (at your option) any later version. 
#   
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY 
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or 
#  FITNESS FOR A PARTICULAR PURPOSE.   
#   
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> 
#  for more details. 


import ert
from cwrap import Prototype
import ert.util

class AnalysisPrototype(Prototype):
    lib = ert.load("libanalysis")

    def __init__(self, prototype, bind=True):
        super(AnalysisPrototype, self).__init__(AnalysisPrototype.lib, prototype, bind=bind)



ANALYSIS_LIB = ert.load("libanalysis")

from .enums import AnalysisModuleOptionsEnum, AnalysisModuleLoadStatusEnum

from .analysis_module import AnalysisModule
from .linalg import Linalg
Exemplo n.º 27
0
class WellPrototype(Prototype):
    lib = ert.load("libecl_well")

    def __init__(self, prototype, bind=True):
        super(WellPrototype, self).__init__(WellPrototype.lib, prototype, bind=bind)
Exemplo n.º 28
0
import ctypes
import ert
from cwrap import CWrapper
from ert.ecl import EclKW, EclFile, EclTypeEnum, FortIO
from ert.test import ExtendedTestCase, TestAreaContext
from ert.util import IntVector

ecl_lib = ert.load("libecl")
ecl_wrapper = CWrapper(ecl_lib)

freadIndexedData = ecl_wrapper.prototype(
    "void ecl_kw_fread_indexed_data(fortio, int, int, int, int_vector, char*)"
)  # fortio, offset, type, count, index_map, buffer
eclFileIndexedRead = ecl_wrapper.prototype(
    "void ecl_file_indexed_read(ecl_file, char*, int, int_vector, char*)"
)  # ecl_file, kw, index, index_map, buffer


class EclIndexedReadTest(ExtendedTestCase):
    def test_ecl_kw_indexed_read(self):
        with TestAreaContext("ecl_kw_indexed_read") as area:
            fortio = FortIO("index_test", mode=FortIO.WRITE_MODE)

            element_count = 100000
            ecl_kw = EclKW.create("TEST", element_count,
                                  EclTypeEnum.ECL_INT_TYPE)

            for index in range(element_count):
                ecl_kw[index] = index

            ecl_kw.fwrite(fortio)
Exemplo n.º 29
0
import ert
from ert.test import ExtendedTestCase
from ert.util import ArgPack, StringList

TEST_LIB = ert.load("libert_util")


class ArgPackTest(ExtendedTestCase):
    def test_create(self):
        arg = ArgPack()
        self.assertEqual(len(arg), 0)

        arg.append(StringList())
        self.assertEqual(len(arg), 1)

        arg.append(3.14)
        self.assertEqual(len(arg), 2)

        o = object()
        with self.assertRaises(TypeError):
            arg.append(o)

    def test_args(self):
        arg = ArgPack(1, 2, 3)
        self.assertEqual(len(arg), 3)

    def test_append_ptr(self):
        arg = ArgPack(StringList())
        self.assertEqual(len(arg), 1)

        func = getattr(TEST_LIB, "test_argpack_is_stringlist")
Exemplo n.º 30
0
import ert
from cwrap import clib, CWrapper
from ert.enkf.data import EnkfNode
from ert.enkf.config import GenDataConfig
from ert.enkf import NodeId
from ert.enkf import ForwardLoadContext
from ert.test import ErtTestContext, ExtendedTestCase
from ert.util import BoolVector

test_lib = ert.load("libenkf")
cwrapper = CWrapper(test_lib)

get_active_mask = cwrapper.prototype("bool_vector_ref gen_data_config_get_active_mask( gen_data_config )")
update_active_mask = cwrapper.prototype(
    "void gen_data_config_update_active( gen_data_config, forward_load_context , bool_vector)"
)

alloc_run_arg = cwrapper.prototype("run_arg_obj run_arg_alloc_ENSEMBLE_EXPERIMENT( enkf_fs , int , int , char*) ")


def updateMask(gen_data_config, report_step, fs, active_mask):
    run_arg = alloc_run_arg(fs, 0, 0, "Path")
    load_context = ForwardLoadContext(run_arg=run_arg, report_step=report_step)
    update_active_mask(gen_data_config, load_context, active_mask)


class GenDataConfigTest(ExtendedTestCase):
    def setUp(self):
        self.config_file = self.createTestPath("Statoil/config/with_GEN_DATA/config")

    def load_active_masks(self, case1, case2):
Exemplo n.º 31
0
import ert
import ert.util
import ert.geo
import ert.ecl

ECL_WELL_LIB = ert.load("libecl_well")


from .well_type_enum import WellTypeEnum
from .well_connection_direction_enum import WellConnectionDirectionEnum
from .well_connection import WellConnection
from .well_segment import WellSegment
from .well_state import WellState
from .well_time_line import WellTimeLine
from .well_info  import WellInfo
Exemplo n.º 32
0
#
#  ERT is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  ERT is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.
#
#  See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
#  for more details.
import ert
import ert.ecl
import ert.util
import ert.geo

from cwrap import Prototype

class SchedulePrototype(Prototype):
    lib = ert.load("libsched")

    def __init__(self, prototype, bind=True):
        super(SchedulePrototype, self).__init__(SchedulePrototype.lib, prototype, bind=bind)

SCHED_LIB = ert.load("libsched")

from .sched_file import SchedFile
from .history_source_enum import HistorySourceEnum
from .history import History
Exemplo n.º 33
0
import ctypes
import ert
from cwrap import CWrapper
from ert.ecl import EclKW, EclFile, EclTypeEnum, FortIO
from ert.test import ExtendedTestCase, TestAreaContext
from ert.util import IntVector


ecl_lib = ert.load("libecl")
ecl_wrapper = CWrapper(ecl_lib)


freadIndexedData = ecl_wrapper.prototype("void ecl_kw_fread_indexed_data(fortio, int, int, int, int_vector, char*)") # fortio, offset, type, count, index_map, buffer
eclFileIndexedRead = ecl_wrapper.prototype("void ecl_file_indexed_read(ecl_file, char*, int, int_vector, char*)") # ecl_file, kw, index, index_map, buffer


class EclIndexedReadTest(ExtendedTestCase):
    def test_ecl_kw_indexed_read(self):
        with TestAreaContext("ecl_kw_indexed_read") as area:
            fortio = FortIO("index_test", mode=FortIO.WRITE_MODE)

            element_count = 100000
            ecl_kw = EclKW.create("TEST", element_count, EclTypeEnum.ECL_INT_TYPE)

            for index in range(element_count):
                ecl_kw[index] = index

            ecl_kw.fwrite(fortio)

            fortio.close()
Exemplo n.º 34
0
from os import path, symlink, remove

import ert
from cwrap import CWrapper
from ert.test import ExtendedTestCase, TestAreaContext,ErtTestContext
from ert.enkf import RunpathList, RunpathNode
from ert.util import BoolVector

test_lib  = ert.load("libenkf") # create a local namespace
cwrapper =  CWrapper(test_lib)

runpath_list_alloc = cwrapper.prototype("runpath_list_obj runpath_list_alloc(char*)")

class RunpathListTest(ExtendedTestCase):

    def test_runpath_list(self):
        runpath_list = runpath_list_alloc("")
        """ @type runpath_list: RunpathList """

        self.assertEqual(len(runpath_list), 0)

        test_runpath_nodes = [RunpathNode(0, 0, "runpath0", "basename0"), RunpathNode(1, 0, "runpath1", "basename0")]

        runpath_node = test_runpath_nodes[0]
        runpath_list.add(runpath_node.realization, runpath_node.iteration, runpath_node.runpath, runpath_node.basename)

        self.assertEqual(len(runpath_list), 1)
        self.assertEqual(runpath_list[0], test_runpath_nodes[0])

        runpath_node = test_runpath_nodes[1]
        runpath_list.add(runpath_node.realization, runpath_node.iteration, runpath_node.runpath, runpath_node.basename)
Exemplo n.º 35
0
from os import path, symlink, remove

import ert
from cwrap import CWrapper
from ert.test import ExtendedTestCase, TestAreaContext, ErtTestContext
from ert.enkf import RunpathList, RunpathNode
from ert.util import BoolVector

test_lib = ert.load("libenkf")  # create a local namespace
cwrapper = CWrapper(test_lib)

runpath_list_alloc = cwrapper.prototype(
    "runpath_list_obj runpath_list_alloc(char*)")


class RunpathListTest(ExtendedTestCase):
    def test_runpath_list(self):
        runpath_list = runpath_list_alloc("")
        """ @type runpath_list: RunpathList """

        self.assertEqual(len(runpath_list), 0)

        test_runpath_nodes = [
            RunpathNode(0, 0, "runpath0", "basename0"),
            RunpathNode(1, 0, "runpath1", "basename0")
        ]

        runpath_node = test_runpath_nodes[0]
        runpath_list.add(runpath_node.realization, runpath_node.iteration,
                         runpath_node.runpath, runpath_node.basename)
Exemplo n.º 36
0
class TestPrototype(Prototype):
    lib = ert.load("libert_util")

    def __init__(self, prototype):
        super(TestPrototype, self).__init__(self.lib, prototype)
Exemplo n.º 37
0
import ert
from ert_gui.shell import ErtShellCollection
from ert_gui.shell.libshell import splitArguments, getPossibleFilenameCompletions, extractFullArgument


import ctypes
import os

NO_SORT = 0
STRING_SORT = 1
OFFSET_SORT = 2

import cwrap.clib as clib
UTIL_LIB = ert.load("libert_util")

UTIL_LIB.block_fs_is_mount.restype = ctypes.c_bool
UTIL_LIB.block_fs_mount.restype = ctypes.c_void_p
UTIL_LIB.block_fs_alloc_filelist.restype = ctypes.c_void_p
UTIL_LIB.block_fs_close.restype = ctypes.c_void_p

UTIL_LIB.vector_get_size.restype = ctypes.c_int
UTIL_LIB.vector_iget_const.restype = ctypes.c_void_p
UTIL_LIB.vector_free.restype = ctypes.c_void_p

UTIL_LIB.user_file_node_get_filename.restype = ctypes.c_char_p
UTIL_LIB.user_file_node_get_data_size.restype = ctypes.c_int
UTIL_LIB.user_file_node_get_node_offset.restype = ctypes.c_long

class Storage(ErtShellCollection):
    def __init__(self, parent):
        super(Storage, self).__init__("storage", parent)
Exemplo n.º 38
0
import ctypes
import ert
from cwrap import CWrapper, BaseCClass, CWrapError
from ert.test  import ExtendedTestCase

test_lib  = ert.load("libert_util") # create a local namespace (so we don't overwrite StringList)
cwrapper =  CWrapper(test_lib)

class StringListTest(BaseCClass):
    def __init__(self):
        c_pointer = self.cNamespace().alloc()
        super(StringListTest, self).__init__(c_pointer)

    def free(self):
        StringListTest.cNamespace().free(self)

CWrapper.registerObjectType("stringlisttest", StringListTest)

StringListTest.cNamespace().alloc = cwrapper.prototype("c_void_p stringlist_alloc_new( )")
StringListTest.cNamespace().free  = cwrapper.prototype("void stringlist_free(stringlisttest )")


class CWrapTest(ExtendedTestCase):

    def test_return_type(self):
        stringlist_alloc = cwrapper.prototype("c_void_p stringlist_alloc_new( )")
        string_list1 = StringListTest()

        stringlist_alloc = cwrapper.prototype("stringlisttest_obj stringlist_alloc_new( )")
        string_list2 = stringlist_alloc()
Exemplo n.º 39
0
import ert
from cwrap import CWrapper
from ert.job_queue import WorkflowJob
from ert.test import TestAreaContext, ExtendedTestCase
from .workflow_common import WorkflowCommon

test_lib  = ert.load("libjob_queue") # create a local namespace
cwrapper =  CWrapper(test_lib)

alloc_config = cwrapper.prototype("c_void_p workflow_job_alloc_config()")
alloc_from_file = cwrapper.prototype("workflow_job_obj workflow_job_config_alloc(char*, c_void_p, char*)")

class WorkflowJobTest(ExtendedTestCase):

    def test_workflow_job_creation(self):
        workflow_job = WorkflowJob("Test")

        self.assertTrue(workflow_job.isInternal())
        self.assertEqual(workflow_job.name(), "Test")


    def test_read_internal_function(self):
        with TestAreaContext("python/job_queue/workflow_job") as work_area:
            WorkflowCommon.createInternalFunctionJob()
            WorkflowCommon.createErtScriptsJob()

            config = alloc_config()
            workflow_job = alloc_from_file("SELECT_CASE", config, "select_case_job")

            self.assertEqual(workflow_job.name(), "SELECT_CASE")
            self.assertTrue(workflow_job.isInternal())