Esempio n. 1
0
    def __init__(self, infile=None, files=None, machine=None):
        """
        initialize an object
        if a filename is provided it will be used,
        otherwise if a files object is provided it will be used
        otherwise create a files object from default values
        """

        self.machine_node = None
        self.machine = None
        self.machines_dir = None

        if infile is None:
            if files is None:
                files = Files()
            infile = files.get_value("MACHINES_SPEC_FILE", resolved=False)
            infile = files.get_resolved_value(infile)

        self.machines_dir = os.path.dirname(infile)

        GenericXML.__init__(self, infile)

        # Append the contents of $HOME/.cime/config_machines.xml if it exists
        # This could cause problems if node matchs are repeated when only one is expected
        local_infile = os.path.join(os.environ.get("HOME"), ".cime", "config_machines.xml")
        logger.debug("Infile: %s", local_infile)
        if os.path.exists(local_infile):
            GenericXML.read(self, local_infile)

        if machine is None:
            machine = self.probe_machine_name()

        expect(machine is not None, "Could not initialize machine object from %s or %s" % (infile, local_infile))
        self.set_machine(machine)
Esempio n. 2
0
    def __init__(self, batch_system=None, machine=None, infile=None, files=None):
        """
        initialize an object
        """
        if files is None:
            files = Files()
        if infile is None:
            infile = files.get_value("BATCH_SPEC_FILE")

        schema = files.get_schema("BATCH_SPEC_FILE")

        GenericXML.__init__(self, infile, schema=schema)

        self.batch_system_node = None
        self.machine_node      = None
        self.batch_system      = batch_system
        self.machine           = machine

        #Append the contents of $HOME/.cime/config_batch.xml if it exists
        #This could cause problems if node matchs are repeated when only one is expected
        infile = os.path.join(os.environ.get("HOME"),".cime","config_batch.xml")
        if os.path.exists(infile):
            GenericXML.read(self, infile)

        if self.batch_system is not None:
            self.set_batch_system(self.batch_system, machine=machine)
Esempio n. 3
0
    def __init__(self, case_root=None, infile="env_archive.xml"):
        """
        initialize an object interface to file env_archive.xml in the case directory
        """
        logger.debug("Case_root = %s" , case_root)


        # Check/Build path to env_archive.xml
        if case_root is None:
            case_root = os.getcwd()

        if os.path.isabs(infile):
            fullpath = infile
        else:
            fullpath = os.path.join(case_root, infile)

        # Initialize self
        # If env_archive.xml file does not exists in case directory read default from config
        GenericXML.__init__(self, fullpath)

        # The following creates the CASEROOT/env_archive.xml contents in self.root
        if not os.path.isfile(fullpath):
            headerobj = Headers()
            headernode = headerobj.get_header_node(os.path.basename(fullpath))
            self.root.append(headernode)
            archive = Archive()
            self.root.append(archive.root)
Esempio n. 4
0
    def __init__(self, compiler=None, machine=None, os_= None, mpilib=None, infile=None, files=None):
        """
        initialize an object
        """
        if infile is None:
            if files is None:
                files = Files()
            infile = files.get_value("COMPILERS_SPEC_FILE")

        GenericXML.__init__(self, infile)

        self.machine        = machine
        self.os             = os_
        self.mpilib         = mpilib
        self.compiler_nodes = None # Listed from last to first
        self.compiler       = compiler

        if self.compiler is not None:
            self.set_compiler(compiler)

        #Append the contents of $HOME/.cime/config_compilers.xml if it exists
        #This could cause problems if node matchs are repeated when only one is expected
        infile = os.path.join(os.environ.get("HOME"),".cime","config_compilers.xml")
        if os.path.exists(infile):
            GenericXML.read(self, infile)
Esempio n. 5
0
    def __init__(self, infile=None, files=None):
        if infile is None:
            if files is None:
                files = Files()
            infile = files.get_value("GRIDS_SPEC_FILE")
        logger.debug(" Grid specification file is %s" % infile)

        GenericXML.__init__(self, infile)
Esempio n. 6
0
    def __init__(self, infile=None):
        """
        initialize an object
        """
        if infile is None:
            infile = os.path.join(get_cime_root(), "cime_config", get_model(), "archive.xml")

        GenericXML.__init__(self, infile)
