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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
def __init__(self, infile=None, files=None): """ initialize an object """ if files is None: files = Files() schema = None GenericXML.__init__(self, infile, schema=schema)
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)
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)
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)
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)
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)
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")
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)
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
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
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))
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()
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)
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)
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
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
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")
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)
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()
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
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
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)
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
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
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)
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)
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))
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))
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)
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)
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()
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()
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"}))
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)
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)
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)
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
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