本文整理汇总了Python中conans.client.remote_registry.RemoteRegistry.remote方法的典型用法代码示例。如果您正苦于以下问题:Python RemoteRegistry.remote方法的具体用法?Python RemoteRegistry.remote怎么用?Python RemoteRegistry.remote使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类conans.client.remote_registry.RemoteRegistry
的用法示例。
在下文中一共展示了RemoteRegistry.remote方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ConanProxy
# 需要导入模块: from conans.client.remote_registry import RemoteRegistry [as 别名]
# 或者: from conans.client.remote_registry.RemoteRegistry import remote [as 别名]
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))
#.........这里部分代码省略.........
示例2: ConanProxy
# 需要导入模块: from conans.client.remote_registry import RemoteRegistry [as 别名]
# 或者: from conans.client.remote_registry.RemoteRegistry import remote [as 别名]
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
#.........这里部分代码省略.........