Esempio n. 7
0
    def __init__(self):
        """
        initialize an object
        """

        expect(get_model() == 'cesm', "testreport is only meant to populate the CESM test database." )
        self.root = None

        GenericXML.__init__(self)
Esempio n. 8
0
    def __init__(self):
        """
        initialize an object
        """

        expect(get_model() == 'cesm', "testreport is only meant to populate the CESM test database." )
        self.root = None

        GenericXML.__init__(self, root_name_override="testrecord", read_only=False, infile="TestRecord.xml")
Esempio n. 9
0
File: pes.py Progetto: Katetc/cime
 def __init__(self, infile, files=None):
     """
     initialize a files object given input pes specification file
     """
     if files is None:
         files = Files()
     schema = files.get_schema("PES_SPEC_FILE")
     logger.debug("DEBUG: infile is {}".format(infile))
     GenericXML.__init__(self, infile, schema=schema)
Esempio n. 10
0
 def __init__(self,infile, files=None):
     """
     initialize an object
     """
     schema = None
     if files is None:
         files = Files()
     schema = files.get_schema("TESTS_SPEC_FILE")
     GenericXML.__init__(self, infile, schema=schema)
Esempio n. 11
0
    def __init__(self, machine, infile=None):
        """
        initialize an object
        """
        if (infile is None):
            infile = os.path.join(get_cime_root(), "cime_config", get_model(), "machines", "config_lt_archive.xml")

        GenericXML.__init__(self, infile)

        self.machine = machine
Esempio n. 12
0
    def __init__(self,  infile=None, files=None):
        """
        initialize an object interface to file config_tests.xml
        """
        if infile is None:
            if files is None:
                files = Files()
            infile = files.get_value("CONFIG_TESTS_FILE")

        GenericXML.__init__(self,  infile)
Esempio n. 13
0
 def __init__(self, infile):
     """
     initialize an object
     """
     GenericXML.__init__(self, infile)
     self._testnodes = {}
     self._testlist_node = None
     if os.path.isfile(infile):
         testnodes = self.get_children('test')
         for node in testnodes:
             self._testnodes[self.get(node, "name")] = node
Esempio n. 14
0
 def __init__(self,infile, files=None):
     """
     initialize an object
     """
     schema = None
     if files is None:
         files = Files()
     schema = files.get_schema("TESTS_SPEC_FILE")
     GenericXML.__init__(self, infile, schema=schema)
     expect(self.get_version() >= 2.0,
            "{} is an unsupported version of the testfile format and will be ignored".format(infile))
Esempio n. 15
0
 def __init__(self, infile):
     """
     initialize an object
     """
     GenericXML.__init__(self, infile)
     self._testnodes = {}
     if os.path.isfile(infile):
         testnodes = self.get_nodes('test')
         for node in testnodes:
             self._testnodes[node.get("name")] = node
     else:
         self.root.set('version', _VERSION)
Esempio n. 16
0
    def __init__(self, infile=None, files=None):
        if files is None:
            files = Files()
        if infile is None:
            infile = files.get_value("GRIDS_SPEC_FILE")
        logger.debug(" Grid specification file is %s" % infile)
        schema = files.get_schema("GRIDS_SPEC_FILE")

        GenericXML.__init__(self, infile, schema)
        self._version = self.get_version()

        self._comp_gridnames = self._get_grid_names()
Esempio n. 17
0
    def __init__(self, machine, files=None, infile=None):
        """
        initialize an object
        """
        if (infile is None):
            if files is None:
                files = Files()
            infile = files.get_value("LTARCHIVE_SPEC_FILE", resolved=False)
            infile = files.get_resolved_value(infile)

        GenericXML.__init__(self, infile)

        self.machine = machine
Esempio n. 18
0
    def __init__(self, infile=None, files=None):
        """
        initialize a files object given input pes specification file
        """
        if files is None:
            files = Files()
        if infile is None:
            infile = files.get_value("INPUTDATA_SPEC_FILE")
        schema = files.get_schema("INPUTDATA_SPEC_FILE")
        logger.debug("DEBUG: infile is {}".format(infile))
        GenericXML.__init__(self, infile, schema=schema)

        self._servernode = None
