Skip to content

Commit

Permalink
WIP on #825.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjordan committed Sep 23, 2024
1 parent 15ca24a commit e855926
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
25 changes: 25 additions & 0 deletions workbench
Original file line number Diff line number Diff line change
Expand Up @@ -3474,6 +3474,31 @@ if args.check is not True and config["remind_user_to_run_check"] is True:
"Your Workbench configuration file indicates you were to be reminded to run --check."
)

if args.check is not True and "check_lock_file_path" in config:
check_lock_file_path = config["check_lock_file_path"]
if os.path.exists(check_lock_file_path):
config_file_md5 = get_file_hash_from_local(
config, config["config_file_path"], "md5"
)
with open(check_lock_file_path, "r") as check_lock_file:
check_lock_message_expected = f"Check against {config['config_file_path']} (md5 hash {config_file_md5}) OK"
check_lock_message_from_file = check_lock_file.readline()
if (
check_lock_message_expected.strip()
!= check_lock_message_from_file.strip()
):
message = f'The "check_lock_file_path" setting is present in config, but the contents of the lock file ("{check_lock_message_from_file.strip()}") do not match the expected --check lock message ("{check_lock_message_expected.strip()}").'
logging.error(message)
sys.exit("Error: " + message)
else:
message = f'Check lock file "{check_lock_file_path}" confirms --check was run. Removing lock file.'
logging.info(message)
os.remove(config["check_lock_file_path"])
else:
message = f'The "check_lock_file_path" setting is present in config but the specified lock file, "{check_lock_file_path}", does not exist.'
logging.error(message)
sys.exit("Error: " + message)

create_temp_dir(config)

if "user_prompts" in config and args.skip_user_prompts is not True:
Expand Down
16 changes: 16 additions & 0 deletions workbench_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1797,6 +1797,10 @@ def check_input(config, args):
args.config,
)

if "check_lock_file_path" in config:
if os.path.exists(config["check_lock_file_path"]):
os.remove(config["check_lock_file_path"])

ping_islandora(config, print_message=False)
check_integration_module_version(config)

Expand Down Expand Up @@ -3806,6 +3810,18 @@ def check_input(config, args):
args.config,
)

if "check_lock_file_path" in config:
with open(config["check_lock_file_path"], "a") as check_lock_file:
config_file_md5 = get_file_hash_from_local(
config, config["config_file_path"], "md5"
)
check_lock_file.write(
f'Check against {config["config_file_path"]} (md5 hash {config_file_md5}) OK'
)
logging.info(
f"Writing --check lock file \"{config['check_lock_file_path']}\"."
)

if args.contactsheet is True:
if os.path.isabs(config["contact_sheet_output_dir"]):
contact_sheet_path = os.path.join(
Expand Down

0 comments on commit e855926

Please sign in to comment.