当前位置: 首页>>代码示例>>Python>>正文


Python i18n._函数代码示例

本文整理汇总了Python中yum.i18n._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _wait

    def _wait(self, block=False):
        num = 0

        while self.jobs:
            if block:
                pid, code = os.wait()
            else:
                pid, code = os.waitpid(-1, os.WNOHANG)
                if not pid:
                    break

            # urlgrabber spawns child jobs, too.  But they exit synchronously,
            # so we should never see an unknown pid here.
            assert pid in self.jobs
            po = self.jobs.pop(pid)
            if self.progress:
                self.done += po.rpm.size
                self.progress.update(self.done)
            if code != 0:
                unlink_f(po.rpm.localpath)
                self.adderror(po, _('Delta RPM rebuild failed'))
            elif not po.rpm.verifyLocalPkg():
                self.adderror(po, _('Checksum of the delta-rebuilt RPM failed'))
            else:
                os.unlink(po.localpath)
                po.localpath = po.rpm.localpath # for --downloadonly
            num += 1
        return num
开发者ID:pnasrat,项目名称:yum,代码行数:28,代码来源:drpm.py

示例2: _check_running_kernel

def _check_running_kernel(yb, md_info, msg):
    kern_pkgtup = misc.get_running_kernel_pkgtup(yb.ts)
    if kern_pkgtup[0] is None:
        return

    found_sec = False
    for (pkgtup, notice) in md_info.get_applicable_notices(kern_pkgtup):
        if found_sec or notice['type'] != 'security':
            continue
        found_sec = True
        ipkg = yb.rpmdb.searchPkgTuple(pkgtup)
        if not ipkg:
            continue # Not installed
        ipkg = ipkg[0]

        e = ''
        if kern_pkgtup[2] != '0':
            e = '%s:' % kern_pkgtup[2]
        rpkg = '%s-%s%s-%s.%s' % (kern_pkgtup[0], e,
                                  kern_pkgtup[3], kern_pkgtup[4],
                                  kern_pkgtup[1])

        msg(_('Security: %s is an installed security update') % ipkg)
        msg(_('Security: %s is the currently running version') % rpkg)
        break
开发者ID:james-antill,项目名称:yum,代码行数:25,代码来源:updateinfo.py

示例3: exclude_updates

def exclude_updates(base, filters=None):
    '''
    Exclude all packages to do with updates, using the updateinfo data.
    '''
    
    def ysp_del_pkg(pkg, reason="updateinfo"):
        """ Deletes a package from all trees that yum knows about """
        base.verbose_logger.log(INFO_1,
                                _(" --> %s from %s excluded (%s)") %
                                (pkg,pkg.repoid, reason))
        pkg.repo.sack.delPackage(pkg)

    if filters is None:
        filters = base.updateinfo_filters
    opts = _updateinfofilter2opts(filters)

    if _no_options(opts):
        return 0, 0

    md_info = base.upinfo

    used_map = _ysp_gen_used_map(opts)

    # In theory the official API is:
    #
    # pkgs = base.pkgSack.returnPackages()
    #
    # ...however that is _extremely_ slow, deleting all packages. So we ask
    # for the list of update packages, which is all we care about.    
    upds = base.doPackageLists(pkgnarrow='updates')
    pkgs = upds.updates
    # In theory we don't need to do this in some cases, but meh.
    upds = base.doPackageLists(pkgnarrow='obsoletes')
    pkgs += upds.obsoletes

    name2tup = _get_name2oldpkgtup(base)
    
    tot = 0
    cnt = 0
    for pkg in pkgs:
        tot += 1
        name = pkg.name
        if (name not in name2tup or
            not _ysp_should_keep_pkg(opts, name2tup[name], md_info, used_map)):
            for p in base.doPackageLists(pkgnarrow='available', patterns=[pkg.name], showdups=True).available:
                ysp_del_pkg(p)
            continue
        cnt += 1

    _ysp_chk_used_map(used_map, lambda x: base.verbose_logger.warn("%s", x))

    if cnt:
        base.verbose_logger.log(INFO_1, _('%d package(s) needed for security, out of %d available') % (cnt, tot))
    else:
        base.verbose_logger.log(INFO_1, _('No packages needed for security; %d packages available' % tot))

    return cnt, tot
开发者ID:james-antill,项目名称:yum,代码行数:57,代码来源:updateinfo.py

