Skip to content

Commit cd6a885

Browse files
author
Dominick Leppich
committed
task: make mets migration more robust
1 parent eaa3764 commit cd6a885

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

migration/lib/api.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
import requests
33
import json
4+
import sys
45

56
SCHEMA_INSERTION_URL = 'http://{{HOST}}:{{PORT}}/api/v1/schemas'
67
SCHEMA_LOOKUP_URL = 'http://{{HOST}}:{{PORT}}/api/v1/schemas/{{SCHEMA_ID}}'
@@ -61,7 +62,16 @@ def query(self, url, obj=None, method='POST'):
6162
response = requests.request(method, url=url, headers=HEADERS, data=payload)
6263
try:
6364
# Check for success
64-
if response.status_code // 100 != 2:
65+
if response.status_code == 401 or response.status_code == 403:
66+
error_msg = f'API call was not successful, reason: Authentification'
67+
logging.critical(error_msg)
68+
sys.exit(1)
69+
raise Exception(error_msg)
70+
if response.status_code == 404:
71+
error_msg = f'API call was not successful, reason: Entity not found {url}'
72+
logging.warning(error_msg)
73+
raise Exception(error_msg)
74+
elif response.status_code // 100 != 2:
6575
error_msg = f'API call was not successful, reason:\n{extract_error_from_response(response)}'
6676
logging.warning(error_msg)
6777
raise Exception(error_msg)

migration/lib/mets_manipulator.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ def process_manual_id_reference(self, node):
141141
self.changed = True
142142
except Exception as e:
143143
msg = f'Unable to read ID {node.text}!'
144-
logging.critical(msg)
145-
raise Exception(msg)
144+
logging.warn(msg)
145+
#raise Exception(msg)
146146

147147
def dump_node(node):
148148
attributes = ' '.join(f'{k}="{v}"' for k, v in node.attrib.items())

0 commit comments

Comments
 (0)