コード例 #1
0
    def _work_loop(self):
        # if self.cnt_long_enough():
        while self.running:
            try:
                local_packs = util.get_all_packages()
                remote_packs = []
                with ConnecterMaintainer(self):
                    rlist = self.downloader.get_list()
                    LOG.debug("get remote package list is [%s]" % rlist)
                    for f in rlist:
                        if self._remote_package_check(f):
                            remote_packs.append(f)
                        else:
                            LOG.warn("package [%s] not legal, ignore" % f)

                    if not remote_packs:
                        LOG.info("remote packages list is empty.")

                    # if packages not exist in remote, we do not
                    # need to handle related update packages.
                    for rp in remote_packs:
                        LOG.debug("check remote package [%s]." % rp)
                        if self._need_download(local_packs, rp):
                            if self.download(rp):
                                if not self._after_download(rp):
                                    LOG.error(
                                        "after-download processing failed, abort install."
                                    )
                                else:
                                    self._install(rp)
                            else:
                                LOG.info(
                                    "can not make a correct download for [%s],"
                                    " wait for next around." % remote_packs)
                        else:
                            LOG.debug(
                                "remote package [%s] not need to download." %
                                rp)

            except Exception as e:
                LOG.error("caught exception in main loop [%s]." % e.message)
                LOG.debug(traceback.format_exc())

            self._wait_for_next()

        return rlist
コード例 #2
0
ファイル: updater.py プロジェクト: gcloud-os/auto-updater
    def _work_loop(self):
        # if self.cnt_long_enough():
        while self.running:
            try:
                local_packs = util.get_all_packages()
                remote_packs = []
                with ConnecterMaintainer(self):
                    rlist = self.downloader.get_list()
                    LOG.debug("get remote package list is [%s]" % rlist)
                    for f in rlist:
                        if self._remote_package_check(f):
                            remote_packs.append(f)
                        else:
                            LOG.warn("package [%s] not legal, ignore" % f)

                    if not remote_packs:
                        LOG.info("remote packages list is empty.")

                    # if packages not exist in remote, we do not
                    # need to handle related update packages.
                    for rp in remote_packs:
                        LOG.debug("check remote package [%s]." % rp)
                        if self._need_download(local_packs, rp):
                            if self.download(rp):
                                if not self._after_download(rp):
                                    LOG.error("after-download processing failed, abort install.")
                                else:
                                    self._install(rp)
                            else:
                                LOG.info("can not make a correct download for [%s],"
                                         " wait for next around." % remote_packs)
                        else:
                            LOG.debug("remote package [%s] not need to download." % rp)

            except Exception as e:
                LOG.error("caught exception in main loop [%s]." % e.message)
                LOG.debug(traceback.format_exc())

            self._wait_for_next()

        return rlist
コード例 #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)
コード例 #4
0
ファイル: updater.py プロジェクト: gcloud-os/auto-updater
    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)