#331: SimFactory does not abort if it has been given a nonexistent optionlist -------------------------+-------------------------------------------------- Reporter: hinder | Owner: mthomas Type: defect | Status: new Priority: major | Milestone: Component: SimFactory | Version: Resolution: | Keywords: -------------------------+--------------------------------------------------
Comment (by eschnett):
The problem seems to be in simlib.py, function GetCactusFile, in the last if statement
if not(os.path.exists(ff)):
This routine obtains a configuration file (e.g. an option list), and takes an argument that specifies whether this file is required to be present or not. If it is required, it outputs an error message if the file is not found, if not, it fails gracefully and returns None. In our case, an option list is not required, hence None is returned.
I believe the logic in this if statement is wrong. If a file name is specified, this file name should be returned no matter what. An additional test may be performed (to see whether the file exists), or an error message may be output, but the specified option should never be ignored and None returned.
Notice that the routine contains some duplication; e.g. the search logic to find the file is repeated twice, first for a user option that can override the MDB entry, and then for an MDB entry.
I believe the correction should be to remove the "else: ff=None" in the last if statement, and possibly also the "if required:". The latter would make both failure paths (for user options and MDB entries) the same.
A cleanup of this routine may also be helpful.