Exemple #1
0
    def download(self, package_, try_times=3):
        while try_times > 0:
            try_times -= 1
            if not self._download(package_):
                LOG.warn("download package [%s] last time [%d] failed."
                         % (package_, try_times + 1))
                time.sleep(3)
            else:
                LOG.info("[%s] download done. check md5." % package_)
                # md5 check and so on...
                if not package.check(package_):
                    LOG.error("package [%s] md5 check failed, redownload." % package_)
                    util.delete_package(package_)
                else:
                    return True

        return False
Exemple #2
0
    def download(self, package_, try_times=3):
        while try_times > 0:
            try_times -= 1
            if not self._download(package_):
                LOG.warn("download package [%s] last time [%d] failed." %
                         (package_, try_times + 1))
                time.sleep(3)
            else:
                LOG.info("[%s] download done. check md5." % package_)
                # md5 check and so on...
                if not package.check(package_):
                    LOG.error("package [%s] md5 check failed, redownload." %
                              package_)
                    util.delete_package(package_)
                else:
                    return True

        return False
Exemple #3
0
    def _after_download(self, package_):
        # delete old version, set done file
        local_packs = util.get_all_packages()
        if not local_packs:
            LOG.warn("find nothing in local paths after download.")
            return False

        if package_ not in local_packs:
            LOG.warn("not found new download package [%s] in local "
                     "store path, do nothing." % package_)
            return False

        pinfo = package.PackageInfo(package_)
        for l in local_packs:
            linfo = package.PackageInfo(l)
            if linfo.TYPE == pinfo.TYPE and package_ != l:
                # delete same type old package.
                util.delete_package(l)

        # set status to downloaded.
        return util.package_set_status(package_, util.PackageStatus.DOWNLOADED)
Exemple #4
0
    def _after_download(self, package_):
        # delete old version, set done file
        local_packs = util.get_all_packages()
        if not local_packs:
            LOG.warn("find nothing in local paths after download.")
            return False

        if package_ not in local_packs:
            LOG.warn("not found new download package [%s] in local "
                     "store path, do nothing." % package_)
            return False

        pinfo = package.PackageInfo(package_)
        for l in local_packs:
            linfo = package.PackageInfo(l)
            if linfo.TYPE == pinfo.TYPE and package_ != l:
                # delete same type old package.
                util.delete_package(l)

        # set status to downloaded.
        return util.package_set_status(package_, util.PackageStatus.DOWNLOADED)