-
Notifications
You must be signed in to change notification settings - Fork 1
/
atomic_client.py
50 lines (41 loc) · 1.79 KB
/
atomic_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import sys
import bagit
import osrf.ses
import osrf.system
conf_file = "/opensrf/etc/opensrf_core.xml"
osrf.system.System.connect(config_file=conf_file,
config_context="config.opensrf")
datastore = "/mnt/datastore"
# take a file
d = "/home/mjg/Documents/bagme"
f = "/home/mjg/Documents/bagme/architecture_scratchpad.txt"
# generate an identifier
ark = osrf.ses.ClientSession.atomic_request("psu.stewardship.identity",
"psu.stewardship.identity.mint")
print "identifier %s minted for %s" % (ark, f)
# grab its fixity value
checksum = osrf.ses.ClientSession.atomic_request("psu.stewardship.fixity",
"psu.stewardship.fixity.generate",
f,
"md5")
print "fixity %s generated for %s" % (checksum, f)
# bag it up
bag = bagit.make_bag(d)
print "bag created at %s" % bag.path
if not bag.validate():
print "bag not valid"
sys.exit(1)
# stuff in a pairtree
storage_location = osrf.ses.ClientSession.atomic_request("psu.stewardship.storage",
"psu.stewardship.storage.store",
datastore,
ark,
bag.path)
print "bag stored in %s" % storage_location
# create a version
version = osrf.ses.ClientSession.atomic_request("psu.stewardship.versioning",
"psu.stewardship.versioning.init",
storage_location)
print "version %s of content created" % version
# check fixity?
# update version?