当前位置: 首页>>代码示例>>Python>>正文


Python Connection.get_service_document方法代码示例

本文整理汇总了Python中sword2.Connection.get_service_document方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.get_service_document方法的具体用法?Python Connection.get_service_document怎么用?Python Connection.get_service_document使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sword2.Connection的用法示例。


在下文中一共展示了Connection.get_service_document方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_17_advanced_replace_file_content

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_service_document [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
开发者ID:Hwesta,项目名称:python-client-sword2,代码行数:27,代码来源:test_pylons.py

示例2: test_15_retrieve_content_em_iri_as_feed

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_service_document [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)
开发者ID:Hwesta,项目名称:python-client-sword2,代码行数:27,代码来源:test_pylons.py

示例3: test_21_advanced_replace_with_multipart

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_service_document [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
开发者ID:dataflow,项目名称:python-client-sword2,代码行数:36,代码来源:test_spec.py

示例4: test_31_delete_container

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_service_document [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)
开发者ID:Hwesta,项目名称:python-client-sword2,代码行数:29,代码来源:test_pylons.py

示例5: test_30_advanced_add_multipart

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_service_document [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
开发者ID:dataflow,项目名称:python-client-sword2,代码行数:32,代码来源:test_spec.py

示例6: __init__

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_service_document [as 别名]
	def __init__(self, owner):
		raise NotImplementedError
		c = Connection(SD_URI, user_name = owner.username, user_pass=owner.password)
		c.get_service_document()

		# pick the first collection within the first workspace:
		workspace_1_title, workspace_1_collections = c.workspaces[0]
		collection = workspace_1_collections[0]

		# upload "package.zip" to this collection as a new (binary) resource:
		with open("package.zip", "r") as pkg:
		    receipt = c.create(col_iri = collection.href,
		                                payload = pkg,
		                                mimetype = "application/zip",
		                                filename = "package.zip",
		                                packaging = 'http://purl.org/net/sword/package/Binary',
		                                in_progress = True)    # As the deposit isn't yet finished


		# Add a metadata record to this newly created resource (or 'container')
		from sword2 import Entry
		# Entry can be passed keyword parameters to add metadata to the entry (namespace + '_' + tagname)
		e = Entry(id="atomid", 
		          title="atom-title",
		          dcterms_abstract = "Info about the resource....",
		          )
		# to add a new namespace:
		e.register_namespace('skos', 'http://www.w3.org/2004/02/skos/core#')
		e.add_field("skos_Concept", "...")


		# Update the metadata entry to the resource:
		updated_receipt = c.update(metadata_entry = e,
		                           dr = receipt,   # use the receipt to discover the right URI to use
		                           in_progress = False)  # finish the deposit
开发者ID:kwierman,项目名称:pyDryad,代码行数:37,代码来源:SWORD.py

示例7: preflight_submission

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_service_document [as 别名]
    def preflight_submission(self):
        opener = self.get_opener()
        
        conn = Connection(self.sword2_sd_url, error_response_raises_exceptions=False, http_impl=UrlLib2Layer(opener))
        logger.debug("Retrieving the service document")
        conn.get_service_document()
        
        logger.debug("Retrieved the service document")
        
        self.assertIsNotNone(conn.sd)
        self.assertIsNotNone(conn.sd.workspaces)
        self.assertNotEqual(len(conn.sd.workspaces),0)
        
        
        workspace = conn.sd.workspaces[0][1]
        
        # we require there to be at least one collection
        self.assertNotEqual(len(workspace),0)
        col = workspace[0]
        

        testid = "testid_"+str(uuid.uuid4())
        logger.debug("col iri = " + str(col.href))
        
        e = Entry(id=testid, title="test title", dcterms_abstract="test description")
        print str(e)
        receipt = conn.create(col_iri=col.href, metadata_entry=e, suggested_identifier=testid)
        #col.href=http://192.168.2.237/swordv2/silo/test-silo
        self.assertIsNotNone(receipt)
        self.assertEquals(receipt.code,201)
        return receipt.location
开发者ID:dataflow,项目名称:DataStage,代码行数:33,代码来源:TestDatasetSubmission.py

示例8: testServiceDocumentAccess

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_service_document [as 别名]
 def testServiceDocumentAccess(self):
     opener = self.get_opener()
     for i in range(10):
         conn = Connection(self.sword2_sd_url, error_response_raises_exceptions=False, http_impl=UrlLib2Layer(opener))
         conn.get_service_document()        
         self.assertIsNotNone(conn.sd, "Service document None (loop %d)"%(i))
         self.assertIsNotNone(conn.sd.workspaces, "Service document workspace None (loop %d)"%(i))
         self.assertNotEqual(len(conn.sd.workspaces),0, "Service document worksoacxe count %d (loop %d)"%(len(conn.sd.workspaces),i))
     return
开发者ID:dataflow,项目名称:DataStage,代码行数:11,代码来源:TestServiceDocumentAccess.py

示例9: test_04_init_from_sss_then_get_doc

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_service_document [as 别名]
 def test_04_init_from_sss_then_get_doc(self):
     conn = Connection("http://localhost:%s/sd-uri" % PORT_NUMBER, user_name="sword", user_pass="sword")
     assert conn.sd_iri == "http://localhost:%s/sd-uri" % PORT_NUMBER
     assert conn.sd == None    # Not asked to get sd doc yet
     conn.get_service_document()
     assert conn.sd != None
     assert conn.sd.parsed == True
     assert conn.sd.valid == True
     assert len(conn.sd.workspaces) == 1
开发者ID:Hwesta,项目名称:python-client-sword2,代码行数:11,代码来源:test_sss.py

示例10: preflight_submission

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_service_document [as 别名]
    def preflight_submission(self, dataset, opener, repository, silo ):
        logger.debug("Carrying out pre-flight submission")
        
        # verify that we can get a service document, and that there
        # is at least one silo and that we can authenticate
        
        if repository.sword2_sd_url is None:
            raise SwordServiceError("No sword2 service-document URL for repository configuration")
            
        # get the service document (for which we must be authenticated)
        conn = Connection(repository.sword2_sd_url, error_response_raises_exceptions=False, http_impl=UrlLib2Layer(opener))
        conn.get_service_document()
        
        # we require there to be at least one workspace
        if conn.sd is None:
            raise SwordServiceError("did not successfully retrieve a service document")
        
        if conn.sd.workspaces is None:
            raise SwordServiceError("no workspaces defined in service document")
        
        if len(conn.sd.workspaces) == 0:
            raise SwordServiceError("no workspaces defined in service document")
        
        workspace = conn.sd.workspaces[0][1]
        
        # we require there to be at least one collection
        if len(workspace) == 0:
            raise SwordServiceError("no collections defined in workspace")
            
        # FIXME: we don't currently have a mechanism to make decisions about
        # which collection to put stuff in, so we just put stuff in the first
        # one for the time being
        col = workspace[0]
        silohref = repository.homepage + "swordv2/silo/" + silo

        # assemble the entry ready for deposit, using the basic metadata
        # FIXME: is there anything further we need to do about the metadata here?
        e = Entry(id=dataset.identifier, title=dataset.title, dcterms_abstract=dataset.description)
        
        # create the item using the metadata-only approach (suppress errors along the way,
        # we'll check for them below)
        #receipt = conn.create(col_iri=col.href, metadata_entry=e, suggested_identifier=dataset.identifier)
        logger.debug( "Deposit is being created" )
        receipt = conn.create(col_iri=silohref, metadata_entry=e, suggested_identifier=dataset.identifier)
        logger.debug( "Deposit created" )
        # check for errors
        if receipt.code >= 400:
            # this is an error
            logger.debug("Received error message from server: " + receipt.to_xml())
            if receipt.error_href == "http://databank.ox.ac.uk/errors/DatasetConflict":
                raise SwordSlugRejected()
            raise SwordDepositError(receipt)
        
        logger.debug("Deposit carried out to: " + receipt.location)
        # return receipt.location
        return (receipt.alternate,receipt.location)
开发者ID:dataflow,项目名称:DataStage,代码行数:58,代码来源:sword2depositor.py

示例11: test_34_check_metadata_only_state

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_service_document [as 别名]
    def test_34_check_metadata_only_state(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)
        statement = conn.get_ore_sword_statement(receipt.ore_statement_iri)

        assert len(statement.states) == 1
        assert statement.states[0][0] == "http://databank.ox.ac.uk/state/EmptyContainer"
开发者ID:Hwesta,项目名称:python-client-sword2,代码行数:12,代码来源:test_databank.py

示例12: test_02_get_service_document_on_behalf_of

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_service_document [as 别名]
 def test_02_get_service_document_on_behalf_of(self):
     conn = Connection(SSS_URL, user_name=SSS_UN, user_pass=SSS_PW, on_behalf_of=SSS_OBO)
     conn.get_service_document()
     
     # given that the client is fully functional, testing that the
     # service document parses and is valid is sufficient.  This, obviously,
     # doesn't test the validation routine itself.
     assert conn.sd != None
     assert conn.sd.parsed == True
     assert conn.sd.valid == True 
     assert len(conn.sd.workspaces) == 1
开发者ID:Hwesta,项目名称:python-client-sword2,代码行数:13,代码来源:test_pylons.py

示例13: test_07_basic_create_resource_with_entry

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_service_document [as 别名]
 def test_07_basic_create_resource_with_entry(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)
                     
     assert receipt.code == 201
     assert receipt.location != None
     
     # these last two assertions are contingent on if we actually get a 
     # receipt back from the server (which we might not legitimately get)
     assert receipt.dom is None or receipt.parsed == True
     assert receipt.dom is None or receipt.valid == True
开发者ID:Hwesta,项目名称:python-client-sword2,代码行数:17,代码来源:test_pylons.py

示例14: test_09_basic_retrieve_deposit_receipt

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_service_document [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
开发者ID:Hwesta,项目名称:python-client-sword2,代码行数:17,代码来源:test_databank.py

示例15: test_35_check_new_zip_state

# 需要导入模块: from sword2 import Connection [as 别名]
# 或者: from sword2.Connection import get_service_document [as 别名]
 def test_35_check_new_zip_state(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)
     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')
     statement = conn.get_ore_sword_statement(receipt.ore_statement_iri)
     
     assert len(statement.states) == 1
     assert statement.states[0][0] == "http://databank.ox.ac.uk/state/ZipFileAdded"
开发者ID:Hwesta,项目名称:python-client-sword2,代码行数:18,代码来源:test_databank.py


注:本文中的sword2.Connection.get_service_document方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。