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


Python QgsApplication.networkContentFetcherRegistry方法代码示例

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


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

示例1: testFetchReloadUrl

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import networkContentFetcherRegistry [as 别名]
    def testFetchReloadUrl(self):
        def writeSimpleFile(content):
            with open('qgis_local_server/simple_content.txt', 'w') as f:
                f.write(content)
            self.file_content = content

        registry = QgsApplication.networkContentFetcherRegistry()
        content = registry.fetch('http://localhost:' + str(self.port) + '/qgis_local_server/simple_content.txt')
        self.loaded = False
        writeSimpleFile('my initial content')

        def check_reply():
            self.loaded = True
            self.assertEqual(content.status(), QgsFetchedContent.Finished)
            self.assertEqual(content.error(), QNetworkReply.NoError)
            self.assertNotEqual(content.filePath(), '')
            with open(content.filePath(), encoding="utf-8") as file:
                self.assertEqual(file.readline().rstrip(), self.file_content)

        content.fetched.connect(check_reply)
        content.download()
        while not self.loaded:
            app.processEvents()

        writeSimpleFile('my second content')
        content.download()
        with open(content.filePath(), encoding="utf-8") as file:
            self.assertNotEqual(file.readline().rstrip(), self.file_content)

        content.download(True)
        while not self.loaded:
            app.processEvents()

        os.remove('qgis_local_server/simple_content.txt')
开发者ID:m-kuhn,项目名称:QGIS,代码行数:36,代码来源:test_qgsnetworkcontentfetcherregistry.py

示例2: testFormUi

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import networkContentFetcherRegistry [as 别名]
    def testFormUi(self):
        layer = self.createLayer()
        config = layer.editFormConfig()

        config.setLayout(QgsEditFormConfig.GeneratedLayout)
        self.assertEqual(config.layout(), QgsEditFormConfig.GeneratedLayout)

        uiLocal = os.path.join(
            unitTestDataPath(), '/qgis_local_server/layer_attribute_form.ui')
        config.setUiForm(uiLocal)
        self.assertEqual(config.layout(), QgsEditFormConfig.UiFileLayout)

        config.setLayout(QgsEditFormConfig.GeneratedLayout)
        self.assertEqual(config.layout(), QgsEditFormConfig.GeneratedLayout)

        uiUrl = 'http://localhost:' + \
            str(self.port) + '/qgis_local_server/layer_attribute_form.ui'
        config.setUiForm(uiUrl)
        self.assertEqual(config.layout(), QgsEditFormConfig.UiFileLayout)
        content = QgsApplication.networkContentFetcherRegistry().fetch(uiUrl)
        self.assertTrue(content is not None)
        while True:
            if content.status() in (QgsFetchedContent.Finished, QgsFetchedContent.Failed):
                break
            app.processEvents()
        self.assertEqual(content.status(), QgsFetchedContent.Finished)
开发者ID:manisandro,项目名称:QGIS,代码行数:28,代码来源:test_qgseditformconfig.py

示例3: testLocalPath

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import networkContentFetcherRegistry [as 别名]
    def testLocalPath(self):
        registry = QgsApplication.networkContentFetcherRegistry()
        filePath = 'qgis_local_server/index.html'
        self.assertEqual(registry.localPath(filePath), filePath)

        # a non existent download shall return untouched the path
        self.assertEqual(registry.localPath('xxxx'), 'xxxx')

        # an existent but unfinished download should return an empty path
        content = registry.fetch('xxxx')
        self.assertEqual(registry.localPath('xxxx'), '')
开发者ID:m-kuhn,项目名称:QGIS,代码行数:13,代码来源:test_qgsnetworkcontentfetcherregistry.py

示例4: testFetchBadUrl

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import networkContentFetcherRegistry [as 别名]
    def testFetchBadUrl(self):
        registry = QgsApplication.networkContentFetcherRegistry()
        content = registry.fetch('http://x')
        self.loaded = False

        def check_reply():
            self.assertEqual(content.status(), QgsFetchedContent.Failed)
            self.assertNotEqual(content.error(), QNetworkReply.NoError)
            self.assertEqual(content.filePath(), '')
            self.loaded = True

        content.fetched.connect(check_reply)
        content.download()
        while not self.loaded:
            app.processEvents()
开发者ID:m-kuhn,项目名称:QGIS,代码行数:17,代码来源:test_qgsnetworkcontentfetcherregistry.py

示例5: testFetchGoodUrl

# 需要导入模块: from qgis.core import QgsApplication [as 别名]
# 或者: from qgis.core.QgsApplication import networkContentFetcherRegistry [as 别名]
    def testFetchGoodUrl(self):
        url = 'http://localhost:' + str(self.port) + '/qgis_local_server/index.html'
        registry = QgsApplication.networkContentFetcherRegistry()
        content = registry.fetch(url)
        self.loaded = False

        def check_reply():
            self.loaded = True
            self.assertEqual(content.status(), QgsFetchedContent.Finished)
            self.assertEqual(content.error(), QNetworkReply.NoError)
            self.assertNotEqual(content.filePath(), '')

        content.fetched.connect(check_reply)
        content.download()
        while not self.loaded:
            app.processEvents()

        self.assertEqual(registry.localPath(url), content.filePath())

        # create new content with same URL
        contentV2 = registry.fetch(url)
        self.assertEqual(contentV2.status(), QgsFetchedContent.Finished)
开发者ID:m-kuhn,项目名称:QGIS,代码行数:24,代码来源:test_qgsnetworkcontentfetcherregistry.py


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