Skip to content

Commit

Permalink
Add overwrite flag
Browse files Browse the repository at this point in the history
  • Loading branch information
berkayurun committed Oct 9, 2023
1 parent 7a39b3b commit 8015993
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def controller(
goldenrun_data = {}

hdf5_file = Path(hdf5path)
if hdf5_file.is_file():
if hdf5_file.is_file() and not args.overwrite:
clogger.info("HDF5 file already exits")
try:
[
Expand All @@ -518,7 +518,9 @@ def controller(
backup_goldenrun_data,
] = read_backup(hdf5_file)
except NameError:
clogger.warning("Backup could not be found in the HDF5 file")
clogger.warning(
"Backup could not be found in the HDF5 file, run with the overwrite flag to overwrite!"
)
return config_qemu
except tables.NoSuchNodeError:
clogger.warning(
Expand All @@ -528,7 +530,9 @@ def controller(

clogger.info("Checking the backup")
if not check_backup(args, config_qemu, backup_config):
clogger.warning("Backup does not match, ending the execution!")
clogger.warning(
"Backup does not match, run with the overwrite flag to overwrite!"
)
return config_qemu

clogger.info("Backup matched and will be used")
Expand Down Expand Up @@ -778,6 +782,13 @@ def get_argument_parser():
action="store_true",
required=False,
)
parser.add_argument(
"--overwrite",
"-o",
help="Overwrite the existing file",
action="store_true",
required=False,
)
return parser


Expand Down

0 comments on commit 8015993

Please sign in to comment.