Esempio n. 19
0
    def __init__(self,
                 machobj,
                 infile=None,
                 compiler=None,
                 mpilib=None,
                 files=None,
                 version=None):
        """
        initialize an object
        """

        if infile is None:
            if files is None:
                files = Files()
            infile = files.get_value("COMPILERS_SPEC_FILE")
            schema = files.get_schema("COMPILERS_SPEC_FILE")

        GenericXML.__init__(self, infile, schema)
        self._machobj = machobj
        if version is not None:
            # this is used in scripts_regression_tests to force version 2, it should not be used otherwise
            self._version = version
        else:
            self._version = self.get_version()

        self.machine = machobj.get_machine_name()
        self.os = machobj.get_value("OS")
        if mpilib is None:
            mpilib = machobj.get_default_MPIlib()
        self.mpilib = mpilib
        if compiler is None:
            compiler = machobj.get_default_compiler()
        self.compiler = compiler

        self.compiler_nodes = None  # Listed from last to first
        #Append the contents of $HOME/.cime/config_compilers.xml if it exists
        #This could cause problems if node matchs are repeated when only one is expected
        infile = os.path.join(os.environ.get("HOME"), ".cime",
                              "config_compilers.xml")
        if os.path.exists(infile):
            GenericXML.read(self, infile)

        if self.compiler is not None:
            self.set_compiler(compiler)

        if self._version > 1.0:
            # Run an XPath query to extract the list of flag variable names.
            ns = {"xs": "http://www.w3.org/2001/XMLSchema"}
            flag_xpath = ".//xs:group[@name='compilerVars']/xs:choice/xs:element[@type='flagsVar']"
            flag_elems = ET.parse(schema).getroot().findall(flag_xpath, ns)
            self.flag_vars = set(elem.get('name') for elem in flag_elems)
Esempio n. 20
0
    def __init__(self, infile=None, files=None, comp_interface=None):
        if files is None:
            files = Files(comp_interface=comp_interface)
        if infile is None:
            infile = files.get_value("GRIDS_SPEC_FILE")
        logger.debug(" Grid specification file is {}".format(infile))
        schema = files.get_schema("GRIDS_SPEC_FILE")
        try:
            GenericXML.__init__(self, infile, schema)
        except:
            expect(False, "Could not initialize Grids")

        self._version = self.get_version()
        self._comp_gridnames = self._get_grid_names()
Esempio n. 21
0
 def __init__(self, infile, files=None):
     """
     initialize an object
     """
     schema = None
     if files is None:
         files = Files()
     schema = files.get_schema("TESTS_SPEC_FILE")
     GenericXML.__init__(self, infile, schema=schema)
     expect(
         self.get_version() >= 2.0,
         "{} is an unsupported version of the testfile format and will be ignored".format(
             infile
         ),
     )
Esempio n. 22
0
File: tests.py Progetto: Katetc/cime
 def __init__(self,  infile=None, files=None):
     """
     initialize an object interface to file config_tests.xml
     """
     if infile is None:
         if files is None:
             files = Files()
         infile = files.get_value("CONFIG_TESTS_FILE")
     GenericXML.__init__(self,  infile)
     # append any component specific config_tests.xml files
     for comp in files.get_components("CONFIG_TESTS_FILE"):
         if comp is None:
             continue
         infile = files.get_value("CONFIG_TESTS_FILE", attribute={"component":comp})
         if os.path.isfile(infile):
             self.read(infile)
Esempio n. 23
0
    def __init__(self, batch_system=None, machine=None, infile=None):
        """
        initialize an object
        """
        if infile is None:
            infile = os.path.join(get_cime_root(), "cime_config", get_model(), "machines", "config_batch.xml")

        GenericXML.__init__(self, infile)

        self.batch_system_node = None
        self.machine_node      = None
        self.batch_system      = batch_system
        self.machine           = machine

        if self.batch_system is not None:
            self.set_batch_system(self.batch_system, machine=machine)
Esempio n. 24
0
 def __init__(self,  infile=None, files=None):
     """
     initialize an object interface to file config_tests.xml
     """
     if infile is None:
         if files is None:
             files = Files()
         infile = files.get_value("CONFIG_TESTS_FILE")
     GenericXML.__init__(self,  infile)
     # append any component specific config_tests.xml files
     for comp in files.get_components("CONFIG_TESTS_FILE"):
         if comp is None:
             continue
         infile = files.get_value("CONFIG_TESTS_FILE", attribute={"component":comp})
         if os.path.isfile(infile):
             self.read(infile)
