本文整理汇总了Python中sword2.Connection.get_deposit_receipt方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.get_deposit_receipt方法的具体用法?Python Connection.get_deposit_receipt怎么用?Python Connection.get_deposit_receipt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sword2.Connection
的用法示例。
在下文中一共展示了Connection.get_deposit_receipt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_31_delete_container
# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_deposit_receipt [as 别名]
def test_31_delete_container(self):
conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO,
error_response_raises_exceptions=False)
conn.get_service_document()
col = conn.sd.workspaces[0][1][0]
#e = Entry(title="Multipart deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
with open(PACKAGE) as pkg:
receipt = conn.create(col_iri = col.href,
#metadata_entry = e,
payload=pkg,
mimetype=PACKAGE_MIME,
filename="example.zip",
packaging = 'http://purl.org/net/sword/package/SimpleZip')
# ensure that we have a receipt (the server may not give us one
# by default)
edit_iri = receipt.location
receipt = conn.get_deposit_receipt(edit_iri)
# delete the container
new_receipt = conn.delete_container(dr=receipt)
assert new_receipt.code == 204
assert new_receipt.dom is None
# the next check is that this 404s appropriately now
another_receipt = conn.get_deposit_receipt(edit_iri)
示例2: complete_submission
# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_deposit_receipt [as 别名]
def complete_submission(self,edit_uri):
opener = self.get_opener()
conn = Connection(self.sword2_sd_url, error_response_raises_exceptions=False, http_impl=UrlLib2Layer(opener))
receipt = None
try:
receipt = conn.get_deposit_receipt(edit_uri)
except urllib2.URLError as e:
# The sword2 client does not catch network errors like this one,
# which indicates that the url couldn't be reached at all
# don't do anything about it here - we'll try again in a moment
# and then error out appropriately later
pass
# at this stage we need to ensure that we actually got back a deposit
# receipt
i = 0
while (receipt is None or receipt.code >= 400) and i < self.retry_limit:
err = None
if receipt is None:
err = "<unable to reach server>"
else:
err = str(receipt.code)
logger.debug("Attempt to retrieve Entry Document failed with error " + str(err) + " ... trying again in " + str(self.retry_delay) + " seconds")
i += 1
time.sleep(self.retry_delay)
try:
receipt = conn.get_deposit_receipt(edit_uri)
except urllib2.URLError as e:
# The sword2 client does not catch network errors like this one,
# which indicates that the url couldn't be reached at all
# just try again up to the retry_limit
continue
self.assertIsNotNone(receipt)
self.assertEquals(receipt.code,200)
# if we get to here we can go ahead with the deposit for real
with open( self.zipFileName, "rb") as data:
new_receipt = conn.update(dr = receipt,
payload=data,
mimetype="application/zip",
filename=self.dataset_identifier + ".zip",
packaging='http://dataflow.ox.ac.uk/package/DataBankBagIt')
self.assertIsNotNone(new_receipt)
self.assertEquals(new_receipt.code,204)
return
示例3: test_17_advanced_replace_file_content
# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_deposit_receipt [as 别名]
def test_17_advanced_replace_file_content(self):
conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO)
conn.get_service_document()
col = conn.sd.workspaces[0][1][0]
with open(PACKAGE) as pkg:
receipt = conn.create(col_iri = col.href,
payload=pkg,
mimetype=PACKAGE_MIME,
filename="example.zip",
packaging='http://purl.org/net/sword/package/SimpleZip')
# ensure that we have a receipt (the server may not give us one
# by default)
receipt = conn.get_deposit_receipt(receipt.location)
# now do the replace
with open(PACKAGE) as pkg:
new_receipt = conn.update(dr = receipt,
payload=pkg,
mimetype=PACKAGE_MIME,
filename="update.zip",
packaging='http://purl.org/net/sword/package/SimpleZip',
metadata_relevant=True)
assert new_receipt.code == 204
assert new_receipt.dom is None
示例4: test_15_retrieve_content_em_iri_as_feed
# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_deposit_receipt [as 别名]
def test_15_retrieve_content_em_iri_as_feed(self):
conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
conn.get_service_document()
col = conn.sd.workspaces[0][1][0]
with open(PACKAGE) as pkg:
receipt = conn.create(col_iri = col.href,
payload=pkg,
mimetype=PACKAGE_MIME,
filename="example.zip",
packaging='http://purl.org/net/sword/package/SimpleZip')
# ensure that we have a receipt (the server may not give us one
# by default)
receipt = conn.get_deposit_receipt(receipt.location)
# we're going to work with the edit_media_feed iri
assert receipt.edit_media_feed is not None
response = conn.get_resource(content_iri=receipt.edit_media_feed)
assert response.code == 200
assert response.content is not None
# the response should be an xml document, so let's see if we can parse
# it. This should give us an exception which will fail the test if not
dom = etree.fromstring(response.content)
示例5: test_30_advanced_add_multipart
# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_deposit_receipt [as 别名]
def test_30_advanced_add_multipart(self):
conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO)
conn.get_service_document()
col = conn.sd.workspaces[0][1][0]
e = Entry(title="Multipart deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
with open(PACKAGE) as pkg:
receipt = conn.create(col_iri = col.href,
metadata_entry = e,
payload=pkg,
mimetype=PACKAGE_MIME,
filename="example.zip",
packaging = 'http://purl.org/net/sword/package/SimpleZip')
# ensure that we have a receipt (the server may not give us one
# by default)
receipt = conn.get_deposit_receipt(receipt.location)
ne = Entry(title="Multipart deposit", id="asidjasidj", dcterms_identifier="http://another/",
dcterms_creator="Me!", dcterms_rights="CC0")
with open(PACKAGE) as pkg:
new_receipt = conn.append(dr=receipt,
metadata_entry=ne,
payload=pkg,
filename="addition.zip",
mimetype=PACKAGE_MIME,
packaging="http://purl.org/net/sword/package/SimpleZip",
in_progress=True,
metadata_relevant=True)
assert new_receipt.code >= 200 and new_receipt.code < 400
示例6: test_21_advanced_replace_with_multipart
# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_deposit_receipt [as 别名]
def test_21_advanced_replace_with_multipart(self):
conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO)
conn.get_service_document()
col = conn.sd.workspaces[0][1][0]
e = Entry(title="Multipart deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
with open(PACKAGE) as pkg:
receipt = conn.create(col_iri = col.href,
metadata_entry = e,
payload=pkg,
mimetype=PACKAGE_MIME,
filename="example.zip",
packaging = 'http://purl.org/net/sword/package/SimpleZip')
# ensure that we have a receipt (the server may not give us one
# by default)
receipt = conn.get_deposit_receipt(receipt.location)
# now do the replace
ne = Entry(title="A multipart update", id="asidjasidj", dcterms_abstract="new abstract", dcterms_identifier="http://elsewhere/")
with open(PACKAGE) as pkg:
new_receipt = conn.update(dr = receipt,
metadata_entry = ne,
payload=pkg,
mimetype=PACKAGE_MIME,
filename="update.zip",
packaging='http://purl.org/net/sword/package/SimpleZip',
in_progress=True)
assert new_receipt.code == 204 or new_receipt.code == 200
if new_receipt.code == 204:
assert new_receipt.dom is None
if new_receipt.code == 200:
assert new_receipt.parsed == True
assert new_receipt.valid == True
示例7: test_09_basic_retrieve_deposit_receipt
# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_deposit_receipt [as 别名]
def test_09_basic_retrieve_deposit_receipt(self):
conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
conn.get_service_document()
col = conn.sd.workspaces[0][1][0]
e = Entry(title="An entry only deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
receipt = conn.create(col_iri = col.href, metadata_entry = e)
# we're going to work with the location
assert receipt.location != None
new_receipt = conn.get_deposit_receipt(receipt.location)
assert new_receipt.code == 200
assert new_receipt.parsed == True
assert new_receipt.valid == True
示例8: test_23_basic_add_content_to_resource_single_file
# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_deposit_receipt [as 别名]
def test_23_basic_add_content_to_resource_single_file(self):
conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
conn.get_service_document()
col = conn.sd.workspaces[0][1][0]
with open(PACKAGE) as pkg:
receipt = conn.create(col_iri = col.href,
payload=pkg,
mimetype=PACKAGE_MIME,
filename="example.zip",
packaging = 'http://purl.org/net/sword/package/SimpleZip')
receipt = conn.get_deposit_receipt(receipt.location)
with open(PACKAGE) as pkg:
new_receipt = conn.add_file_to_resource(receipt.edit_media, pkg, "addition.zip", mimetype=PACKAGE_MIME)
assert new_receipt.code >= 200 and new_receipt.code < 400
assert new_receipt.location is not None
assert new_receipt.location != receipt.edit_media
示例9: test_01_massive_file
# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_deposit_receipt [as 别名]
def test_01_massive_file(self):
http = UrlLib2Layer()
conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, http_impl=http)
conn.get_service_document()
col = conn.sd.workspaces[0][1][0]
e = Entry(title="scalability testing", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
receipt = conn.create(col_iri = col.href, metadata_entry = e)
receipt = conn.get_deposit_receipt(receipt.location)
# now do the replace
with open(PACKAGE) as pkg:
new_receipt = conn.update(dr = receipt,
payload=pkg,
mimetype=PACKAGE_MIME,
filename="massive_file.zip",
packaging='http://purl.org/net/sword/package/Binary')
assert new_receipt.code == 204
示例10: test_09_basic_retrieve_deposit_receipt
# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_deposit_receipt [as 别名]
def test_09_basic_retrieve_deposit_receipt(self):
conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
conn.get_service_document()
col = conn.sd.workspaces[0][1][0]
with open(PACKAGE) as pkg:
receipt = conn.create(col_iri = col.href,
payload=pkg,
mimetype=PACKAGE_MIME,
filename="example.zip",
packaging = 'http://purl.org/net/sword/package/SimpleZip')
# we're going to work with the location
assert receipt.location != None
new_receipt = conn.get_deposit_receipt(receipt.location)
assert new_receipt.code == 200
assert new_receipt.parsed == True
assert new_receipt.valid == True
示例11: test_10_advanced_retrieve_deposit_receipt
# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_deposit_receipt [as 别名]
def test_10_advanced_retrieve_deposit_receipt(self):
conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO)
conn.get_service_document()
col = conn.sd.workspaces[0][1][0]
suggested_id = str(uuid.uuid4())
e = Entry(title="An entry only deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
receipt = conn.create(col_iri = col.href, metadata_entry = e,
in_progress = True,
suggested_identifier = suggested_id)
# we're going to work with the location
assert receipt.location != None
new_receipt = conn.get_deposit_receipt(receipt.location)
assert new_receipt.code == 200
assert new_receipt.parsed == True
assert new_receipt.valid == True
print new_receipt.to_xml()
# Here are some more things we can know about the receipt
# 1 - the links will all contain the suggested identifier
# 2 - the links will all contain the name of the silo
# 3 - the packaging will contain DataBankBagIt
# 4 - the DC metadata will be reflected back at us
# 5 - the atom metadata will be populated in some way
for rel, links in new_receipt.links.iteritems():
for link in links:
assert suggested_id in link['href']
assert col.title in link['href']
assert "http://dataflow.ox.ac.uk/package/DataBankBagIt" in new_receipt.packaging
# check the atom metadata
assert new_receipt.title == "An entry only deposit"
assert new_receipt.summary == "abstract"
# check the DC metadata
assert "An entry only deposit" in new_receipt.metadata["dcterms_title"]
assert "abstract" in new_receipt.metadata["dcterms_abstract"]
assert "http://whatever/" in new_receipt.metadata["dcterms_identifier"]
示例12: test_12_basic_retrieve_content_em_iri
# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_deposit_receipt [as 别名]
def test_12_basic_retrieve_content_em_iri(self):
conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
conn.get_service_document()
col = conn.sd.workspaces[0][1][0]
with open(PACKAGE) as pkg:
receipt = conn.create(col_iri = col.href,
payload=pkg,
mimetype=PACKAGE_MIME,
filename="example.zip",
packaging='http://purl.org/net/sword/package/SimpleZip')
# ensure that we have a receipt (the server may not give us one
# by default)
receipt = conn.get_deposit_receipt(receipt.location)
# we're going to work with the edit_media iri
assert receipt.edit_media is not None
resource = conn.get_resource(content_iri=receipt.edit_media)
assert resource.code == 200
assert resource.content is not None
示例13: test_10_advanced_retrieve_deposit_receipt
# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_deposit_receipt [as 别名]
def test_10_advanced_retrieve_deposit_receipt(self):
conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO)
conn.get_service_document()
col = conn.sd.workspaces[0][1][0]
with open(PACKAGE) as pkg:
receipt = conn.create(col_iri = col.href,
payload=pkg,
mimetype=PACKAGE_MIME,
filename="example.zip",
packaging = 'http://purl.org/net/sword/package/SimpleZip',
in_progress = True,
suggested_identifier = "0987654321")
# we're going to work with the location
assert receipt.location != None
new_receipt = conn.get_deposit_receipt(receipt.location)
assert new_receipt.code == 200
assert new_receipt.parsed == True
assert new_receipt.valid == True
示例14: test_16_basic_replace_file_content
# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_deposit_receipt [as 别名]
def test_16_basic_replace_file_content(self):
conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW)
conn.get_service_document()
col = conn.sd.workspaces[0][1][0]
e = Entry(title="An entry only deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
receipt = conn.create(col_iri = col.href, metadata_entry = e)
# ensure that we have a receipt (the server may not give us one
# by default)
receipt = conn.get_deposit_receipt(receipt.location)
# now do the replace
with open(PACKAGE) as pkg:
new_receipt = conn.update(dr = receipt,
payload=pkg,
mimetype=PACKAGE_MIME,
filename="update.zip",
packaging='http://purl.org/net/sword/package/SimpleZip')
assert new_receipt.code == 204
assert new_receipt.dom is None
示例15: test_19_advanced_replace_metadata
# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_deposit_receipt [as 别名]
def test_19_advanced_replace_metadata(self):
conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO)
conn.get_service_document()
col = conn.sd.workspaces[0][1][0]
e = Entry(title="An entry only deposit", id="asidjasidj", dcterms_abstract="abstract", dcterms_identifier="http://whatever/")
receipt = conn.create(col_iri = col.href, metadata_entry = e)
# ensure that we have a receipt (the server may not give us one
# by default)
receipt = conn.get_deposit_receipt(receipt.location)
# now do the replace
ne = Entry(title="A metadata update", id="asidjasidj", dcterms_abstract="new abstract", dcterms_identifier="http://elsewhere/")
new_receipt = conn.update(dr=receipt, metadata_entry=ne, in_progress=True)
assert new_receipt.code == 204 or new_receipt.code == 200
if new_receipt.code == 204:
assert new_receipt.dom is None
if new_receipt.code == 200:
assert new_receipt.parsed == True
assert new_receipt.valid == True