示例4: add

    def add(self, obj, mdtype="updateinfo"):
        """ Parse a metadata from a given YumRepository, file, or filename. """

        def _rid(repoid, fmt=_(" (from %s)")):
            if not repoid:
                return ""
            return fmt % repoid

        if not obj:
            raise UpdateNoticeException
        repoid = None
        if type(obj) in (type(""), type(u"")):
            unfile = decompress(obj)
            infile = open(unfile, "rt")

        elif isinstance(obj, YumRepository):
            if obj.id not in self._repos:
                repoid = obj.id
                self._repos.append(obj.id)
                md = obj.retrieveMD(mdtype)
                if not md:
                    raise UpdateNoticeException()
                unfile = repo_gen_decompress(md, "updateinfo.xml")
                infile = open(unfile, "rt")
        elif isinstance(obj, FakeRepository):
            raise Errors.RepoMDError, "No updateinfo for local pkg"
        else:  # obj is a file object
            infile = obj

        have_dup = False
        for event, elem in safe_iterparse(infile, logger=self._logger):
            if elem.tag == "update":
                try:
                    un = UpdateNotice(elem)
                except UpdateNoticeException, e:
                    msg = _("An update notice%s is broken, skipping.") % _rid(repoid)
                    if self._vlogger:
                        self._vlogger.log(logginglevels.DEBUG_1, "%s", msg)
                    else:
                        print >> sys.stderr, msg
                    continue

                if not self.add_notice(un):
                    msg = _("Update notice %s%s is broken, or a bad duplicate, skipping.") % (
                        un["update_id"],
                        _rid(repoid),
                    )
                    if not have_dup:
                        msg += _("\nYou should report this problem to the owner of the %srepository.") % _rid(
                            repoid, "%s "
                        )
                    have_dup = True
                    if self._vlogger:
                        self._vlogger.warn("%s", msg)
                    else:
                        print >> sys.stderr, msg
开发者ID:z0by,项目名称:yum,代码行数:56,代码来源:update_md.py

示例5: exclude_updates

def exclude_updates(base, filters=None):
    '''
    Exclude all packages to do with updates, using the updateinfo data.
    '''
    
    def ysp_del_pkg(pkg, reason="updateinfo"):
        """ Deletes a package from all trees that yum knows about """
        base.verbose_logger.log(INFO_1,
                                _(" --> %s from %s excluded (%s)") %
                                (pkg,pkg.repoid, reason))
        pkg.repo.sack.delPackage(pkg)

    if filters is None:
        filters = base.updateinfo_filters
    opts = _ysp_gen_opts(filters)

    if _no_options(opts):
        return 0, 0

    md_info = base.upinfo

    used_map = _ysp_gen_used_map(opts)

    upds = base.doPackageLists(pkgnarrow='updates')
    tot = len(upds.updates)
    # In theory we don't need to do this in some cases, but meh.
    upds = base.doPackageLists(pkgnarrow='obsoletes')
    tot += len(upds.obsoletes)

    pkgs = base.pkgSack.returnPackages()
    name2tup = _get_name2oldpkgtup(base)
    
    pkgs_to_del = []
    for pkg in pkgs:
        name = pkg.name
        if (name not in name2tup or
            not _ysp_should_keep_pkg(opts, name2tup[name], md_info, used_map)):
            pkgs_to_del.append(pkg.name)
            continue
    if pkgs_to_del:
        for p in base.doPackageLists(pkgnarrow='available', patterns=pkgs_to_del, showdups=True).available:
            ysp_del_pkg(p)

    cnt = len(base.doPackageLists(pkgnarrow='updates').updates) + \
          len(base.doPackageLists(pkgnarrow='obsoletes').obsoletes)

    _ysp_chk_used_map(used_map, lambda x: base.verbose_logger.warn("%s", x))

    if cnt:
        base.verbose_logger.log(INFO_1, _('%d package(s) needed for security, out of %d available') % (cnt, tot))
    else:
        base.verbose_logger.log(INFO_1, _('No packages needed for security; %d packages available' % tot))

    return cnt, tot
开发者ID:rpm5,项目名称:yum,代码行数:54,代码来源:updateinfo.py

示例6: exclude_all