Esempio n. 25
0
    def __init__(self, infile=None, files=None, machine=None):
        """
        initialize an object
        if a filename is provided it will be used,
        otherwise if a files object is provided it will be used
        otherwise create a files object from default values
        """

        self.machine_node = None
        self.machine = None
        self.machines_dir = None
        self.custom_settings = {}
        schema = None
        if files is None:
            files = Files()
        if infile is None:
            infile = files.get_value("MACHINES_SPEC_FILE")
        schema = files.get_schema("MACHINES_SPEC_FILE")
        logger.debug("Verifying using schema {}".format(schema))

        self.machines_dir = os.path.dirname(infile)

        GenericXML.__init__(self, infile, schema)

        # Append the contents of $HOME/.cime/config_machines.xml if it exists
        # This could cause problems if node matchs are repeated when only one is expected
        local_infile = os.path.join(os.environ.get("HOME"), ".cime",
                                    "config_machines.xml")
        logger.debug("Infile: {}".format(local_infile))
        if os.path.exists(local_infile):
            GenericXML.read(self, local_infile, schema)

        if machine is None:
            if "CIME_MACHINE" in os.environ:
                machine = os.environ["CIME_MACHINE"]
            else:
                cime_config = get_cime_config()
                if cime_config.has_option("main", "machine"):
                    machine = cime_config.get("main", "machine")
                if machine is None:
                    machine = self.probe_machine_name()

        expect(
            machine is not None,
            "Could not initialize machine object from {} or {}".format(
                infile, local_infile))
        self.set_machine(machine)
Esempio n. 26
0
    def __init__(self, machobj, infile=None, compiler=None, mpilib=None, files=None, version=None):
        """
        initialize an object
        """

        if infile is None:
            if files is None:
                files = Files()
            infile = files.get_value("COMPILERS_SPEC_FILE")
            schema = files.get_schema("COMPILERS_SPEC_FILE")

        GenericXML.__init__(self, infile, schema)
        self._machobj = machobj
        if version is not None:
            # this is used in scripts_regression_tests to force version 2, it should not be used otherwise
            self._version = version
        else:
            self._version = self.get_version()

        self.machine  = machobj.get_machine_name()
        self.os = machobj.get_value("OS")
        if compiler is None:
            compiler = machobj.get_default_compiler()
        self.compiler       = compiler

        if mpilib is None:
            if compiler is None:
                mpilib = machobj.get_default_MPIlib()
            else:
                mpilib = machobj.get_default_MPIlib(attributes={'compiler':compiler})
        self.mpilib = mpilib

        self.compiler_nodes = None # Listed from last to first
        #Append the contents of $HOME/.cime/config_compilers.xml if it exists
        #This could cause problems if node matchs are repeated when only one is expected
        infile = os.path.join(os.environ.get("HOME"),".cime","config_compilers.xml")
        if os.path.exists(infile):
            GenericXML.read(self, infile)

        if self.compiler is not None:
            self.set_compiler(compiler)

        if self._version > 1.0:
            schema_db = GenericXML(infile=schema)
            compiler_vars = schema_db.get_child("{http://www.w3.org/2001/XMLSchema}group", attributes={"name":"compilerVars"})
            choice  = schema_db.get_child(name="{http://www.w3.org/2001/XMLSchema}choice", root=compiler_vars)
            self.flag_vars = set(schema_db.get(elem, "name") for elem in schema_db.get_children(root=choice, attributes={"type":"flagsVar"}))
