Example #1
0
 def __prepare_return(self):
     if self.__checksum:
         if self.__use_md5_checksum:
             self.__status = self.__md5_checksum.hexdigest()
         else:
             # for rsync, we don't have control on the data flow, so
             # we cannot calculate the md5 on the way
             self.__status = md5sum(self.__path_to_save)
         return self.__status
     self.__status = UrlFetcher.GENERIC_FETCH_WARN
     return self.__status
Example #2
0
 def __prepare_return(self):
     if self.__checksum:
         if self.__use_md5_checksum:
             self.__status = self.__md5_checksum.hexdigest()
         else:
             # for rsync, we don't have control on the data flow, so
             # we cannot calculate the md5 on the way
             self.__status = md5sum(self.__path_to_save)
         return self.__status
     self.__status = UrlFetcher.GENERIC_FETCH_WARN
     return self.__status
Example #3
0
    def _copy_herustic_support(self, handler, local_path,
            txc_basedir, remote_path):
        """
        Determine if it's possible to remote copy the package from other
        configured repositories to save bandwidth.
        This herustic only works with package files, not repository db files.
        Thus, it should be only enabled for these kind of uploads.
        """
        pkg_download = self.handlers_data.get('download')
        if pkg_download is None:
            # unsupported, we need at least package "download" metadatum
            # to be able to reconstruct a valid remote URI
            return None, None

        current_repository_id = self.repo
        available_repositories = self._entropy.available_repositories()
        test_repositories = []
        for repository_id, repo_meta in available_repositories.items():
            if current_repository_id == repository_id:
                # not me
                continue
            if repository_id == InstalledPackagesRepository.NAME:
                # __system__ repository doesn't have anything remotely
                # it's a fake repo, skip
                continue
            # In order to take advantage of remote copy, it is also required
            # that current working uri (handler.get_uri()) is also a packages
            # mirror of the other repository.
            if handler.get_uri() not in repo_meta['pkg_mirrors']:
                # no way
                continue
            test_repositories.append(repository_id)

        if not test_repositories:
            # sorry!
            return None, None

        test_repositories.sort()

        local_path_filename = os.path.basename(local_path)
        local_md5 = None
        for repository_id in test_repositories:
            repo_txc_basedir = \
                self._entropy.complete_remote_package_relative_path(
                    pkg_download, repository_id)
            test_remote_path = repo_txc_basedir + "/" + local_path_filename
            if not handler.is_file(test_remote_path):
                # not found on this packages mirror
                continue
            # then check md5 and compare
            remote_md5 = handler.get_md5(test_remote_path)
            if not const_isstring(remote_md5):
                # transceiver or remote server doesn't support md5sum()
                # so cannot verify the integrity
                continue
            if local_md5 is None:
                local_md5 = md5sum(local_path)
            if local_md5 == remote_md5:
                # yay! we can copy over!
                return handler.copy, (test_remote_path, remote_path)

        return None, None
Example #4
0
 def get_md5(self, remote_path):
     remote_str = self._setup_remote_path(remote_path)
     if not os.path.isfile(remote_str):
         return None
     return md5sum(remote_str)
Example #5
0
    def _copy_herustic_support(self, handler, local_path, txc_basedir,
                               remote_path):
        """
        Determine if it's possible to remote copy the package from other
        configured repositories to save bandwidth.
        This herustic only works with package files, not repository db files.
        Thus, it should be only enabled for these kind of uploads.
        """
        pkg_download = self.handlers_data.get('download')
        if pkg_download is None:
            # unsupported, we need at least package "download" metadatum
            # to be able to reconstruct a valid remote URI
            return None, None

        current_repository_id = self.repo
        available_repositories = self._entropy.available_repositories()
        test_repositories = []
        for repository_id, repo_meta in available_repositories.items():
            if current_repository_id == repository_id:
                # not me
                continue
            if repository_id == InstalledPackagesRepository.NAME:
                # __system__ repository doesn't have anything remotely
                # it's a fake repo, skip
                continue
            # In order to take advantage of remote copy, it is also required
            # that current working uri (handler.get_uri()) is also a packages
            # mirror of the other repository.
            if handler.get_uri() not in repo_meta['pkg_mirrors']:
                # no way
                continue
            test_repositories.append(repository_id)

        if not test_repositories:
            # sorry!
            return None, None

        test_repositories.sort()

        local_path_filename = os.path.basename(local_path)
        local_md5 = None
        for repository_id in test_repositories:
            repo_txc_basedir = \
                self._entropy.complete_remote_package_relative_path(
                    pkg_download, repository_id)
            test_remote_path = repo_txc_basedir + "/" + local_path_filename
            if not handler.is_file(test_remote_path):
                # not found on this packages mirror
                continue
            # then check md5 and compare
            remote_md5 = handler.get_md5(test_remote_path)
            if not const_isstring(remote_md5):
                # transceiver or remote server doesn't support md5sum()
                # so cannot verify the integrity
                continue
            if local_md5 is None:
                local_md5 = md5sum(local_path)
            if local_md5 == remote_md5:
                # yay! we can copy over!
                return handler.copy, (test_remote_path, remote_path)

        return None, None