当前位置: 首页>>代码示例>>Python>>正文


Python Files.get_value方法代码示例

本文整理汇总了Python中CIME.XML.files.Files.get_value方法的典型用法代码示例。如果您正苦于以下问题:Python Files.get_value方法的具体用法?Python Files.get_value怎么用?Python Files.get_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CIME.XML.files.Files的用法示例。


在下文中一共展示了Files.get_value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_caseroot_tools

# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_value [as 别名]
    def _create_caseroot_tools(self):
        machines_dir = os.path.abspath(self.get_value("MACHDIR"))
        toolsdir = os.path.join(self.get_value("CIMEROOT"),"scripts","Tools")
        # setup executable files in caseroot/
        exefiles = (os.path.join(toolsdir, "case.setup"),
                    os.path.join(toolsdir, "case.build"),
                    os.path.join(toolsdir, "case.submit"),
                    os.path.join(toolsdir, "preview_namelists"),
                    os.path.join(toolsdir, "check_input_data"),
                    os.path.join(toolsdir, "check_case"),
                    os.path.join(toolsdir, "archive_metadata.sh"),
                    os.path.join(toolsdir, "xmlchange"),
                    os.path.join(toolsdir, "xmlquery"))
        try:
            for exefile in exefiles:
                destfile = os.path.join(self._caseroot,os.path.basename(exefile))
                os.symlink(exefile, destfile)
        except Exception as e:
            logger.warning("FAILED to set up exefiles: %s" % str(e))

        # set up utility files in caseroot/Tools/
        toolfiles = (os.path.join(toolsdir, "check_lockedfiles"),
                     os.path.join(toolsdir, "lt_archive.sh"),
                     os.path.join(toolsdir, "getTiming"),
                     os.path.join(toolsdir, "save_provenance"),
                     os.path.join(machines_dir,"Makefile"),
                     os.path.join(machines_dir,"mkSrcfiles"),
                     os.path.join(machines_dir,"mkDepends"))

        for toolfile in toolfiles:
            destfile = os.path.join(self._caseroot,"Tools",os.path.basename(toolfile))
            expect(os.path.isfile(toolfile)," File %s does not exist"%toolfile)
            try:
                os.symlink(toolfile, destfile)
            except Exception as e:
                logger.warning("FAILED to set up toolfiles: %s %s %s" % (str(e), toolfile, destfile))

        # Create Macros file.
        machine = self.get_value("MACH")
        files = Files()
        # Use config_build if the environment variable is set, or if there is no
        # config_compilers file.
        if os.getenv("CIME_USE_CONFIG_BUILD") == "TRUE" or \
           files.get_value("COMPILERS_SPEC_FILE") is None:
            build_file = files.get_value("BUILD_SPEC_FILE")
            machobj = Machines(machine=machine, files=files)
            macro_maker = Build(machobj)
            macros_path = os.path.join(self._caseroot, "Macros")
            with open(macros_path, "w") as macros_file:
                macro_maker.write_macros('Makefile', build_file, macros_file)

        # Copy any system or compiler Depends files to the case.
        compiler = self.get_value("COMPILER")
        for dep in (machine, compiler):
            dfile = "Depends.%s"%dep
            if os.path.isfile(os.path.join(machines_dir,dfile)):
                shutil.copyfile(os.path.join(machines_dir,dfile), os.path.join(self._caseroot,dfile))
        dfile = "Depends.%s.%s"%(machine,compiler)
        if os.path.isfile(os.path.join(machines_dir,dfile)):
            shutil.copyfile(os.path.join(machines_dir,dfile), os.path.join(self._caseroot, dfile))
开发者ID:cacraigucar,项目名称:cime-cacraig,代码行数:62,代码来源:case.py

示例2: _set_compset_and_pesfile

# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_value [as 别名]
    def _set_compset_and_pesfile(self, compset_name, user_compset=False, pesfile=None):
        """
        Loop through all the compset files and find the compset
        specifation file that matches either the input 'compset_name'.
        Note that the input compset name (i.e. compset_name) can be
        either a longname or an alias.  This will also set the
        compsets and pes specfication files.
        """
        files = Files()
        components = files.get_components("COMPSETS_SPEC_FILE")
        logger.debug(" Possible components for COMPSETS_SPEC_FILE are %s" % components)

        # Loop through all of the files listed in COMPSETS_SPEC_FILE and find the file
        # that has a match for either the alias or the longname in that order
        for component in components:

            # Determine the compsets file for this component
            compsets_filename = files.get_value("COMPSETS_SPEC_FILE", {"component":component})
            pes_filename      = files.get_value("PES_SPEC_FILE"     , {"component":component})
            tests_filename    = files.get_value("TESTS_SPEC_FILE"   , {"component":component}, resolved=False)
            tests_mods_dir    = files.get_value("TESTS_MODS_DIR"    , {"component":component}, resolved=False)
            user_mods_dir     = files.get_value("USER_MODS_DIR"     , {"component":component}, resolved=False)

            # If the file exists, read it and see if there is a match for the compset alias or longname
            if (os.path.isfile(compsets_filename)):
                compsets = Compsets(compsets_filename)
                match = compsets.get_compset_match(name=compset_name)
                if match is not None:
                    self._pesfile = pes_filename
                    self._compsetsfile = compsets_filename
                    self._compsetname = match
                    self.set_value("COMPSETS_SPEC_FILE" ,
                                   files.get_value("COMPSETS_SPEC_FILE", {"component":component}, resolved=False))
                    self.set_value("TESTS_SPEC_FILE"    , tests_filename)
                    self.set_value("TESTS_MODS_DIR"     , tests_mods_dir)
                    self.set_value("USER_MODS_DIR"      , user_mods_dir)
                    self.set_value("PES_SPEC_FILE"      ,
                                   files.get_value("PES_SPEC_FILE"     , {"component":component}, resolved=False))
                    logger.info("Compset longname is %s " %(match))
                    logger.info("Compset specification file is %s" %(compsets_filename))
                    logger.info("Pes     specification file is %s" %(pes_filename))
                    return

        if user_compset is True:
            #Do not error out for user_compset
            logger.warn("Could not find a compset match for either alias or longname in %s" %(compset_name))
            self._compsetname = compset_name
            self._pesfile = pesfile
            self.set_value("PES_SPEC_FILE", pesfile)
        else:
            expect(False,
                   "Could not find a compset match for either alias or longname in %s" %(compset_name))
开发者ID:quantheory,项目名称:cime,代码行数:54,代码来源:case.py

示例3: setup

# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_value [as 别名]
    def setup(self, env_archive, components, files=None):
        if files is None:
            files = Files()

        components_node = env_archive.make_child("components", attributes={"version":"2.0"})

        model = get_model()
        if 'drv' not in components:
            components.append('drv')
        if 'dart' not in components and model == 'cesm':
            components.append('dart')

        for comp in components:
            infile = files.get_value("ARCHIVE_SPEC_FILE", {"component":comp})

            if infile is not None and os.path.isfile(infile):
                arch = Archive(infile=infile, files=files)
                specs = arch.get_optional_child(name="comp_archive_spec", attributes={"compname":comp})
            else:
                if infile is None:
                    logger.debug("No archive file defined for component {}".format(comp))
                else:
                    logger.debug("Archive file {} for component {} not found".format(infile,comp))

                specs = self.get_optional_child(name="comp_archive_spec", attributes={"compname":comp})

            if specs is None:
                logger.debug("No archive specs found for component {}".format(comp))
            else:
                logger.debug("adding archive spec for {}".format(comp))
                env_archive.add_child(specs, root=components_node)
开发者ID:Katetc,项目名称:cime,代码行数:33,代码来源:archive.py

示例4: _create_newcase_phase

# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_value [as 别名]
    def _create_newcase_phase(self, test):
    ###########################################################################
        test_dir = self._get_test_dir(test)

        test_case, case_opts, grid, compset, machine, compiler, test_mods = CIME.utils.parse_test_name(test)
        if (compiler != self._compiler):
            raise StandardError("Test '%s' has compiler that does not match instance compliler '%s'" % (test, self._compiler))
        if (self._parallel_jobs == 1):
            scratch_dir = self._machobj.get_value("CESMSCRATCHROOT")
            if (self._project is not None):
                scratch_dir = scratch_dir.replace("$PROJECT", self._project)
            sharedlibroot = os.path.join(scratch_dir, "sharedlibroot.%s" % self._test_id)
        else:
            # Parallelizing builds introduces potential sync problems with sharedlibroot
            # Just let every case build it's own
            sharedlibroot = os.path.join(test_dir, "sharedlibroot.%s" % self._test_id)
        create_newcase_cmd = "%s -model %s -case %s -res %s -mach %s -compiler %s -compset %s -testname %s -project %s -sharedlibroot %s" % \
                              (os.path.join(self._cime_root,"scripts", "create_newcase"),
                               self._cime_model,test_dir, grid, machine, compiler, compset, test_case, self._project,
                               sharedlibroot)
        if (test_case != 'PFS'):
            create_newcase_cmd += " -nosavetiming "
        if (case_opts is not None):
            create_newcase_cmd += " -confopts _%s" % ("_".join(case_opts))
        if (test_mods is not None):
            files = Files()
            (component, mods) = test_mods.split('/')
            testmods_dir = files.get_value("TESTS_MODS_DIR",{"component": component})
            test_mod_file = os.path.join(testmods_dir, component, mods)
            if (not os.path.exists(test_mod_file)):
                self._log_output(test, "Missing testmod file '%s'" % test_mod_file)
                return False
            create_newcase_cmd += " -user_mods_dir %s" % test_mod_file
        logging.info("Calling create_newcase: "+create_newcase_cmd)
        return self._shell_cmd_for_phase(test, create_newcase_cmd, CREATE_NEWCASE_PHASE)
