コード例 #1
0
    def get_path(self, path, package_id=None):
        """ Return the contents for the given `path` inside current layout, it can
            be a single file or the list of files in a directory

            :param package_id: will retrieve the contents from the package directory
            :param path: path relative to the cache reference or package folder
        """

        assert not os.path.isabs(path)

        if package_id is None:  # Get the file in the exported files
            folder = self.export()
        else:
            pref = PackageReference(self._ref, package_id)
            folder = self.package(pref)

        abs_path = os.path.join(folder, path)
        if not os.path.exists(abs_path):
            raise NotFoundException("The specified path doesn't exist")
        if os.path.isdir(abs_path):
            keep_python = get_env("CONAN_KEEP_PYTHON_FILES", False)
            return sorted([
                path for path in os.listdir(abs_path)
                if not discarded_file(path, keep_python)
            ])
        else:
            return load(abs_path)
コード例 #2
0
ファイル: local_file_getter.py プロジェクト: 19317362/conan
def get_path(client_cache, conan_ref, package_id, path):
    """
    :param client_cache: Conan's client cache
    :param conan_ref: Specified reference in the conan get command
    :param package_id: Specified package id (can be None)
    :param path: Path to a file, subfolder of exports (if only ref) or package (if package_id declared as well)
    :return: The real path in the local cache for the specified parameters
    """
    if package_id is None:  # Get the file in the exported files
        folder = client_cache.export(conan_ref)
    else:
        folder = client_cache.package(PackageReference(conan_ref, package_id))

    abs_path = os.path.join(folder, path)
    if not os.path.exists(abs_path):
        raise NotFoundException("The specified path doesn't exist")
    if os.path.isdir(abs_path):
        return sorted([path for path in os.listdir(abs_path) if not discarded_file(path)])
    else:
        return load(abs_path)
コード例 #3
0
ファイル: local_file_getter.py プロジェクト: xaqq/conan
def get_path(cache, ref, package_id, path):
    """
    :param cache: Conan's client cache
    :param ref: Specified reference in the conan get command
    :param package_id: Specified package id (can be None)
    :param path: Path to a file, subfolder of exports (if only ref)
                 or package (if package_id defined)
    :return: The real path in the local cache for the specified parameters
    """
    if package_id is None:  # Get the file in the exported files
        folder = cache.export(ref)
    else:
        folder = cache.package(PackageReference(ref, package_id), short_paths=None)

    abs_path = os.path.join(folder, path)
    if not os.path.exists(abs_path):
        raise NotFoundException("The specified path doesn't exist")
    if os.path.isdir(abs_path):
        return sorted([path for path in os.listdir(abs_path) if not discarded_file(path)])
    else:
        return load(abs_path)
コード例 #4
0
    def upload_package(self, package_reference, remote, retry, retry_wait):
        """Will upload the package to the first remote"""
        t1 = time.time()
        # existing package, will use short paths if defined
        package_folder = self._client_cache.package(package_reference,
                                                    short_paths=None)
        # Get all the files in that directory
        rel_files = relative_dirs(package_folder)

        self._output.rewrite_line("Checking package integrity...")
        if CONANINFO not in rel_files or CONAN_MANIFEST not in rel_files:
            logger.error("Missing info or manifest in uploading files: %s" %
                         (str(rel_files)))
            raise ConanException("Cannot upload corrupted package '%s'" %
                                 str(package_reference))

        the_files = {
            filename: os.path.join(package_folder, filename)
            for filename in rel_files if not discarded_file(filename)
        }
        logger.debug("====> Time remote_manager build_files_set : %f" %
                     (time.time() - t1))

        # If package has been modified remove tgz to regenerate it
        read_manifest, expected_manifest = self._client_cache.package_manifests(
            package_reference)

        if read_manifest is None or read_manifest.file_sums != expected_manifest.file_sums:
            self._output.writeln("")
            for fname in read_manifest.file_sums.keys():
                if read_manifest.file_sums[
                        fname] != expected_manifest.file_sums[fname]:
                    self._output.warn(
                        "Mismatched checksum for file %s (checksum: %s, expected: %s)"
                        % (fname, read_manifest.file_sums[fname],
                           expected_manifest.file_sums[fname]))

            if PACKAGE_TGZ_NAME in the_files:
                try:
                    tgz_path = os.path.join(package_folder, PACKAGE_TGZ_NAME)
                    os.unlink(tgz_path)
                except Exception:
                    pass
            logger.error("Manifests doesn't match!: %s != %s" % (str(
                read_manifest.file_sums), str(expected_manifest.file_sums)))
            raise ConanException("Cannot upload corrupted package '%s'" %
                                 str(package_reference))
        else:
            self._output.rewrite_line("Package integrity OK!")
        self._output.writeln("")
        logger.debug("====> Time remote_manager check package integrity : %f" %
                     (time.time() - t1))

        the_files = compress_conan_files(the_files, package_folder,
                                         PACKAGE_TGZ_NAME, CONANINFO,
                                         self._output)

        tmp = self._call_remote(remote, "upload_package", package_reference,
                                the_files, retry, retry_wait)
        logger.debug("====> Time remote_manager upload_package: %f" %
                     (time.time() - t1))
        return tmp