def exclude_all(base, filters=None):
    '''
    Exclude all packages, using the updateinfo data.
    '''

    def ysp_del_pkg(pkg, reason="updateinfo"):
        """ Deletes a package from all trees that yum knows about """
        base.verbose_logger.log(
            INFO_1,
            _(" --> %s from %s excluded (%s)") % (pkg, pkg.repoid, reason))
        pkg.repo.sack.delPackage(pkg)

    if filters is None:
        filters = base.updateinfo_filters
    opts = _updateinfofilter2opts(filters)

    if _no_options(opts):
        return 0, 0

    md_info = base.upinfo

    used_map = _ysp_gen_used_map(opts)

    pkgs = base.pkgSack.returnPackages()
    name2tup = _get_name2aallpkgtup(base)

    tot = 0
    cnt = 0
    for pkg in pkgs:
        tot += 1
        name = pkg.name
        if (name not in name2tup or not _ysp_should_keep_pkg(
                opts, name2tup[name], md_info, used_map)):
            ysp_del_pkg(pkg)
            continue
        cnt += 1

    _ysp_chk_used_map(used_map, lambda x: base.verbose_logger.warn("%s", x))

    if cnt:
        base.verbose_logger.log(
            INFO_1,
            _('%d package(s) needed for security, out of %d available') %
            (cnt, tot))
    else:
        base.verbose_logger.log(
            INFO_1,
            _('No packages needed for security; %d packages available' % tot))

    return cnt, tot
开发者ID:ncoghlan,项目名称:yum,代码行数:50,代码来源:updateinfo.py

示例7: _ask_user

    def _ask_user(self, question):
        if self.base.conf.assumeyes and not self.base.conf.assumeno:
            return
        elif self.base.conf.assumeno and not self.base.conf.assumeyes:
            raise YError(_("Safe and good answer. Exiting."))

        answer = raw_input(question).lower()
        answer = _(answer)
        while not ((answer in yes) or (answer in no)):
            answer = raw_input(question).lower()
            answer = _(answer)
        if answer in yes:
            return
        else:
            raise YError(_("Safe and good answer. Exiting."))
开发者ID:sean797,项目名称:yum-utils-1,代码行数:15,代码来源:copr.py

示例8: _get_data

    def _get_data(cls, req):
        """ Wrapper around response from server

        check data and print nice error in case of some error (and return None)
        otherwise return json object.
        """
        try:
            output = json.loads(req.text)
        except ValueError:
            YCliError(_("Unknown response from server."))
            return
        if req.status_code != 200:
            YCliError(_("Something went wrong:\n {0}\n".format(output["error"])))
            return
        return output
开发者ID:sean797,项目名称:yum-utils-1,代码行数:15,代码来源:copr.py

示例9: _cmd_enable

    def _cmd_enable(self, chroot):
        self._need_root()
        self._ask_user(
            """
You are about to enable a Playground repository.

Do you want to continue? [y/N]: """
        )
        api_url = "{0}/api/playground/list/".format(self.copr_url)
        req = requests.get(api_url)
        output = self._get_data(req)
        if output["output"] != "ok":
            raise YCliError(_("Unknown response from server."))
        for repo in output["repos"]:
            project_name = "{0}/{1}".format(repo["username"], repo["coprname"])
            repo_filename = "/etc/yum.repos.d/_playground_{}.repo".format(project_name.replace("/", "-"))
            try:
                # check if that repo exist? but that will result in twice
                # up calls
                api_url = "{0}/api/coprs/{1}/detail/{2}/".format(self.copr_url, project_name, chroot)
                req = requests.get(api_url)
                output2 = self._get_data(req)
                if output2 and ("output" in output2) and (output2["output"] == "ok"):
                    self._download_repo(project_name, repo_filename, chroot)
            except YError:
                # likely 404 and that repo does not exist
                pass
开发者ID:sean797,项目名称:yum-utils-1,代码行数:27,代码来源:copr.py

示例10: ysp_del_pkg

 def ysp_del_pkg(tspkg):
     """ Deletes a package within a transaction. """
     base.verbose_logger.log(
         INFO_1,
         _(" --> %s from %s removed (updateinfo)") %
         (tspkg.po, tspkg.po.ui_from_repo))
     tsinfo.remove(tspkg.pkgtup)
开发者ID:ncoghlan,项目名称:yum,代码行数:7,代码来源:updateinfo.py