Esempio n. 27
0
    def __init__(
        self,
        batch_system=None,
        machine=None,
        infile=None,
        files=None,
        extra_machines_dir=None,
    ):
        """
        initialize an object

        If extra_machines_dir is provided, it should be a string giving a path to an
        additional directory that will be searched for a config_batch.xml file; if
        found, the contents of this file will be appended to the standard
        config_batch.xml. An empty string is treated the same as None.
        """
        if files is None:
            files = Files()
        if infile is None:
            infile = files.get_value("BATCH_SPEC_FILE")

        schema = files.get_schema("BATCH_SPEC_FILE")

        GenericXML.__init__(self, infile, schema=schema)

        self.batch_system_node = None
        self.machine_node = None
        self.batch_system = batch_system
        self.machine = machine

        # Append the contents of $HOME/.cime/config_batch.xml if it exists.
        #
        # Also append the contents of a config_batch.xml file in the directory given by
        # extra_machines_dir, if present.
        #
        # This could cause problems if node matches are repeated when only one is expected.
        infile = os.path.join(os.environ.get("HOME"), ".cime",
                              "config_batch.xml")
        if os.path.exists(infile):
            GenericXML.read(self, infile)
        if extra_machines_dir:
            infile = os.path.join(extra_machines_dir, "config_batch.xml")
            if os.path.exists(infile):
                GenericXML.read(self, infile)

        if self.batch_system is not None:
            self.set_batch_system(self.batch_system, machine=machine)
Esempio n. 28
0
    def __init__(self):
        """
        initialize an object
        """

        expect(
            get_model() == "cesm",
            "testreport is only meant to populate the CESM test database.",
        )
        self.root = None

        GenericXML.__init__(
            self,
            root_name_override="testrecord",
            read_only=False,
            infile="TestRecord.xml",
        )
Esempio n. 29
0
    def __init__(self, machobj, infile=None, compiler=None, mpilib=None, files=None, version=None):
        """
        initialize an object
        """

        if infile is None:
            if files is None:
                files = Files()
            infile = files.get_value("COMPILERS_SPEC_FILE")
            schema = files.get_schema("COMPILERS_SPEC_FILE")

        GenericXML.__init__(self, infile, schema)
        self._machobj = machobj
        if version is not None:
            # this is used in scripts_regression_tests to force version 2, it should not be used otherwise
            self._version = version
        else:
            self._version = self.get_version()

        self.machine  = machobj.get_machine_name()
        self.os = machobj.get_value("OS")
        if mpilib is None:
            mpilib = machobj.get_default_MPIlib()
        self.mpilib = mpilib
        if compiler is None:
            compiler = machobj.get_default_compiler()
        self.compiler       = compiler

        self.compiler_nodes = None # Listed from last to first
        #Append the contents of $HOME/.cime/config_compilers.xml if it exists
        #This could cause problems if node matchs are repeated when only one is expected
        infile = os.path.join(os.environ.get("HOME"),".cime","config_compilers.xml")
        if os.path.exists(infile):
            GenericXML.read(self, infile)

        if self.compiler is not None:
            self.set_compiler(compiler)

        if self._version > 1.0:
            # Run an XPath query to extract the list of flag variable names.
            ns = {"xs": "http://www.w3.org/2001/XMLSchema"}
            flag_xpath = ".//xs:group[@name='compilerVars']/xs:choice/xs:element[@type='flagsVar']"
            flag_elems = ET.parse(schema).getroot().findall(flag_xpath, ns)
            self.flag_vars = set(elem.get('name') for elem in flag_elems)
Esempio n. 30
0
    def __init__(self, infile=None, files=None):
        """
        initialize an object
        """
        if files is None:
            files = Files()
        if infile is None:
            infile = files.get_value("WORKFLOW_SPEC_FILE")
        expect(infile, "No workflow file defined in {}".format(files.filename))

        schema = files.get_schema("WORKFLOW_SPEC_FILE")

        GenericXML.__init__(self, infile, schema=schema)

        #Append the contents of $HOME/.cime/config_workflow.xml if it exists
        #This could cause problems if node matchs are repeated when only one is expected
        infile = os.path.join(os.environ.get("HOME"),".cime","config_workflow.xml")
        if os.path.exists(infile):
            GenericXML.read(self, infile)
