當前位置: 首頁>>代碼示例>>Python>>正文


Python RemoteRegistry.set_ref方法代碼示例

本文整理匯總了Python中conans.client.remote_registry.RemoteRegistry.set_ref方法的典型用法代碼示例。如果您正苦於以下問題:Python RemoteRegistry.set_ref方法的具體用法?Python RemoteRegistry.set_ref怎麽用?Python RemoteRegistry.set_ref使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在conans.client.remote_registry.RemoteRegistry的用法示例。


在下文中一共展示了RemoteRegistry.set_ref方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: refs_test

# 需要導入模塊: from conans.client.remote_registry import RemoteRegistry [as 別名]
# 或者: from conans.client.remote_registry.RemoteRegistry import set_ref [as 別名]
    def refs_test(self):
        f = os.path.join(temp_folder(), "aux_file")
        registry = RemoteRegistry(f, TestBufferConanOutput())
        ref = ConanFileReference.loads("MyLib/[email protected]/stable")

        remotes = registry.remotes
        registry.set_ref(ref, remotes[0])
        remote = registry.get_ref(ref)
        self.assertEqual(remote, remotes[0])

        registry.set_ref(ref, remotes[0])
        remote = registry.get_ref(ref)
        self.assertEqual(remote, remotes[0])
開發者ID:nesono,項目名稱:conan,代碼行數:15,代碼來源:registry_test.py

示例2: ConanProxy

# 需要導入模塊: from conans.client.remote_registry import RemoteRegistry [as 別名]
# 或者: from conans.client.remote_registry.RemoteRegistry import set_ref [as 別名]

#.........這裏部分代碼省略.........
                                            "than %s's one" % remote.name)
                            else:
                                output.error("Current conanfile is newer than %s's one. "
                                             "Run 'conan remove %s' and run install again "
                                             "to replace it." % (remote.name, conan_reference))

        else:
            self._retrieve_conanfile(conan_reference, output)
        return conanfile_path

    def update_available(self, conan_reference):
        """Returns 0 if the conanfiles are equal, 1 if there is an update and -1 if
        the local is newer than the remote"""
        if not conan_reference:
            return 0
        read_manifest, _ = self._paths.conan_manifests(conan_reference)
        if read_manifest:
            try:  # get_conan_digest can fail, not in server
                upstream_manifest = self.get_conan_digest(conan_reference)
                if upstream_manifest.file_sums != read_manifest.file_sums:
                    return 1 if upstream_manifest.time > read_manifest.time else -1
            except ConanException:
                pass

        return 0

    def _retrieve_conanfile(self, conan_reference, output):
        """ returns the requested conanfile object, retrieving it from
        remotes if necessary. Can raise NotFoundException
        """
        def _retrieve_from_remote(remote):
            output.info("Trying with '%s'..." % remote.name)
            result = self._remote_manager.get_conanfile(conan_reference, remote)
            self._registry.set_ref(conan_reference, remote)
            return result

        if self._remote_name:
            output.info("Not found, retrieving from server '%s' " % self._remote_name)
            remote = self._registry.remote(self._remote_name)
            return _retrieve_from_remote(remote)
        else:
            output.info("Not found, looking in remotes...")

        remotes = self._registry.remotes
        for remote in remotes:
            logger.debug("Trying with remote %s" % remote.name)
            try:
                return _retrieve_from_remote(remote)
            # If exception continue with the next
            except (ConanOutdatedClient, ConanConnectionError) as exc:
                output.warn(str(exc))
                if remote == remotes[-1]:  # Last element not found
                    raise ConanConnectionError("All remotes failed")
            except NotFoundException as exc:
                if remote == remotes[-1]:  # Last element not found
                    logger.debug("Not found in any remote, raising...%s" % exc)
                    raise NotFoundException("Unable to find '%s' in remotes"
                                            % str(conan_reference))

        raise ConanException("No remote defined")

    def upload_conan(self, conan_reference):
        """ upload to defined remote in (-r=remote), to current remote
        or to default remote, in that order.
        If the remote is not set, set it
        """
開發者ID:JustgeekDE,項目名稱:conan,代碼行數:70,代碼來源:proxy.py

示例3: ConanProxy

# 需要導入模塊: from conans.client.remote_registry import RemoteRegistry [as 別名]
# 或者: from conans.client.remote_registry.RemoteRegistry import set_ref [as 別名]

#.........這裏部分代碼省略.........

        if self._manifest_manager:
            # Just make sure that the recipe sources are there to check
            self.get_recipe_sources(conan_reference)
            remote = self._registry.get_ref(conan_reference)
            self._manifest_manager.check_recipe(conan_reference, remote)

        return conanfile_path

    def update_available(self, conan_reference):
        """Returns 0 if the conanfiles are equal, 1 if there is an update and -1 if
        the local is newer than the remote"""
        if not conan_reference:
            return 0
        read_manifest, _ = self._client_cache.conan_manifests(conan_reference)
        if read_manifest:
            try:  # get_conan_digest can fail, not in server
                upstream_manifest = self.get_conan_digest(conan_reference)
                if upstream_manifest != read_manifest:
                    return 1 if upstream_manifest.time > read_manifest.time else -1
            except ConanException:
                pass

        return 0

    def _retrieve_recipe(self, conan_reference, output):
        """ returns the requested conanfile object, retrieving it from
        remotes if necessary. Can raise NotFoundException
        """
        def _retrieve_from_remote(remote):
            output.info("Trying with '%s'..." % remote.name)
            export_path = self._client_cache.export(conan_reference)
            result = self._remote_manager.get_recipe(conan_reference, export_path, remote)
            self._registry.set_ref(conan_reference, remote)
            return result

        if self._remote_name:
            output.info("Not found, retrieving from server '%s' " % self._remote_name)
            remote = self._registry.remote(self._remote_name)
            return _retrieve_from_remote(remote)
        else:
            output.info("Not found, looking in remotes...")

        remotes = self._registry.remotes
        for remote in remotes:
            logger.debug("Trying with remote %s" % remote.name)
            try:
                return _retrieve_from_remote(remote)
            # If exception continue with the next
            except (ConanOutdatedClient, ConanConnectionError) as exc:
                output.warn(str(exc))
                if remote == remotes[-1]:  # Last element not found
                    raise ConanConnectionError("All remotes failed")
            except NotFoundException as exc:
                if remote == remotes[-1]:  # Last element not found
                    logger.debug("Not found in any remote, raising...%s" % exc)
                    raise NotFoundException("Unable to find '%s' in remotes"
                                            % str(conan_reference))

        raise ConanException("No remote defined")

    def complete_recipe_sources(self, conan_reference, force_complete=True):
        export_path = self._client_cache.export(conan_reference)
        sources_folder = os.path.join(export_path, EXPORT_SOURCES_DIR)
        ignore_deleted_file = None
        if not os.path.exists(sources_folder):
開發者ID:nesono,項目名稱:conan,代碼行數:70,代碼來源:proxy.py


注:本文中的conans.client.remote_registry.RemoteRegistry.set_ref方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。