Skip to content

Commit

Permalink
fix QChemErrorHandler file renaming on Windows: os.rename -> os.replace
Browse files Browse the repository at this point in the history
os.rename(self.input_file, self.input_file + ".last")
E       FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'mol.qin' -> 'mol.qin.last'
  • Loading branch information
janosh committed Mar 9, 2024
1 parent 49aa9f9 commit 3614903
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion custodian/qchem/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,6 @@ def correct(self):
) and str(self.qcinp.geom_opt["initial_hessian"]).lower() == "read":
del self.qcinp.geom_opt["initial_hessian"]
actions.append({"initial_hessian": "deleted"})
os.rename(self.input_file, self.input_file + ".last")
os.replace(self.input_file, f"{self.input_file}.last")
self.qcinp.write_file(self.input_file)
return {"errors": self.errors, "warnings": self.warnings, "actions": actions}

0 comments on commit 3614903

Please sign in to comment.