Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
replaceafill committed Aug 11, 2023
1 parent 799e271 commit 234d276
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 23 deletions.
10 changes: 6 additions & 4 deletions src/MCPClient/lib/clientScripts/archivematica_clamscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,12 @@ def version_attrs(self):


def file_already_scanned(file_uuid):
return Event.objects.filter(
file_uuid_id=file_uuid, event_type="virus check"
).exists()
return (
file_uuid != "None"
and Event.objects.filter(
file_uuid_id=file_uuid, event_type="virus check"
).exists()
)


def queue_event(file_uuid, date, scanner, passed, queue):
Expand Down Expand Up @@ -274,7 +277,6 @@ def get_scanner():
"""
choice = str(mcpclient_settings.CLAMAV_CLIENT_BACKEND).lower()
if choice not in SCANNERS_NAMES:

logger.warning(
"Unexpected antivirus scanner (CLAMAV_CLIENT_BACKEND):" ' "%s"; using %s.',
choice,
Expand Down
12 changes: 6 additions & 6 deletions src/MCPClient/lib/clientScripts/create_mets_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ def createFileSec(
GROUPID = ""
if f.filegrpuuid:
# GROUPID was determined elsewhere
GROUPID = "Group-%s" % (f.filegrpuuid)
GROUPID = f"Group-{f.filegrpuuid}"
if use == "TRIM file metadata":
use = "metadata"

Expand All @@ -1148,7 +1148,7 @@ def createFileSec(
"maildirFile",
):
# These files are in a group defined by themselves
GROUPID = "Group-%s" % (f.uuid)
GROUPID = f"Group-{f.uuid}"
if use == "maildirFile":
use = "original"
# Check for CSV-based Dublincore dmdSec
Expand Down Expand Up @@ -1194,7 +1194,7 @@ def createFileSec(
}
original_file = File.objects.filter(**kwargs).first()
if original_file is not None:
GROUPID = "Group-" + original_file.uuid
GROUPID = f"Group-{original_file.uuid}"

elif use in ("preservation", "text/ocr", "derivative"):
# Derived files should be in the original file's group
Expand All @@ -1206,7 +1206,7 @@ def createFileSec(
" where the derived file is {}".format(f.uuid)
)
raise
GROUPID = "Group-" + d.source_file_id
GROUPID = f"Group-{d.source_file_id}"

elif use == "service":
# Service files are in the original file's group
Expand All @@ -1224,10 +1224,10 @@ def createFileSec(
"currentlocation__startswith": fileFileIDPath,
}
original_file = File.objects.get(**kwargs)
GROUPID = "Group-" + original_file.uuid
GROUPID = f"Group-{original_file.uuid}"

elif use == "TRIM container metadata":
GROUPID = "Group-%s" % (f.uuid)
GROUPID = f"Group-{f.uuid}"
use = "metadata"

# Special DSPACEMETS processing
Expand Down
18 changes: 10 additions & 8 deletions src/MCPClient/lib/clientScripts/create_transfer_mets.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,10 @@ def get_premis_relationship_data(derivations, originals):
(
"related_object_identification",
("related_object_identifier_type", "UUID"),
("related_object_identifier_value", derivation.derived_file_id),
(
"related_object_identifier_value",
str(derivation.derived_file_id),
),
),
(
"related_event_identification",
Expand All @@ -356,7 +359,7 @@ def get_premis_relationship_data(derivations, originals):
(
"related_object_identification",
("related_object_identifier_type", "UUID"),
("related_object_identifier_value", original.source_file_id),
("related_object_identifier_value", str(original.source_file_id)),
),
(
"related_event_identification",
Expand Down Expand Up @@ -546,7 +549,6 @@ def get_premis_other_rights_information(rights):
def get_premis_rights_granted(rights):
rights_granted_info = ()
for rights_granted in rights.rightsstatementrightsgranted_set.all():

start_date = clean_date(rights_granted.startdate)
if rights_granted.enddateopen:
end_date = "OPEN"
Expand Down Expand Up @@ -584,7 +586,7 @@ def get_premis_object_identifiers(uuid, additional_identifiers):
(
"object_identifier",
("object_identifier_type", identifier.type),
("object_identifier_value", identifier.value),
("object_identifier_value", str(identifier.value)),
),
)

Expand Down Expand Up @@ -701,7 +703,7 @@ def event_to_premis(event):
(
"linking_agent_identifier",
("linking_agent_identifier_type", agent.identifiertype),
("linking_agent_identifier_value", agent.identifiervalue),
("linking_agent_identifier_value", str(agent.identifiervalue)),
),
)

Expand All @@ -723,7 +725,7 @@ def agent_to_premis(agent):
(
"agent_identifier",
("agent_identifier_type", agent.identifiertype),
("agent_identifier_value", agent.identifiervalue),
("agent_identifier_value", str(agent.identifiervalue)),
),
("agent_name", agent.name),
("agent_type", agent.agenttype),
Expand Down Expand Up @@ -761,7 +763,7 @@ def rights_to_premis(rights, file_uuid):
(
"rights_statement_identifier",
("rights_statement_identifier_type", id_type),
("rights_statement_identifier_value", id_value),
("rights_statement_identifier_value", str(id_value)),
),
("rights_basis", rights_basis),
)
Expand Down Expand Up @@ -792,7 +794,7 @@ def rights_to_premis(rights, file_uuid):
(
"linking_object_identifier",
("linking_object_identifier_type", "UUID"),
("linking_object_identifier_value", file_uuid),
("linking_object_identifier_value", str(file_uuid)),
),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_file_info_from_mets(job, mets, file_):
checksum and checksum_type, as they are described in the original METS
document of the transfer. The dict will be empty or missing keys on error.
"""
fsentry = mets.get_file(file_uuid=file_.uuid)
fsentry = mets.get_file(file_uuid=str(file_.uuid))
if not fsentry:
job.print_error(f"FSEntry with UUID {file_.uuid} not found in METS")
return {}
Expand Down
2 changes: 1 addition & 1 deletion src/MCPServer/lib/server/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def get_file_replacement_mapping(file_obj, unit_directory):