Esempio n. 31
0
    def __init__(self, infile=None, files=None, machine=None):
        """
        initialize an object
        if a filename is provided it will be used,
        otherwise if a files object is provided it will be used
        otherwise create a files object from default values
        """

        self.machine_node = None
        self.machine = None
        self.machines_dir = None
        schema = None
        if files is None:
            files = Files()
        if infile is None:
            infile = files.get_value("MACHINES_SPEC_FILE")
        schema = files.get_schema("MACHINES_SPEC_FILE")
        logger.debug("Verifying using schema {}".format(schema))

        self.machines_dir = os.path.dirname(infile)

        GenericXML.__init__(self, infile, schema)

        # Append the contents of $HOME/.cime/config_machines.xml if it exists
        # This could cause problems if node matchs are repeated when only one is expected
        local_infile = os.path.join(os.environ.get("HOME"),".cime","config_machines.xml")
        logger.debug("Infile: {}".format(local_infile))
        if os.path.exists(local_infile):
            GenericXML.read(self, local_infile, schema)

        if machine is None:
            if "CIME_MACHINE" in os.environ:
                machine = os.environ["CIME_MACHINE"]
            else:
                cime_config = get_cime_config()
                if cime_config.has_option("main", "machine"):
                    machine = cime_config.get("main", "machine")
                if machine is None:
                    machine = self.probe_machine_name()

        expect(machine is not None, "Could not initialize machine object from {} or {}".format(infile, local_infile))
        self.set_machine(machine)
Esempio n. 32
0
    def __init__(self, batch_system=None, machine=None, infile=None):
        """
        initialize an object
        """
        if infile is None:
            infile = os.path.join(get_cime_root(), "cime_config", get_model(), "machines", "config_batch.xml")

        GenericXML.__init__(self, infile)

        self.batch_system_node = None
        self.machine_node      = None
        self.batch_system      = batch_system
        self.machine           = machine

        #Append the contents of $HOME/.cime/config_batch.xml if it exists
        #This could cause problems if node matchs are repeated when only one is expected
        infile = os.path.join(os.environ.get("HOME"),".cime","config_batch.xml")
        if os.path.exists(infile):
            GenericXML.read(self, infile)

        if self.batch_system is not None:
            self.set_batch_system(self.batch_system, machine=machine)
Esempio n. 33
0
    def __init__(self, case_root=None, infile="env_archive.xml"):
        """
        initialize an object interface to file env_archive.xml in the case directory
        """
        logger.debug("Case_root = {}".format(case_root))

        # Check/Build path to env_archive.xml
        if case_root is None:
            case_root = os.getcwd()

        if os.path.isabs(infile):
            fullpath = infile
        else:
            fullpath = os.path.join(case_root, infile)

        schema = os.path.join(get_cime_root(), "config", "xml_schemas", "env_archive.xsd")
        GenericXML.__init__(self, fullpath, schema=schema)

        # The following creates the CASEROOT/env_archive.xml contents in self.root
        if not os.path.isfile(fullpath):
            headerobj = Headers()
            headernode = headerobj.get_header_node(os.path.basename(fullpath))
            self.add_child(headernode)
Esempio n. 34
0
    def __init__(self, case_root=None, infile="env_archive.xml"):
        """
        initialize an object interface to file env_archive.xml in the case directory
        """
        logger.debug("Case_root = {}".format(case_root))


        # Check/Build path to env_archive.xml
        if case_root is None:
            case_root = os.getcwd()

        if os.path.isabs(infile):
            fullpath = infile
        else:
            fullpath = os.path.join(case_root, infile)

        schema = os.path.join(get_cime_root(), "config", "xml_schemas", "env_archive.xsd")
        GenericXML.__init__(self, fullpath, schema=schema)

        # The following creates the CASEROOT/env_archive.xml contents in self.root
        if not os.path.isfile(fullpath):
            headerobj = Headers()
            headernode = headerobj.get_header_node(os.path.basename(fullpath))
            self.root.append(headernode)
Esempio n. 35
0
 def __init__(self, infile=None, files=None):
     if files is None:
         files = Files()
     schema = files.get_schema("COMPSETS_SPEC_FILE")
     GenericXML.__init__(self, infile, schema=schema)
     self.groups = {}
Esempio n. 36
0
 def __init__(self, infile):
     schema = os.path.join(get_cime_root(), "config", "xml_schemas",
                           "expected_fails_file.xsd")
     GenericXML.__init__(self, infile, schema=schema)
Esempio n. 37
0
 def __init__(self, infile=None):
     GenericXML.__init__(self, infile)
     self.groups = {}
Esempio n. 38
0
 def __init__(self,infile):
     """
     initialize an object
     """
     GenericXML.__init__(self,infile)
Esempio n. 39
0
 def __init__(self, infile=None, schema=None):
     GenericXML.__init__(self, infile, schema)
     self.groups={}