开发者ID:mt5555,项目名称:cime,代码行数:37,代码来源:system_test.py

示例5: __init__

# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_value [as 别名]
    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)
开发者ID:apcraig,项目名称:cime,代码行数:28,代码来源:batch.py

示例6: __init__

# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_value [as 别名]
    def __init__(self, infile=None, files=None):
        if infile is None:
            if files is None:
                files = Files()
            infile = files.get_value("PIO_SPEC_FILE")

        EntryID.__init__(self, infile)
开发者ID:Katetc,项目名称:cime,代码行数:9,代码来源:pio.py

示例7: saveLogs

# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_value [as 别名]
def saveLogs(case, lid):
###############################################################################

    logdir = case.get_value("LOGDIR")
    if logdir is not None and len(logdir) > 0:
        if not os.path.isdir(logdir):
            os.makedirs(logdir)

        caseroot = case.get_value("CASEROOT")
        rundir = case.get_value("RUNDIR")

        # get components
        files = Files()
        config_file = files.get_value("CONFIG_DRV_FILE")
        component = Component(config_file)
        comps = [x.lower() for x in component.get_valid_model_components()]
        comps = [x.replace('drv', 'cpl') for x in comps]
        model = [case.get_value("MODEL")]
        comps = comps + model

        # for each component, compress log files and copy to logdir
        for comp in comps:
            logfile = os.path.join(rundir, comp + '.log.' + lid)
            if os.path.isfile(logfile):
                f_in = open(logfile)
                f_out = gzip.open(logfile + '.gz', 'wb')
                f_out.writelines(f_in)
                f_out.close()
                f_in.close()
                os.remove(logfile)
                logfile_copy = logfile + '.gz'
                shutil.copy(logfile_copy,
                            os.path.join(caseroot, logdir, os.path.basename(logfile_copy)))
开发者ID:quantheory,项目名称:cime,代码行数:35,代码来源:case_run.py

示例8: __init__

# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_value [as 别名]
    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)
开发者ID:mnlevy1981,项目名称:cime,代码行数:36,代码来源:machines.py

示例9: __init__

# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_value [as 别名]
    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)
开发者ID:quantheory,项目名称:cime,代码行数:27,代码来源:compilers.py

示例10: __init__

# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_value [as 别名]
 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)
开发者ID:Katetc,项目名称:cime,代码行数:18,代码来源:tests.py

示例11: __init__

# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_value [as 别名]
    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)
开发者ID:cacraigucar,项目名称:cime-cacraig,代码行数:10,代码来源:grids.py

示例12: __init__

# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_value [as 别名]
    def __init__(self, infile=None):
        """
        initialize an object
        """
        if infile is None:
            files = Files()
            infile = files.get_value("CONFIG_DRV_FILE")

        EntryID.__init__(self,infile)
开发者ID:quantheory,项目名称:cime,代码行数:11,代码来源:component.py

示例13: __init__

# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_value [as 别名]
    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)
开发者ID:cacraigucar,项目名称:cime-cacraig,代码行数:12,代码来源:tests.py

示例14: __init__

# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_value [as 别名]
    def __init__(self,infile=None):
        """
        initialize an object

        >>> files = Files()
        >>> files.get_value('CASEFILE_HEADERS',resolved=False)
        '$CIMEROOT/config/config_headers.xml'
        """
        if infile is None:
            files = Files()
            infile = files.get_value('CASEFILE_HEADERS', resolved=True)
        super(Headers, self).__init__(infile)
开发者ID:Katetc,项目名称:cime,代码行数:14,代码来源:headers.py

示例15: __init__

# 需要导入模块: from CIME.XML.files import Files [as 别名]
# 或者: from CIME.XML.files.Files import get_value [as 别名]
    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()
开发者ID:mnlevy1981,项目名称:cime,代码行数:14,代码来源:grids.py


注:本文中的CIME.XML.files.Files.get_value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。