mapping.update(
{
r"%fileUUID%": file_obj.pk,
r"%fileUUID%": str(file_obj.pk),
r"%originalLocation%": file_obj.originallocation,
r"%currentLocation%": file_obj.currentlocation,
r"%fileGrpUse%": file_obj.filegrpuse,
Expand Down
2 changes: 1 addition & 1 deletion src/MCPServer/tests/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def test_package_files_with_non_ascii_names(tmp_path):
assert len(result) == 1

# And it is the file we just created
assert result[0]["%fileUUID%"] == kwargs["uuid"]
assert result[0]["%fileUUID%"] == str(kwargs["uuid"])
assert result[0]["%currentLocation%"] == kwargs["currentlocation"]
assert result[0]["%fileGrpUse%"] == kwargs["filegrpuse"]

Expand Down
2 changes: 1 addition & 1 deletion src/archivematicaCommon/lib/dicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def frommodel(type_="file", sip=None, file_=None, expand_path=True):
rd["%relativeLocation%"] = relative_location

if file_:
rd["%fileUUID%"] = file_.uuid
rd["%fileUUID%"] = str(file_.uuid)
try:
base_location = file_.sip.currentpath
except:
Expand Down
2 changes: 1 addition & 1 deletion src/dashboard/src/components/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def approve_transfer(request):
msg = "Unable to start the transfer."
LOGGER.error("%s %s (db_transfer_path=%s)", msg, err, db_transfer_path)
return _error_response(msg, status_code=500)
return _ok_response("Approval successful.", uuid=unit_uuid)
return _ok_response("Approval successful.", uuid=str(unit_uuid))


def get_modified_standard_transfer_path(transfer_type=None):
Expand Down

0 comments on commit 234d276

Please sign in to comment.