示例#1
0
文件: batch.py 项目: IMMM-SFA/iwmm
    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)
示例#2
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)
示例#3
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
        #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)
示例#4
0
文件: machines.py 项目: gold2718/cime
    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
        infile = os.path.join(os.environ.get("HOME"), ".cime",
                              "config_machines.xml")
        logger.debug("Infile: %s", infile)
        if os.path.exists(infile):
            GenericXML.read(self, infile)

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

        expect(machine is not None, "Could not initialize machine object")
        self.set_machine(machine)
示例#5
0
文件: batch.py 项目: apcraig/cime
    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)
示例#6
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)
示例#7
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)
示例#8
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)
示例#9
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)
示例#10
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)
示例#11
0
 def __init__(self, infile, schema):
     """
     Initialize a CDEPS stream object
     """
     logger.debug("Verifying using schema {}".format(schema))
     GenericXML.__init__(self, infile, schema)
     if os.path.exists(infile):
         GenericXML.read(self, infile, schema)
示例#12
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)
示例#13
0
 def __init__(self, infile=None, files=None):
     """
     initialize an object
     """
     if files is None:
         files = Files()
     schema = None
     GenericXML.__init__(self, infile, schema=schema)
示例#14
0
文件: pes.py 项目: 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)
示例#15
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)
示例#16
0
文件: testlist.py 项目: apcraig/cime
 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)
示例#17
0
文件: pes.py 项目: rgknox/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)
示例#18
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)
示例#19
0
    def __init__(self, infile=None):
        """
        initialize an object
        """
        if infile is None:
            infile = os.path.join(get_cime_root(), "cime_config", get_model(),
                                  "config_archive.xml")

        GenericXML.__init__(self, infile)
示例#20
0
文件: archive.py 项目: j143-zz/cime
    def __init__(self, infile=None, files=None):
        """
        initialize an object
        """
        if files is None:
            files = Files()
        schema = files.get_schema("ARCHIVE_SPEC_FILE")

        GenericXML.__init__(self, infile, schema)
示例#21
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")
示例#22
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)
示例#23
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)
示例#24
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
示例#25
0
文件: testspec.py 项目: Katetc/cime
 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
示例#26
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
示例#27
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))
示例#28
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()
示例#29
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)
示例#30
0
文件: grids.py 项目: mnlevy1981/cime
    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()
示例#31
0
文件: testspec.py 项目: erika72/cime
 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_nodes('test')
         for node in testnodes:
             self._testnodes[node.get("name")] = node
     else:
         self.root.set('version', _VERSION)
示例#32
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
示例#33
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
示例#34
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")
示例#35
0
文件: inputdata.py 项目: Katetc/cime
    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
示例#36
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
示例#37
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)
示例#38
0
文件: grids.py 项目: jtruesdal/cime
    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()
示例#39
0
    def get_value(self, item, attribute=None, resolved=True, subgroup=None):
        """
        Get Value of fields in a stream.xml file
        """
        expect(subgroup is None, "This class does not support subgroups")
        value = None
        node = None
        names = item.split("/")
        node = None
        for name in names:
            node = self.scan_child(name, root=node)
        if node is not None:
            value = self.text(node).strip()

        if value is None:
            # if all else fails
            # pylint: disable=assignment-from-none
            value = GenericXML.get_value(self, item, attribute, resolved, subgroup)

        if resolved:
            if value is not None:
                value = self.get_resolved_value(value)
            elif item in os.environ:
                value = os.environ[item]

        return value
示例#40
0
    def get_value(self, name, attribute=None, resolved=True, subgroup=None):
        """
        Get Value of fields in the config_compilers.xml file
        """
        expect(self.compiler_nodes is not None,
               "Compiler object has no compiler defined")
        expect(subgroup is None, "This class does not support subgroups")
        value = None

        node = self.get_optional_compiler_node(name, attributes=attribute)
        if node is not None:
            value = self.text(node)

        if value is None:
            # if all else fails
            #pylint: disable=assignment-from-none
            value = GenericXML.get_value(self, name)

        if resolved:
            if value is not None:
                value = self.get_resolved_value(value)
            elif name in os.environ:
                value = os.environ[name]

        return value
示例#41
0
文件: tests.py 项目: 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)
示例#42
0
文件: batch.py 项目: IMMM-SFA/iwmm
    def get_value(self, name, attribute=None, resolved=True, subgroup=None):
        """
        Get Value of fields in the config_batch.xml file
        """
        expect(self.batch_system_node is not None,
               "Batch object has no batch system defined")
        expect(subgroup is None, "This class does not support subgroups")
        value = None

        node = self.get_optional_batch_node(name)
        if node is not None:
            value = self.text(node)

        if value is None:
            # if all else fails
            value = GenericXML.get_value(self, name, attribute, resolved,
                                         subgroup)

        if resolved:
            if value is not None:
                value = self.get_resolved_value(value)
            elif name in os.environ:
                value = os.environ[name]

        return value
示例#43
0
    def get_value(self, name, attributes=None, resolved=True, subgroup=None):
        """
        Get Value of fields in the config_machines.xml file
        """
        expect(self.machine_node is not None,
               "Machine object has no machine defined")
        expect(subgroup is None, "This class does not support subgroups")
        value = None

        # COMPILER and MPILIB are special, if called without arguments they get the default value from the
        # COMPILERS and MPILIBS lists in the file.
        if name == "COMPILER":
            value = self.get_default_compiler()
        elif name == "MPILIB":
            value = self.get_default_MPIlib(attributes)
        else:
            node = self.get_optional_node(name,
                                          root=self.machine_node,
                                          attributes=attributes)
            if node is not None:
                value = node.text

        if value is None:
            # if all else fails
            value = GenericXML.get_value(self, name)

        if resolved:
            if value is not None:
                value = self.get_resolved_value(value)
            elif name in os.environ:
                value = os.environ[name]

            value = convert_to_unknown_type(value)

        return value