Esempio n. 40
0
 def __init__(self, infile):
     """
     initialize a files object given input pes specification file
     """
     logger.debug("DEBUG: infile is %s" % infile)
     GenericXML.__init__(self, infile)
Esempio n. 41
0
 def __init__(self, infile):
     """
     initialize an object
     """
     GenericXML.__init__(self, infile)
Esempio n. 42
0
 def __init__(self, infile=None, schema=None, read_only=True):
     GenericXML.__init__(self, infile, schema, read_only=read_only)
     self.groups = {}
Esempio n. 43
0
 def __init__(self, infile):
     """
     initialize a files object given input pes specification file
     """
     logger.debug("DEBUG: infile is %s"%infile)
     GenericXML.__init__(self, infile)
Esempio n. 44
0
 def __init__(self, infile=None, schema=None):
     GenericXML.__init__(self, infile, schema)
     self.groups={}
Esempio n. 45
0
    def __init__(
        self,
        machobj,
        infile=None,
        compiler=None,
        mpilib=None,
        files=None,
        version=None,
        extra_machines_dir=None,
    ):
        """
        initialize an object

        If extra_machines_dir is provided, it should be a string giving a path to an
        additional directory that will be searched for a config_compilers.xml file; if
        found, the contents of this file will be appended to the standard
        config_compilers.xml. An empty string is treated the same as None.
        """

        expect(
            "CIME_NO_CMAKE_MACRO" in os.environ,
            "Should not be using config_compilers.xml without CIME_NO_CMAKE_MACRO",
        )

        if infile is None:
            if files is None:
                files = Files()
            infile = files.get_value("COMPILERS_SPEC_FILE")
        schema = files.get_schema("COMPILERS_SPEC_FILE")

        GenericXML.__init__(self, infile, schema)
        if version is not None:
            # this is used in scripts_regression_tests to force version 2, it should not be used otherwise
            self._version = version
        else:
            self._version = self.get_version()

        self._machobj = machobj
        self.machine = machobj.get_machine_name()
        self.os = machobj.get_value("OS")
        if compiler is None:
            compiler = machobj.get_default_compiler()
        self.compiler = compiler

        if mpilib is None:
            if compiler is None:
                mpilib = machobj.get_default_MPIlib()
            else:
                mpilib = machobj.get_default_MPIlib(attributes={"compiler": compiler})
        self.mpilib = mpilib

        self.compiler_nodes = None  # Listed from last to first
        # Append the contents of $HOME/.cime/config_compilers.xml if it exists.
        #
        # Also append the contents of a config_compilers.xml file in the directory given by
        # extra_machines_dir, if present.
        #
        # This could cause problems if node matches are repeated when only one is expected.
        infile = os.path.join(os.environ.get("HOME"), ".cime", "config_compilers.xml")
        if os.path.exists(infile):
            GenericXML.read(self, infile, schema=schema)
        if extra_machines_dir:
            infile = os.path.join(extra_machines_dir, "config_compilers.xml")
            if os.path.exists(infile):
                GenericXML.read(self, infile, schema=schema)

        if self.compiler is not None:
            self.set_compiler(compiler)

        if self._version > 1.0:
            schema_db = GenericXML(infile=schema)
            compiler_vars = schema_db.get_child(
                "{http://www.w3.org/2001/XMLSchema}group",
                attributes={"name": "compilerVars"},
            )
            choice = schema_db.get_child(
                name="{http://www.w3.org/2001/XMLSchema}choice", root=compiler_vars
            )
            self.flag_vars = set(
                schema_db.get(elem, "name")
                for elem in schema_db.get_children(
                    root=choice, attributes={"type": "flagsVar"}
                )
            )