示例11: dequeue_all

    def dequeue_all(self):
        """ De-Queue all delta rebuilds and spawn the rebuild processes. """

        count = total = 0
        for po in self.jobs.values() + self._future_jobs:
            count += 1
            total += po.rpm.size
        if total:
            self.verbose_logger.info(
                _("Finishing delta rebuilds of %d package(s) (%s)"), count, progress.format_number(total)
            )
            if po.repo.callback:
                if hasattr(progress, "text_meter_total_size"):
                    progress.text_meter_total_size(0)
                self.progress = po.repo.callback
                # default timescale 5s works fine with 0.3s dl updates.
                # drpm rebuild jobs do not finish that often, so bump it
                try:
                    self.progress.re.timescale = 30
                except:
                    pass  # accessing private api
                self.progress.start(
                    filename=None, url=None, text="<locally rebuilding deltarpms>", size=total  # BZ 963023
                )
                self.done = 0
        while self._future_jobs:
            self.dequeue()
开发者ID:dmnks,项目名称:yum,代码行数:27,代码来源:drpm.py

示例12: safe_iterparse

def safe_iterparse(filename, logger=None):
    """ Works like iterparse, but hides XML errors (prints a warning). """
    try:
        for event, elem in iterparse(filename):
            yield event, elem
    except SyntaxError: # Bad XML
        if logger:
            logger.critical(_("Updateinfo file is not valid XML: %s"), filename)
        else:
            print >> sys.stderr, "Updateinfo file is not valid XML:", filename
开发者ID:openebs,项目名称:vsm-image,代码行数:10,代码来源:update_md.py

示例13: _log_failure

 def _log_failure(data):
     """Log the mismatched data similarly to conflict markers in git."""
     if self._vlogger is None:
         return
     msg = _('Duplicate of %s differs in some fields:\n')
     msg %= other._md['update_id']
     msg += '<<<<<<< %s:%s\n' % (_rid(other), data)
     msg += '%r\n=======\n%r\n' % (other._md[data], self._md[data])
     msg += '>>>>>>> %s:%s' % (_rid(self), data)
     # --verbose mode enables this
     self._vlogger.log(logginglevels.DEBUG_3, msg)
开发者ID:dmnks,项目名称:yum,代码行数:11,代码来源:update_md.py

示例14: _wait

    def _wait(self, block=False):
        num = 0

        while self.jobs:
            if block:
                pid, code = os.wait()
            else:
                pid, code = os.waitpid(-1, os.WNOHANG)
                if not pid:
                    break

            # urlgrabber spawns child jobs, too.  But they exit synchronously,
            # so we should never see an unknown pid here.
            assert pid in self.jobs
            po = self.jobs.pop(pid)
            if self.progress:
                self.done += po.rpm.size
                self.progress.update(self.done)
            if code != 0:
                unlink_f(po.rpm.localpath)
                self.adderror(po, _("Delta RPM rebuild failed"))
            elif not po.rpm.verifyLocalPkg():
                self.adderror(po, _("Checksum of the delta-rebuilt RPM failed"))
            else:
                # done with drpm file, unlink when local
                if po.localpath.startswith(po.repo.pkgdir):
                    os.unlink(po.localpath)
                # rename the rpm if --downloadonly
                if po.rpm.localpath.endswith(".tmp"):
                    rpmfile = po.rpm.localpath.rsplit(".", 2)[0]
                    os.rename(po.rpm.localpath, rpmfile)
                    po.rpm.localpath = rpmfile
            num += 1

            # when blocking, one is enough
            if block:
                break
        return num
开发者ID:dmnks,项目名称:yum,代码行数:38,代码来源:drpm.py

示例15: dequeue

    def dequeue(self, block=True):
        """ Try to De-Queue a delta rebuild and spawn the rebuild process. """
        # Do this here, just to keep the zombies at bay...
        self._wait()

        if not self._future_jobs:
            return False

        if self.limit <= len(self.jobs):
            if not block:
                return False
            self.wait(len(self.jobs) - self.limit + 1)

        po = self._future_jobs.pop(0)
        args = ("-a", po.arch)
        if po.oldrpm:
            args += "-r", po.oldrpm
        args += po.localpath, po.rpm.localpath

        try:
            pid = os.spawnl(os.P_NOWAIT, APPLYDELTA, APPLYDELTA, *args)
        except OSError, e:
            raise MiscError, _("Couldn't spawn %s: %s") % (APPLYDELTA, exception2msg(e))
开发者ID:dmnks,项目名称:yum,代码行数:23,代码来源:drpm.py


注:本文中的yum.i18n._函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。