示例#44
0
文件: batch.py 项目: quantheory/cime
    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)
示例#45
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)
示例#46
0
文件: machines.py 项目: apcraig/cime
    def get_value(self, name, attributes=None, resolved=True, subgroup=None):
        """
        Get Value of fields in the config_machines.xml file
        """
        expect(self.machine_node is not None, "Machine object has no machine defined")
        expect(subgroup is None, "This class does not support subgroups")
        value = None

        # COMPILER and MPILIB are special, if called without arguments they get the default value from the
        # COMPILERS and MPILIBS lists in the file.
        if name == "COMPILER":
            value = self.get_default_compiler()
        elif name == "MPILIB":
            value = self.get_default_MPIlib(attributes)
        else:
            node = self.get_optional_node(name, root=self.machine_node, attributes=attributes)
            if node is not None:
                value = node.text

        if value is None:
            # if all else fails
            value = GenericXML.get_value(self, name)

        if resolved:
            if value is not None:
                value = self.get_resolved_value(value)
            elif name in os.environ:
                value = os.environ[name]

            value = convert_to_unknown_type(value)

        return value
示例#47
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)
示例#48
0
def lock_file(filename, caseroot=None, newname=None):
    expect("/" not in filename, "Please just provide basename of locked file")
    caseroot = os.getcwd() if caseroot is None else caseroot
    newname = filename if newname is None else newname
    fulllockdir = os.path.join(caseroot, LOCKED_DIR)
    if not os.path.exists(fulllockdir):
        os.mkdir(fulllockdir)

    logging.debug("Locking file {}".format(filename))

    # JGF: It is extremely dangerous to alter our database (xml files) without
    # going through the standard API. The copy below invalidates all existing
    # GenericXML instances that represent this file and all caching that may
    # have involved this file. We should probably seek a safer way of locking
    # files.
    safe_copy(os.path.join(caseroot, filename), os.path.join(fulllockdir, newname))
    GenericXML.invalidate(os.path.join(fulllockdir, newname))
示例#49
0
def lock_file(filename, caseroot=None, newname=None):
    expect("/" not in filename, "Please just provide basename of locked file")
    caseroot = os.getcwd() if caseroot is None else caseroot
    newname = filename if newname is None else newname
    fulllockdir = os.path.join(caseroot, LOCKED_DIR)
    if not os.path.exists(fulllockdir):
        os.mkdir(fulllockdir)
    logging.debug("Locking file {} to {}".format(filename, newname))

    # JGF: It is extremely dangerous to alter our database (xml files) without
    # going through the standard API. The copy below invalidates all existing
    # GenericXML instances that represent this file and all caching that may
    # have involved this file. We should probably seek a safer way of locking
    # files.
    shutil.copyfile(os.path.join(caseroot, filename),
                    os.path.join(fulllockdir, newname))
    GenericXML.invalidate_file(os.path.join(fulllockdir, newname))
示例#50
0
文件: compilers.py 项目: apcraig/cime
    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)
示例#51
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)
示例#52
0
def _main_func():
###############################################################################

    testroot, testid, tagname, testtype, dryrun, dumpxml = parse_command_line(sys.argv)

    testxml = get_testreporter_xml(testroot, testid, tagname, testtype)

    #
    # Dump xml to a file.
    #
    if dumpxml:
        GenericXML.write(testxml,outfile="TestRecord.xml")


    #
    # Prompt for username and password, then post the XML string to the test database website
    #
    if not dryrun:
        testxml.push2testdb()
示例#53
0
def _main_func():
    ###############################################################################

    testroot, testid, tagname, testtype, dryrun, dumpxml = parse_command_line(
        sys.argv)

    testxml = get_testreporter_xml(testroot, testid, tagname, testtype)

    #
    # Dump xml to a file.
    #
    if dumpxml:
        GenericXML.write(testxml, outfile="TestRecord.xml")

    #
    # Prompt for username and password, then post the XML string to the test database website
    #
    if not dryrun:
        testxml.push2testdb()
示例#54
0
文件: compilers.py 项目: Katetc/cime
    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"}))
示例#55
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)
示例#56
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)
示例#57
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)
示例#58
0
文件: compilers.py 项目: Katetc/cime
    def get_value(self, name, attribute=None, resolved=True, subgroup=None):
        """
        Get Value of fields in the config_compilers.xml file
        """
        expect(self.compiler_nodes is not None, "Compiler object has no compiler defined")
        expect(subgroup is None, "This class does not support subgroups")
        value = None

        node = self.get_optional_compiler_node(name, attributes=attribute)
        if node is not None:
            value = self.text(node)

        if value is None:
            # if all else fails
            value = GenericXML.get_value(self, name)

        if resolved:
            if value is not None:
                value = self.get_resolved_value(value)
            elif name in os.environ:
                value = os.environ[name]

        return value
示例#59
0
文件: batch.py 项目: apcraig/cime
    def get_value(self, name, attribute=None, resolved=True, subgroup=None):
        """
        Get Value of fields in the config_batch.xml file
        """
        expect(self.batch_system_node is not None, "Batch object has no batch system defined")
        expect(subgroup is None, "This class does not support subgroups")
        value = None

        node = self.get_optional_batch_node(name)
        if node is not None:
            value = node.text

        if value is None:
            # if all else fails
            value = GenericXML.get_value(self, name, attribute, resolved, subgroup)

        if resolved:
            if value is not None:
                value = self.get_resolved_value(value)
            elif name in os.environ:
                value = os.environ[name]

        return value