Esempio n. 46
0
    def __init__(self,
                 machobj,
                 infile=None,
                 compiler=None,
                 mpilib=None,
                 files=None,
                 version=None):
        """
        initialize an object
        """

        if infile is None:
            if files is None:
                files = Files()
            infile = files.get_value("COMPILERS_SPEC_FILE")
            schema = files.get_schema("COMPILERS_SPEC_FILE")

        GenericXML.__init__(self, infile, schema)
        self._machobj = machobj
        if version is not None:
            # this is used in scripts_regression_tests to force version 2, it should not be used otherwise
            self._version = version
        else:
            self._version = self.get_version()

        self.machine = machobj.get_machine_name()
        self.os = machobj.get_value("OS")
        if compiler is None:
            compiler = machobj.get_default_compiler()
        self.compiler = compiler

        if mpilib is None:
            if compiler is None:
                mpilib = machobj.get_default_MPIlib()
            else:
                mpilib = machobj.get_default_MPIlib(
                    attributes={'compiler': compiler})
        self.mpilib = mpilib

        self.compiler_nodes = None  # Listed from last to first
        #Append the contents of $HOME/.cime/config_compilers.xml if it exists
        #This could cause problems if node matchs are repeated when only one is expected
        infile = os.path.join(os.environ.get("HOME"), ".cime",
                              "config_compilers.xml")
        if os.path.exists(infile):
            GenericXML.read(self, infile)

        if self.compiler is not None:
            self.set_compiler(compiler)

        if self._version > 1.0:
            schema_db = GenericXML(infile=schema)
            compiler_vars = schema_db.get_child(
                "{http://www.w3.org/2001/XMLSchema}group",
                attributes={"name": "compilerVars"})
            choice = schema_db.get_child(
                name="{http://www.w3.org/2001/XMLSchema}choice",
                root=compiler_vars)
            self.flag_vars = set(
                schema_db.get(elem, "name") for elem in schema_db.get_children(
                    root=choice, attributes={"type": "flagsVar"}))
Esempio n. 47
0
 def __init__(self, infile):
     schema = os.path.join(get_cime_root(), "config", "xml_schemas", "expected_fails_file.xsd")
     GenericXML.__init__(self, infile, schema=schema)
Esempio n. 48
0
 def __init__(self, infile=None):
     GenericXML.__init__(self, infile)
     self.groups={}
Esempio n. 49
0
    def __init__(self,
                 infile=None,
                 files=None,
                 machine=None,
                 extra_machines_dir=None):
        """
        initialize an object
        if a filename is provided it will be used,
        otherwise if a files object is provided it will be used
        otherwise create a files object from default values

        If extra_machines_dir is provided, it should be a string giving a path to an
        additional directory that will be searched for a config_machines.xml file; if
        found, the contents of this file will be appended to the standard
        config_machines.xml. An empty string is treated the same as None.
        """

        self.machine_node = None
        self.machine = None
        self.machines_dir = None
        self.custom_settings = {}
        schema = None
        if files is None:
            files = Files()
        if infile is None:
            infile = files.get_value("MACHINES_SPEC_FILE")
        schema = files.get_schema("MACHINES_SPEC_FILE")
        logger.debug("Verifying using schema {}".format(schema))

        self.machines_dir = os.path.dirname(infile)

        GenericXML.__init__(self, infile, schema)

        # Append the contents of $HOME/.cime/config_machines.xml if it exists.
        #
        # Also append the contents of a config_machines.xml file in the directory given by
        # extra_machines_dir, if present.
        #
        # This could cause problems if node matches are repeated when only one is expected.
        local_infile = os.path.join(os.environ.get("HOME"), ".cime",
                                    "config_machines.xml")
        logger.debug("Infile: {}".format(local_infile))
        if os.path.exists(local_infile):
            GenericXML.read(self, local_infile, schema)
        if extra_machines_dir:
            local_infile = os.path.join(extra_machines_dir,
                                        "config_machines.xml")
            logger.debug("Infile: {}".format(local_infile))
            if os.path.exists(local_infile):
                GenericXML.read(self, local_infile, schema)

        if machine is None:
            if "CIME_MACHINE" in os.environ:
                machine = os.environ["CIME_MACHINE"]
            else:
                cime_config = get_cime_config()
                if cime_config.has_option("main", "machine"):
                    machine = cime_config.get("main", "machine")
                if machine is None:
                    machine = self.probe_machine_name()

        expect(
            machine is not None,
            "Could not initialize machine object from {} or {}".format(
                infile, local_infile))
        self.set_machine(machine)
Esempio n. 50
0
 def __init__(self, infile):
     schema = os.path.join(utils.get_schema_path(),
                           "expected_fails_file.xsd")
     GenericXML.__init__(self, infile, schema=schema)