Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if the config_machines.xml file cannot be found give a meaningful error #4469

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CIME/XML/grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def __init__(self, infile=None, files=None, comp_interface=None):
infile = files.get_value("GRIDS_SPEC_FILE")
logger.debug(" Grid specification file is {}".format(infile))
schema = files.get_schema("GRIDS_SPEC_FILE")
expect(
os.path.isfile(infile) and os.access(infile, os.R_OK),
f" grid file not found {infile}",
)
try:
GenericXML.__init__(self, infile, schema)
except:
Expand Down
5 changes: 4 additions & 1 deletion CIME/XML/machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ def __init__(self, infile=None, files=None, machine=None, extra_machines_dir=Non
logger.debug("Verifying using schema {}".format(schema))

self.machines_dir = os.path.dirname(infile)
if os.path.exists(infile):
checked_files.append(infile)
else:
expect(False, f"file not found {infile}")

GenericXML.__init__(self, infile, schema)
checked_files.append(infile)

# Append the contents of $HOME/.cime/config_machines.xml if it exists.
#
Expand Down
4 changes: 2 additions & 2 deletions CIME/tests/test_unit_xml_machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@
class TestUnitXMLMachines(unittest.TestCase):
def setUp(self):
Machines._FILEMAP = {}

self.machine = Machines()
# read_only=False for github testing
self.machine = Machines(machine="centos7-linux")

self.machine.read_fd(io.StringIO(MACHINE_TEST_XML))

Expand Down
Loading