Skip to content

Instantly share code, notes, and snippets.

@ross-spencer
Last active August 30, 2018 20:00
Show Gist options
  • Save ross-spencer/c7dc9ba6867719a1a6edd95b149efbdc to your computer and use it in GitHub Desktop.
Save ross-spencer/c7dc9ba6867719a1a6edd95b149efbdc to your computer and use it in GitHub Desktop.
Reading DSpace METS Example
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
import xml.etree.ElementTree as et
try:
tree = et.parse(sys.argv[1])
except IndexError:
sys.exit(1)
except IOError:
sys.exit(1)
root = tree.getroot()
mets_fields = {'mets_mets': '{http://www.loc.gov/METS/}mets',
'mets_name': '{http://www.loc.gov/METS/}name',
'mets_agent': '{http://www.loc.gov/METS/}agent'}
for item in root.iter():
if item.tag in mets_fields.values():
if item.tag == mets_fields.get('mets_agent'):
if item.attrib.get("ROLE") == "CUSTODIAN":
name_ = True
elif item.tag == mets_fields.get('mets_name'):
if name_:
print("Item:", item)
print("Text:", item.text.strip())
name_ = False
else:
print("Item:", item)
print("Attribs:", item.attrib.get("ID", ""))
#!/bin/bash
set -ux
# cd /usr/lib/archivematica/automation-tools/
# /usr/share/python/automation-tools/bin/python -m transfers.transfer \
# --user <user> \
# --api-key <apikey> \
# --ss-user <user> \
# --ss-api-key <apikey> \
# --transfer-source <transfer_source_uuid> \
# --config-file <config_file>
AT_LOC_UUID_ETD=2a85a7eb-b919-48b4-b986-a56a1ca6df5e
AT_LOC_UUID_OTHER=c8606394-7e81-49b3-8db9-8b3e14ae86bb
AT_LOC="/home/ross-spencer/git/mainline-archivematica/automation-tools"
cd $AT_LOC
echo `pwd`
run_at () {
python -m transfers.transfer \
--am-url "http://127.0.0.1:62080" \
--ss-url "http://127.0.0.1:62081" \
--user "test" \
--api-key "test" \
--ss-user "test" \
--ss-api-key "test" \
--transfer-source "$1"
}
run_at "$AT_LOC_UUID_ETD"
AT_RET=$?
echo $AT_RET
if [ $AT_RET > 0 ]
then
run_at "$AT_LOC_UUID_OTHER"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment