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


Python remote_registry.RemoteRegistry类代码示例

本文整理汇总了Python中conans.client.remote_registry.RemoteRegistry的典型用法代码示例。如果您正苦于以下问题:Python RemoteRegistry类的具体用法?Python RemoteRegistry怎么用?Python RemoteRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

    def __init__(self, base_folder=None, current_folder=None,
                 servers=None, users=None, client_version=CLIENT_VERSION,
                 min_server_compatible_version=MIN_SERVER_COMPATIBLE_VERSION):
        """
        storage_folder: Local storage path
        current_folder: Current execution folder
        servers: dict of {remote_name: TestServer}
        logins is a list of (user, password) for auto input in order
        if required==> [("lasote", "mypass"), ("other", "otherpass")]
        """
        self.users = users or {"default":
                               [(TESTING_REMOTE_PRIVATE_USER, TESTING_REMOTE_PRIVATE_PASS)]}
        self.servers = servers or {}

        self.client_version = Version(str(client_version))
        self.min_server_compatible_version = Version(str(min_server_compatible_version))

        self.base_folder = base_folder or temp_folder()
        # Define storage_folder, if not, it will be read from conf file & pointed to real user home
        self.storage_folder = os.path.join(self.base_folder, ".conan", "data")
        self.paths = ConanPaths(self.base_folder, self.storage_folder, TestBufferConanOutput())
        self.default_settings(get_env("CONAN_COMPILER", "gcc"),
                              get_env("CONAN_COMPILER_VERSION", "4.8"))

        self.init_dynamic_vars()

        save(self.paths.registry, "")
        registry = RemoteRegistry(self.paths.registry, TestBufferConanOutput())
        for name, server in self.servers.items():
            registry.add(name, server.fake_url)

        logger.debug("Client storage = %s" % self.storage_folder)
        self.current_folder = current_folder or temp_folder()
开发者ID:NoWiseMan,项目名称:conan,代码行数:33,代码来源:tools.py

示例2: update_servers

 def update_servers(self, servers):
     self.servers = servers or {}
     save(self.client_cache.registry, "")
     registry = RemoteRegistry(self.client_cache.registry, TestBufferConanOutput())
     for name, server in self.servers.items():
         if isinstance(server, TestServer):
             registry.add(name, server.fake_url)
         else:
             registry.add(name, server)
开发者ID:19317362,项目名称:conan,代码行数:9,代码来源:tools.py

示例3: __init__

 def __init__(self, paths, user_io, remote_manager, remote_name,
              update=False, check_updates=True):
     self._paths = paths
     self._out = user_io.out
     self._remote_manager = remote_manager
     self._registry = RemoteRegistry(self._paths.registry, self._out)
     self._remote_name = remote_name
     self._update = update
     self._check_updates = check_updates
开发者ID:esteve,项目名称:conan,代码行数:9,代码来源:proxy.py

示例4: __init__

 def __init__(self, client_cache, user_io, remote_manager, remote_name,
              update=False, check_updates=False, manifest_manager=False):
     self._client_cache = client_cache
     self._out = user_io.out
     self._remote_manager = remote_manager
     self._registry = RemoteRegistry(self._client_cache.registry, self._out)
     self._remote_name = remote_name
     self._update = update
     self._check_updates = check_updates or update  # Update forces check (and of course the update)
     self._manifest_manager = manifest_manager
开发者ID:nesono,项目名称:conan,代码行数:10,代码来源:proxy.py

示例5: __init__

 def __init__(self, paths, user_io, remote_manager, remote_name,
              update=False, check_updates=False, check_integrity=False):
     self._paths = paths
     self._out = user_io.out
     self._remote_manager = remote_manager
     self._registry = RemoteRegistry(self._paths.registry, self._out)
     self._remote_name = remote_name
     self._update = update
     self._check_updates = check_updates or update  # Update forces check
     self._check_integrity = check_integrity
开发者ID:JustgeekDE,项目名称:conan,代码行数:10,代码来源:proxy.py

示例6: refs_test

    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,代码行数:13,代码来源:registry_test.py

示例7: insert_test

 def insert_test(self):
     f = os.path.join(temp_folder(), "aux_file")
     save(f, "conan.io https://server.conan.io True")
     registry = RemoteRegistry(f, TestBufferConanOutput())
     registry.add("repo1", "url1", True, insert=0)
     self.assertEqual(registry.remotes, [("repo1", "url1", True),
                                         ("conan.io", "https://server.conan.io", True)])
     registry.add("repo2", "url2", True, insert=1)
     self.assertEqual(registry.remotes, [("repo1", "url1", True),
                                         ("repo2", "url2", True),
                                         ("conan.io", "https://server.conan.io", True)])
     registry.add("repo3", "url3", True, insert=5)
     self.assertEqual(registry.remotes, [("repo1", "url1", True),
                                         ("repo2", "url2", True),
                                         ("conan.io", "https://server.conan.io", True),
                                         ("repo3", "url3", True)])
开发者ID:nesono,项目名称:conan,代码行数:16,代码来源:registry_test.py

示例8: remote

    def remote(self, *args):
        """ manage remotes
        """
        parser = argparse.ArgumentParser(description=self.remote.__doc__, prog="conan remote")
        subparsers = parser.add_subparsers(dest='subcommand', help='sub-command help')

        # create the parser for the "a" command
        subparsers.add_parser('list', help='list current remotes')
        parser_add = subparsers.add_parser('add', help='add a remote')
        parser_add.add_argument('remote',  help='name of the remote')
        parser_add.add_argument('url',  help='url of the remote')
        parser_rm = subparsers.add_parser('remove', help='remove a remote')
        parser_rm.add_argument('remote',  help='name of the remote')
        parser_upd = subparsers.add_parser('update', help='update the remote url')
        parser_upd.add_argument('remote',  help='name of the remote')
        parser_upd.add_argument('url',  help='url')
        subparsers.add_parser('list_ref', help='list the package recipes and its associated remotes')
        parser_padd = subparsers.add_parser('add_ref', help="associate a recipe's reference to a remote")
        parser_padd.add_argument('reference',  help='package recipe reference')
        parser_padd.add_argument('remote',  help='name of the remote')
        parser_prm = subparsers.add_parser('remove_ref', help="dissociate a recipe's reference and its remote")
        parser_prm.add_argument('reference',  help='package recipe reference')
        parser_pupd = subparsers.add_parser('update_ref', help="update the remote associated with a package recipe")
        parser_pupd.add_argument('reference',  help='package recipe reference')
        parser_pupd.add_argument('remote',  help='name of the remote')
        args = parser.parse_args(*args)

        registry = RemoteRegistry(self._conan_paths.registry, self._user_io.out)
        if args.subcommand == "list":
            for r in registry.remotes:
                self._user_io.out.info("%s: %s" % (r.name, r.url))
        elif args.subcommand == "add":
            registry.add(args.remote, args.url)
        elif args.subcommand == "remove":
            registry.remove(args.remote)
        elif args.subcommand == "update":
            registry.update(args.remote, args.url)
        elif args.subcommand == "list_ref":
            for ref, remote in registry.refs.items():
                self._user_io.out.info("%s: %s" % (ref, remote))
        elif args.subcommand == "add_ref":
            registry.add_ref(args.reference, args.remote)
        elif args.subcommand == "remove_ref":
            registry.remove_ref(args.reference)
        elif args.subcommand == "update_ref":
            registry.update_ref(args.reference, args.remote)
开发者ID:WimK,项目名称:conan,代码行数:46,代码来源:command.py

示例9: remote_remove

 def remote_remove(self, remote):
     registry = RemoteRegistry(self._client_cache.registry, self._user_io.out)
     return registry.remove(remote)
开发者ID:nesono,项目名称:conan,代码行数:3,代码来源:conan_api.py

示例10: ConanProxy

class ConanProxy(object):
    """ Class to access the conan storage, to perform typical tasks as to get packages,
    getting conanfiles, uploading, removing from remote, etc.
    It uses the RemoteRegistry to control where the packages come from.
    """
    def __init__(self, paths, user_io, remote_manager, remote_name,
                 update=False, check_updates=False, check_integrity=False):
        self._paths = paths
        self._out = user_io.out
        self._remote_manager = remote_manager
        self._registry = RemoteRegistry(self._paths.registry, self._out)
        self._remote_name = remote_name
        self._update = update
        self._check_updates = check_updates or update  # Update forces check
        self._check_integrity = check_integrity

    @property
    def registry(self):
        return self._registry

    def get_package(self, package_reference, force_build):
        """ obtain a package, either from disk or retrieve from remotes if necessary
        and not necessary to build
        """
        output = ScopedOutput(str(package_reference.conan), self._out)
        package_folder = self._paths.package(package_reference)

        # Check current package status
        if path_exists(package_folder, self._paths.store):
            if self._check_integrity or self._check_updates:
                read_manifest, expected_manifest = self._paths.package_manifests(package_reference)

            if self._check_integrity:  # Check if package is corrupted
                if read_manifest.file_sums != expected_manifest.file_sums:
                    # If not valid package, ensure empty folder
                    output.warn("Bad package '%s' detected! Removing "
                                "package directory... " % str(package_reference.package_id))
                    rmdir(package_folder)

            if self._check_updates:
                try:  # get_conan_digest can fail, not in server
                    upstream_manifest = self.get_package_digest(package_reference)
                    if upstream_manifest.file_sums != read_manifest.file_sums:
                        if upstream_manifest.time > read_manifest.time:
                            output.warn("Current package is older than remote upstream one")
                            if self._update:
                                output.warn("Removing it to retrieve or build an updated one")
                                rmdir(package_folder)
                        else:
                            output.warn("Current package is newer than remote upstream one")
                except ConanException:
                    pass

        if not force_build:
            local_package = os.path.exists(package_folder)
            if local_package:
                output = ScopedOutput(str(package_reference.conan), self._out)
                output.info('Already installed!')
                return True
            return self._retrieve_remote_package(package_reference, output)

        return False

    def get_conanfile(self, conan_reference):
        output = ScopedOutput(str(conan_reference), self._out)

        def _refresh():
            conan_dir_path = self._paths.export(conan_reference)
            rmdir(conan_dir_path)
            rmdir(self._paths.source(conan_reference), True)  # It might need to remove shortpath
            current_remote, _ = self._get_remote(conan_reference)
            output.info("Retrieving from remote '%s'..." % current_remote.name)
            self._remote_manager.get_conanfile(conan_reference, current_remote)
            if self._update:
                output.info("Updated!")
            else:
                output.info("Installed!")

        # check if it is in disk
        conanfile_path = self._paths.conanfile(conan_reference)

        path_exist = path_exists(conanfile_path, self._paths.store)

        if path_exist:
            if self._check_integrity:  # Check if package is corrupted
                read_manifest, expected_manifest = self._paths.conan_manifests(conan_reference)
                if read_manifest.file_sums != expected_manifest.file_sums:
                    output.warn("Bad conanfile detected! Removing export directory... ")
                    _refresh()
            else:  # Check for updates
                if self._check_updates:
                    ret = self.update_available(conan_reference)
                    if ret != 0:  # Found and not equal
                        remote, ref_remote = self._get_remote(conan_reference)
                        if ret == 1:
                            if not self._update:
                                if remote != ref_remote:  # Forced new remote
                                    output.warn("There is a new conanfile in '%s' remote. "
                                                "Execute 'install -u -r %s' to update it."
                                                % (remote.name, remote.name))
#.........这里部分代码省略.........
开发者ID:JustgeekDE,项目名称:conan,代码行数:101,代码来源:proxy.py

示例11: _handle_remotes

def _handle_remotes(registry_path, remote_file, output):
    registry = RemoteRegistry(registry_path, output)
    new_registry = RemoteRegistry(remote_file, output)
    registry.define_remotes(new_registry.remotes)
开发者ID:19317362,项目名称:conan,代码行数:4,代码来源:config_installer.py

示例12: remote_update

 def remote_update(self, remote, url, verify_ssl=True):
     registry = RemoteRegistry(self._client_cache.registry, self._user_io.out)
     return registry.update(remote, url, verify_ssl)
开发者ID:nesono,项目名称:conan,代码行数:3,代码来源:conan_api.py

示例13: remote_update_ref

 def remote_update_ref(self, reference, remote):
     registry = RemoteRegistry(self._client_cache.registry, self._user_io.out)
     return registry.update_ref(reference, remote)
开发者ID:nesono,项目名称:conan,代码行数:3,代码来源:conan_api.py

示例14: ConanProxy

class ConanProxy(object):
    """ Class to access the conan storage, to perform typical tasks as to get packages,
    getting conanfiles, uploading, removing from remote, etc.
    It uses the RemoteRegistry to control where the packages come from.
    """
    def __init__(self, client_cache, user_io, remote_manager, remote_name,
                 update=False, check_updates=False, manifest_manager=False):
        self._client_cache = client_cache
        self._out = user_io.out
        self._remote_manager = remote_manager
        self._registry = RemoteRegistry(self._client_cache.registry, self._out)
        self._remote_name = remote_name
        self._update = update
        self._check_updates = check_updates or update  # Update forces check (and of course the update)
        self._manifest_manager = manifest_manager

    @property
    def registry(self):
        return self._registry

    def package_available(self, package_ref, short_paths, check_outdated):
        """
        Returns True if there is a local or remote package available (and up to date if check_outdated).
        It wont download the package, just check its hash
        """

        output = ScopedOutput(str(package_ref.conan), self._out)
        package_folder = self._client_cache.package(package_ref, short_paths=short_paths)

        remote_info = None
        # No package in local cache
        if not os.path.exists(package_folder):
            try:
                remote_info = self.get_package_info(package_ref)
            except ConanException:
                return False  # Not local nor remote

        # Maybe we have the package (locally or in remote) but it's outdated
        if check_outdated:
            if remote_info:
                package_hash = remote_info.recipe_hash
            else:
                package_hash = self._client_cache.read_package_recipe_hash(package_folder)
            local_recipe_hash = self._client_cache.load_manifest(package_ref.conan).summary_hash
            up_to_date = local_recipe_hash == package_hash
            if not up_to_date:
                output.info("Outdated package!")
            else:
                output.info("Package is up to date")
            return up_to_date

        return True

    def get_package(self, package_ref, short_paths):
        """ obtain a package, either from disk or retrieve from remotes if necessary
        and not necessary to build
        """
        output = ScopedOutput(str(package_ref.conan), self._out)
        package_folder = self._client_cache.package(package_ref, short_paths=short_paths)

        # Check current package status
        if os.path.exists(package_folder):
            if self._check_updates:
                read_manifest = self._client_cache.load_package_manifest(package_ref)
                try:  # get_conan_digest can fail, not in server
                    upstream_manifest = self.get_package_digest(package_ref)
                    if upstream_manifest != read_manifest:
                        if upstream_manifest.time > read_manifest.time:
                            output.warn("Current package is older than remote upstream one")
                            if self._update:
                                output.warn("Removing it to retrieve or build an updated one")
                                rmdir(package_folder)
                        else:
                            output.warn("Current package is newer than remote upstream one")
                except ConanException:
                    pass

        installed = False
        local_package = os.path.exists(package_folder)
        if local_package:
            output.info('Already installed!')
            installed = True
            log_package_got_from_local_cache(package_ref)
        else:
            installed = self._retrieve_remote_package(package_ref, package_folder,
                                                      output)
        self.handle_package_manifest(package_ref, installed)
        return installed

    def handle_package_manifest(self, package_ref, installed):
        if installed and self._manifest_manager:
            remote = self._registry.get_ref(package_ref.conan)
            self._manifest_manager.check_package(package_ref, remote)

    def get_recipe_sources(self, conan_reference):
        export_path = self._client_cache.export(conan_reference)
        sources_folder = os.path.join(export_path, EXPORT_SOURCES_DIR)
        if os.path.exists(sources_folder):
            return

#.........这里部分代码省略.........
开发者ID:nesono,项目名称:conan,代码行数:101,代码来源:proxy.py

示例15: remote_add

 def remote_add(self, remote, url, verify_ssl=True, insert=None):
     registry = RemoteRegistry(self._client_cache.registry, self._user_io.out)
     return registry.add(remote, url, verify_ssl, insert)
开发者ID:nesono,项目名称:conan,代码行数:3,代码来源:conan_api.py


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