示例#1
0
def show_lock_owner(pid, logger):
    """Output information about another process that is holding the
    yum lock.

    :param pid: the process id number of the process holding the yum
       lock
    :param logger: the logger to output the information to
    :return: a dictionary containing information about the process.
       This is the same as the dictionary returned by
       :func:`get_process_info`.
    """
    ps = get_process_info(pid)
    if not ps:
        return None

    # This yumBackend isn't very friendly, so...
    if ps['name'] == 'yumBackend.py':
        nmsg = _("  The other application is: PackageKit")
    else:
        nmsg = _("  The other application is: %s") % ps['name']

    logger.critical("%s", nmsg)
    logger.critical(
        _("    Memory : %5s RSS (%5sB VSZ)") % (format_number(
            int(ps['vmrss']) * 1024), format_number(int(ps['vmsize']) * 1024)))

    ago = seconds_to_ui_time(int(time.time()) - ps['start_time'])
    logger.critical(
        _("    Started: %s - %s ago") % (time.ctime(ps['start_time']), ago))
    logger.critical(_("    State  : %s, pid: %d") % (ps['state'], pid))

    return ps
示例#2
0
文件: utils.py 项目: davidhrbac/dnf
def show_lock_owner(pid, logger):
    """Output information about another process that is holding the
    yum lock.

    :param pid: the process id number of the process holding the yum
       lock
    :param logger: the logger to output the information to
    :return: a dictionary containing information about the process.
       This is the same as the dictionary returned by
       :func:`get_process_info`.
    """
    ps = get_process_info(pid)
    if not ps:
        return None

    # This yumBackend isn't very friendly, so...
    if ps['name'] == 'yumBackend.py':
        nmsg = _("  The other application is: PackageKit")
    else:
        nmsg = _("  The other application is: %s") % ps['name']

    logger.critical("%s", nmsg)
    logger.critical(_("    Memory : %5s RSS (%5sB VSZ)") %
                    (format_number(int(ps['vmrss']) * 1024),
                     format_number(int(ps['vmsize']) * 1024)))
    
    ago = seconds_to_ui_time(int(time.time()) - ps['start_time'])
    logger.critical(_("    Started: %s - %s ago") %
                    (time.ctime(ps['start_time']), ago))
    logger.critical(_("    State  : %s, pid: %d") % (ps['state'], pid))

    return ps
示例#3
0
def out_mem(pid):
    ps = {}
    for line in open("/proc/%d/status" % pid):
        if line[-1] != '\n':
            continue
        data = line[:-1].split(':\t', 1)
        if data[1].endswith(' kB'):
            data[1] = data[1][:-3]
        ps[data[0].strip().lower()] = data[1].strip()
    if 'vmrss' in ps and 'vmsize' in ps:
        print "* Memory : %5s RSS (%5sB VSZ)" % \
                    (format_number(int(ps['vmrss']) * 1024),
                     format_number(int(ps['vmsize']) * 1024))
示例#4
0
def out_mem(pid):
    ps = {}
    for line in open("/proc/%d/status" % pid):
        if line[-1] != '\n':
            continue
        data = line[:-1].split(':\t', 1)
        if data[1].endswith(' kB'):
            data[1] = data[1][:-3]
        ps[data[0].strip().lower()] = data[1].strip()
    if 'vmrss' in ps and 'vmsize' in ps:
        print "* Memory : %5s RSS (%5sB VSZ)" % \
                    (format_number(int(ps['vmrss']) * 1024),
                     format_number(int(ps['vmsize']) * 1024))
示例#5
0
文件: drpm.py 项目: dmnks/yum
    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()
示例#6
0
文件: drpm.py 项目: wenjiedeng/yum
    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,  # BZ 963023
                    text='<locally rebuilding deltarpms>',
                    size=total)
                self.done = 0
        while self._future_jobs:
            self.dequeue()
    def __str__(self):
        return """\
Timestamp: %s
Size:      %5s (%d)
MD5:       %s
SHA1:      %s
SHA256:    %s
SHA512:    %s
""" % (time.ctime(self.timestamp), format_number(self.size), self.size,
       self.md5, self.sha1, self.sha256, self.sha512)
示例#8
0
def show_lock_owner(pid, logger):
    if not pid:
        return

    ps = get_process_info(pid)
    # This yumBackend isn't very friendly, so...
    if ps is not None and ps['name'] == 'yumBackend.py':
        nmsg = _("  The other application is: PackageKit")
    else:
        nmsg = _("  The other application is: %s") % ps['name']

    logger.critical("%s", nmsg)
    logger.critical(_("    Memory : %5s RSS (%5sB VSZ)") %
                    (format_number(int(ps['vmrss']) * 1024),
                     format_number(int(ps['vmsize']) * 1024)))
    
    ago = seconds_to_ui_time(int(time.time()) - ps['start_time'])
    logger.critical(_("    Started: %s - %s ago") %
                    (time.ctime(ps['start_time']), ago))
    logger.critical(_("    State  : %s, pid: %d") % (ps['state'], pid))
示例#9
0
文件: utils.py 项目: rhauser/ayum
def show_lock_owner(pid, logger):
    ps = get_process_info(pid)
    if not ps:
        return None

    # This yumBackend isn't very friendly, so...
    if ps['name'] == 'yumBackend.py':
        nmsg = _("  The other application is: PackageKit")
    else:
        nmsg = _("  The other application is: %s") % ps['name']

    logger.critical("%s", nmsg)
    logger.critical(_("    Memory : %5s RSS (%5sB VSZ)") %
                    (format_number(int(ps['vmrss']) * 1024),
                     format_number(int(ps['vmsize']) * 1024)))
    
    ago = seconds_to_ui_time(int(time.time()) - ps['start_time'])
    logger.critical(_("    Started: %s - %s ago") %
                    (time.ctime(ps['start_time']), ago))
    logger.critical(_("    State  : %s, pid: %d") % (ps['state'], pid))

    return ps
示例#10
0
 def _do_update(self, amount_read, now=None):
     fread = format_number(amount_read)
     name = self._getName()
     if self.size is None:
         # Elapsed time
         etime = self.re.elapsed_time()
         fetime = format_time(etime)
         frac = 0.0
         self.updateProgress(name, frac, fread, fetime)
     else:
         # Remaining time
         rtime = self.re.remaining_time()
         frtime = format_time(rtime)
         frac = self.re.fraction_read()
         self.updateProgress(name, frac, fread, frtime)
示例#11
0
 def _do_update( self, amount_read, now=None ):
     fread = format_number( amount_read )
     name = self._getName()
     if self.size is None:
         # Elapsed time
         etime = self.re.elapsed_time()
         fetime = format_time( etime )
         frac = 0.0
         self.updateProgress(name,frac,fread,fetime)
     else:
         # Remaining time
         rtime = self.re.remaining_time()
         frtime = format_time( rtime )
         frac = self.re.fraction_read()
         self.updateProgress(name,frac,fread,frtime)
示例#12
0
    def _do_end(self, amount_read, now=None):
        if self.i % 100 == 0:
            etime = self.re.elapsed_time()
            fetime = format_time(etime)
            fread = format_number(amount_read)
            #self.size = None
            if self.text is not None:
                text = self.text
            else:
                text = self.basename
            if self.size is None:
                #out = '\r%-60.60s    %5sB %s ' % (text, fread, fetime)
                try:
                    self.app.gui.SetVisible(4000, True)
                    self.app.gui.SetTexture(4001,
                                            'download/download-%s.png' % 0)
                    self.app.gui.SetLabel(
                        4002, '%3i%%  %5sB  %s' % (frac * 100, fread, fetime))
                    self.app.gui.SetLabel(4005, 'Downloading: %s' % text)
                    Log(self.app,
                        '\r%-60.60s    %5sB %s ' % (text, fread, fetime))
                except:
                    pass
            else:
                rtime = self.re.remaining_time()
                frtime = format_time(rtime)
                speed = int(self.re.average_rate()) / 1024
                frac = self.re.fraction_read()
                bar = '=' * int(25 * frac)

                #out = '\r%-25.25s %3i%% |%-25.25s| %5sB %8s ETA ' % (text, frac*100, bar, fread, frtime)
                try:
                    self.app.gui.SetVisible(4000, True)
                    self.app.gui.SetTexture(
                        4001, 'download/download-%s.png' %
                        int(round(frac * 100, -1)))
                    self.app.gui.SetLabel(
                        4002, '%3i%%  %5sB  %skbps  %s ETA' %
                        (frac * 100, fread, speed, frtime))
                    self.app.gui.SetLabel(4005, 'Downloading: %s' % text)
                    Log(
                        self.app, '\r%-25.25s %3i%% |%-25.25s| %5sB %8s ETA ' %
                        (text, frac * 100, bar, fread, frtime))
                except:
                    pass
        self.i += 1
示例#13
0
文件: meter.py 项目: xiaoqiang0/osc
 def _do_end(self, amount_read, now=None):
     total_time = format_time(self.re.elapsed_time())
     total_size = format_number(amount_read)
     if self.text is not None:
         text = self.text
     else:
         text = self.basename
     if self.size is None:
         out = self.unsized_templ % \
               (text, total_size, total_time)
     else:
         bar = '=' * self.bar_length
         out = self.sized_templ % \
               (text, 100, bar, total_size, total_time) + '    '
     if self.hide_finished:
         self.fo.write('\r'+ ' '*len(out) + '\r')
     else:
         self.fo.write(out + '\n')
     self.fo.flush()
示例#14
0
文件: drpm.py 项目: pnasrat/yum
    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
                self.progress.start(filename=None, url=None, # BZ 963023
                                    text='<locally rebuilding deltarpms>', size=total)
                self.done = 0
        while self._future_jobs:
            self.dequeue()
示例#15
0
    def _do_end(self, amount_read, now=None):
        if self.i%100==0:
            etime = self.re.elapsed_time()
            fetime = format_time(etime)
            fread = format_number(amount_read)
            #self.size = None
            if self.text is not None:
                text = self.text
            else:
                text = self.basename
            if self.size is None:
                #out = '\r%-60.60s    %5sB %s ' % (text, fread, fetime)
                try:
                    self.app.gui.SetVisible(4000, True)
                    self.app.gui.SetTexture(4001, 'download/download-%s.png' % 0 )
                    self.app.gui.SetLabel(4002, '%3i%%  %5sB  %s' % (frac*100, fread, fetime))
                    self.app.gui.SetLabel(4005, 'Downloading: %s' % text  )
                    Log(self.app, '\r%-60.60s    %5sB %s ' % (text, fread, fetime))
                except:
                    pass
            else:
                rtime  = self.re.remaining_time()
                frtime = format_time(rtime)
                speed  = int(self.re.average_rate()) / 1024
                frac   = self.re.fraction_read()
                bar    = '='*int(25 * frac)

                #out = '\r%-25.25s %3i%% |%-25.25s| %5sB %8s ETA ' % (text, frac*100, bar, fread, frtime)
                try:
                    self.app.gui.SetVisible(4000, True)
                    self.app.gui.SetTexture(4001, 'download/download-%s.png' % int(round( frac*100, -1)) )
                    self.app.gui.SetLabel(4002, '%3i%%  %5sB  %skbps  %s ETA' % (frac*100, fread, speed, frtime))
                    self.app.gui.SetLabel(4005, 'Downloading: %s' % text  )
                    Log(self.app, '\r%-25.25s %3i%% |%-25.25s| %5sB %8s ETA ' % (text, frac*100, bar, fread, frtime))
                except:
                    pass
        self.i += 1
        
示例#16
0
文件: meter.py 项目: xiaoqiang0/osc
    def _do_update(self, amount_read, now=None):
        etime = self.re.elapsed_time()
        fetime = format_time(etime)
        fread = format_number(amount_read)
        #self.size = None
        if self.text is not None:
            text = self.text
        else:
            text = self.basename
        if self.size is None:
            out = self.unsized_templ % \
                  (text, fread, fetime)
        else:
            rtime = self.re.remaining_time()
            frtime = format_time(rtime)
            frac = self.re.fraction_read()
            bar = '='*int(self.bar_length * frac)

            out = self.sized_templ % \
                  (text, frac*100, bar, fread, frtime) + 'ETA '

        self.fo.write(out)
        self.fo.flush()
示例#17
0
 def _do_end( self, amount_read, now=None ):
     total_time = format_time( self.re.elapsed_time() )
     total_size = format_number( amount_read )
     name = self._getName()
     self.updateProgress(name,1.0,total_size,total_time)
示例#18
0
 def _do_end(self, amount_read, now=None):
     total_time = format_time(self.re.elapsed_time())
     total_size = format_number(amount_read)
     name = self._getName()
     self.updateProgress(name, 1.0, total_size, total_time)
示例#19
0
def bkMG(num):
    ''' Call format_number() but deals with negative numbers. '''
    if num >= 0:
        return format_number(num)
    return '-' + format_number(-num)
示例#20
0
 def _do_start(self, now=None):
     name = self._getName()
     self.updateProgress(name, 0.0, "", "")
     if not self.size is None:
         self.totSize = format_number(self.size)
示例#21
0
def bkMG(num):
    """ Call format_number() but deals with negative numbers. """
    if num >= 0:
        return format_number(num)
    return "-" + format_number(-num)
示例#22
0
    except IOError, e:
        logger.critical("%s", exception2msg(e))
        ps = None
    if not ps:
        return None

    # This yumBackend isn't very friendly, so...
    if ps["name"] == "yumBackend.py":
        nmsg = _("  The other application is: PackageKit")
    else:
        nmsg = _("  The other application is: %s") % ps["name"]

    logger.critical("%s", nmsg)
    logger.critical(
        _("    Memory : %5s RSS (%5sB VSZ)")
        % (format_number(int(ps["vmrss"]) * 1024), format_number(int(ps["vmsize"]) * 1024))
    )

    ago = seconds_to_ui_time(int(time.time()) - ps["start_time"])
    logger.critical(_("    Started: %s - %s ago") % (time.ctime(ps["start_time"]), ago))
    logger.critical(_("    State  : %s, pid: %d") % (ps["state"], pid))

    return ps


class YumUtilBase(YumBaseCli):
    """A class to extend the yum cli for utilities."""

    def __init__(self, name, ver, usage):
        YumBaseCli.__init__(self)
        self._parser = YumOptionParser(base=self, utils=True, usage=usage)
示例#23
0
文件: utils.py 项目: wenjiedeng/yum
        ps = get_process_info(pid)
    except IOError, e:
        logger.critical("%s", exception2msg(e))
        ps = None
    if not ps:
        return None

    # This yumBackend isn't very friendly, so...
    if ps['name'] == 'yumBackend.py':
        nmsg = _("  The other application is: PackageKit")
    else:
        nmsg = _("  The other application is: %s") % ps['name']

    logger.critical("%s", nmsg)
    logger.critical(
        _("    Memory : %5s RSS (%5sB VSZ)") % (format_number(
            int(ps['vmrss']) * 1024), format_number(int(ps['vmsize']) * 1024)))

    ago = seconds_to_ui_time(int(time.time()) - ps['start_time'])
    logger.critical(
        _("    Started: %s - %s ago") % (time.ctime(ps['start_time']), ago))
    logger.critical(_("    State  : %s, pid: %d") % (ps['state'], pid))

    return ps


class YumUtilBase(YumBaseCli):
    """A class to extend the yum cli for utilities."""
    def __init__(self, name, ver, usage):
        YumBaseCli.__init__(self)
        self._parser = YumOptionParser(base=self, utils=True, usage=usage)
        self._usage = usage
示例#24
0
文件: drpm.py 项目: dmnks/yum
    def __init__(self, ayum, pkgs, adderror):
        self.verbose_logger = ayum.verbose_logger
        self.adderror = adderror
        self.jobs = {}
        self._future_jobs = []
        self.progress = None
        self.limit = ayum.conf.deltarpm
        if self.limit < 0:
            nprocs = _num_cpus_online()
            self.limit *= -nprocs

        if not self.limit:  # Turned off.
            return

        # calculate update sizes
        oldrpms = {}
        pinfo = {}
        reposize = {}
        for index, po in enumerate(pkgs):
            perc = po.repo.deltarpm_percentage
            if perc is None:
                urls = po.repo.urls
                perc = ayum.conf.deltarpm_percentage
                if len(urls) == 1 and urls[0].startswith("file:"):
                    perc = 0  # for local repos, default to off.
            if perc == 0:
                continue  # Allow people to turn off a repo. (meh)
            if po.state == TS_UPDATE:
                pass
            elif po.name in ayum.conf.installonlypkgs:
                pass
            else:
                names = oldrpms.get(po.repo)
                if names is None:
                    # load all locally cached rpms
                    names = oldrpms[po.repo] = {}
                    for rpmfn in os.listdir(po.repo.pkgdir):
                        m = re.match("^(.+)-(.+)-(.+)\.(.+)\.rpm$", rpmfn)
                        if m:
                            n, v, r, a = m.groups()
                            names.setdefault((n, a), set()).add((v, r))
                if (po.name, po.arch) not in names:
                    continue
            pinfo.setdefault(po.repo, {})[po.pkgtup] = index
            reposize[po.repo] = reposize.get(po.repo, 0) + po.size

        # don't use deltas when deltarpm not installed
        if reposize and not os.access(APPLYDELTA, os.X_OK):
            self.verbose_logger.info(_("Delta RPMs disabled because %s not installed."), APPLYDELTA)
            return

        # download delta metadata
        mdpath = {}
        for repo in reposize:
            for name in ("prestodelta", "deltainfo"):
                try:
                    data = repo.repoXML.getData(name)
                    break
                except:
                    pass
            else:
                self.verbose_logger.info(_("No Presto metadata available for %s"), repo)
                continue
            path = repo.cachedir + "/" + os.path.basename(data.location[1])
            perc = repo.deltarpm_metadata_percentage
            data_size = int(data.size) * (perc / 100.0)
            if perc and not os.path.exists(path) and data_size > reposize[repo]:
                msg = _("Not downloading deltainfo for %s, MD is %s and rpms are %s")
                self.verbose_logger.info(
                    msg, repo, progress.format_number(data_size), progress.format_number(reposize[repo])
                )
                continue

            def failfunc(e, name=name, repo=repo):
                mdpath.pop(repo, None)
                if hasattr(e, "exception"):
                    e = e.exception
                self.verbose_logger.warn(_("Failed to download %s for repository %s: %s"), name, repo, exception2msg(e))

            kwargs = {}
            if async and repo._async:
                kwargs["failfunc"] = failfunc
                kwargs["async"] = True
            try:
                mdpath[repo] = repo._retrieveMD(name, **kwargs)
            except RepoError, e:
                failfunc(e)
示例#25
0
def bkMG(num):
    ''' Call format_number() but deals with negative numbers. '''
    if num >= 0:
        return format_number(num)
    return '-' + format_number(-num)
示例#26
0
文件: __init__.py 项目: bkueng/yumex
    def size(self):
        '''

        '''
        return format_number(self.sizeBytes)
示例#27
0
    def doCommand(self, base, basecmd, extcmds):
        show_all = False
        show_upgrades = False
        if extcmds and extcmds[0] == 'all':
            show_all = True
            extcmds = extcmds[1:]
        elif extcmds and extcmds[0] in ('updates', 'upgrades'):
            show_upgrades = True
            extcmds = extcmds[1:]
        elif extcmds and extcmds[0] == 'restarts':
            extcmds = extcmds[1:]

        # Call base.rpmdb.return_running_packages() eventually.
        pkgs = _rpmdb_return_running_packages(base.rpmdb, return_pids=True)
        ts = base.rpmdb.readOnlyTS()
        kern_pkgtup = misc.get_running_kernel_pkgtup(ts)
        kern_pkg = None
        for pkg in sorted(base.rpmdb.searchPkgTuple(kern_pkgtup)):
            kern_pkg = pkg
        if kern_pkg is not None:
            kern_pkgs = base.rpmdb.searchNames([kern_pkgtup[0]])
            if kern_pkgs:
                kern_latest = sorted(kern_pkgs)[-1]
                if kern_latest.verGT(kern_pkg):
                    pkgs[kern_latest] = [0]

        try:
            # Get boot time, this is what get_process_info() uses:
            for line in open("/proc/stat"):
                if line.startswith("btime "):
                    kern_boot = int(line[len("btime "):-1])
                    break
        except:
            kern_boot = 0

        print "  %8s %-16s %8s %8s %10s %s" % ("pid", "proc",
                                               "CPU", "RSS", "State", "uptime")
        for pkg in sorted(pkgs):
            if extcmds:
                for cmd in extcmds:
                    if fnmatch.fnmatch(pkg.name, cmd):
                        break
                    if fnmatch.fnmatch(pkg.ui_nevra, cmd):
                        break
                else:
                    continue

            apkgs = base.pkgSack.searchNames([pkg.name])
            state = ''
            if not apkgs:
                apkgs = 'Not available!'
            else:
                apkgs = sorted(apkgs)[-1]
                if apkgs.verEQ(pkg):
                    apkgs = ''
                    state = ''
                elif apkgs.verGT(pkg):
                    state = 'Upgrade'
                    apkgs = apkgs.ui_nevra[len(apkgs.name)+1:]
                else:
                    state = 'Newer'
                    apkgs = apkgs.ui_nevra[len(apkgs.name)+1:]
            procs = []
            for pid in pkgs[pkg]:
                pid = int(pid)
                now = int(time.time())
                if pid:
                    ps_info = utils.get_process_info(pid)
                    if ps_info is None:
                        ps_info = {'name' : '<Unknown>',
                                   'start_time' : 0,
                                   'state' : 'Unknown',
                                   'vmrss' : 0, 'utime' : 0, 'stime' : 0}
                else:
                    ps_info = {'name' : '<kernel>',
                               'start_time' : kern_boot,
                               'state' : 'Running',
                               'vmrss' : 0, 'utime' : 0, 'stime' : 0}
                procs.append((ps_info['start_time'], pid, ps_info))
            oldest_proc = min([t[0] for t in procs])
            if show_all:
                pass
            elif oldest_proc < pkg.installtime:
                pass
            elif show_upgrades and state == 'Upgrade':
                pass
            else:
                continue
            print "%s %s %s" % (pkg, state, apkgs)
            for start_time, pid, ps_info in sorted(procs):
                ago = utils.seconds_to_ui_time(now - start_time)
                nr = ' '
                if start_time <= pkg.installtime:
                    nr = '*'
                name = ps_info['name']
                cpu  = int(ps_info['utime']) + int(ps_info['stime'])
                cpu  = "%d:%02d" % (cpu / 60, cpu % 60)
                rss  = format_number(int(ps_info['vmrss']) * 1024)
                S    = ps_info['state']
                print "  %8d %-16.16s %8s %7sB %10s: %s%s" % (pid, name,
                                                            cpu, rss, S,nr, ago)

        rc = 0
        return rc, ['%s' % basecmd]
示例#28
0
 def _do_start( self, now=None ):
     name = self._getName()
     self.updateProgress(name,0.0,"","")
     if not self.size is None:
         self.totSize = format_number( self.size )
示例#29
0
文件: drpm.py 项目: wenjiedeng/yum
    def __init__(self, ayum, pkgs, adderror):
        self.verbose_logger = ayum.verbose_logger
        self.adderror = adderror
        self.jobs = {}
        self._future_jobs = []
        self.progress = None
        self.limit = ayum.conf.deltarpm
        if self.limit < 0:
            nprocs = _num_cpus_online()
            self.limit *= -nprocs

        if not self.limit:  # Turned off.
            return

        # calculate update sizes
        oldrpms = {}
        pinfo = {}
        reposize = {}
        for index, po in enumerate(pkgs):
            perc = po.repo.deltarpm_percentage
            if perc is None:
                urls = po.repo.urls
                perc = ayum.conf.deltarpm_percentage
                if len(urls) == 1 and urls[0].startswith('file:'):
                    perc = 0  # for local repos, default to off.
            if perc == 0:
                continue  # Allow people to turn off a repo. (meh)
            if po.state == TS_UPDATE: pass
            elif po.name in ayum.conf.installonlypkgs: pass
            else:
                names = oldrpms.get(po.repo)
                if names is None:
                    # load all locally cached rpms
                    names = oldrpms[po.repo] = {}
                    for rpmfn in os.listdir(po.repo.pkgdir):
                        m = re.match('^(.+)-(.+)-(.+)\.(.+)\.rpm$', rpmfn)
                        if m:
                            n, v, r, a = m.groups()
                            names.setdefault((n, a), set()).add((v, r))
                if (po.name, po.arch) not in names:
                    continue
            pinfo.setdefault(po.repo, {})[po.pkgtup] = index
            reposize[po.repo] = reposize.get(po.repo, 0) + po.size

        # don't use deltas when deltarpm not installed
        if reposize and not os.access(APPLYDELTA, os.X_OK):
            self.verbose_logger.info(
                _('Delta RPMs disabled because %s not installed.'), APPLYDELTA)
            return

        # download delta metadata
        mdpath = {}
        for repo in reposize:
            for name in ('prestodelta', 'deltainfo'):
                try:
                    data = repo.repoXML.getData(name)
                    break
                except:
                    pass
            else:
                self.verbose_logger.info(
                    _('No Presto metadata available for %s'), repo)
                continue
            path = repo.cachedir + '/' + os.path.basename(data.location[1])
            perc = repo.deltarpm_metadata_percentage
            data_size = int(data.size) * (perc / 100.0)
            if perc and not os.path.exists(
                    path) and data_size > reposize[repo]:
                msg = _(
                    'Not downloading deltainfo for %s, MD is %s and rpms are %s'
                )
                self.verbose_logger.info(
                    msg, repo, progress.format_number(data_size),
                    progress.format_number(reposize[repo]))
                continue

            def failfunc(e, name=name, repo=repo):
                mdpath.pop(repo, None)
                if hasattr(e, 'exception'): e = e.exception
                self.verbose_logger.warn(
                    _('Failed to download %s for repository %s: %s'), name,
                    repo, exception2msg(e))

            kwargs = {}
            if async and repo._async:
                kwargs['failfunc'] = failfunc
                kwargs['async'] = True
            try:
                mdpath[repo] = repo._retrieveMD(name, **kwargs)
            except RepoError, e:
                failfunc(e)
示例#30
0
        ps = get_process_info(pid)
    except IOError, e:
        logger.critical("%s", exception2msg(e))
        ps = None
    if not ps:
        return None

    # This yumBackend isn't very friendly, so...
    if ps['name'] == 'yumBackend.py':
        nmsg = _("  The other application is: PackageKit")
    else:
        nmsg = _("  The other application is: %s") % ps['name']

    logger.critical("%s", nmsg)
    logger.critical(_("    Memory : %5s RSS (%5sB VSZ)") %
                    (format_number(int(ps['vmrss']) * 1024),
                     format_number(int(ps['vmsize']) * 1024)))
    
    ago = seconds_to_ui_time(int(time.time()) - ps['start_time'])
    logger.critical(_("    Started: %s - %s ago") %
                    (time.ctime(ps['start_time']), ago))
    logger.critical(_("    State  : %s, pid: %d") % (ps['state'], pid))

    return ps


class YumUtilBase(YumBaseCli):
    """A class to extend the yum cli for utilities."""
    
    def __init__(self,name,ver,usage):
        YumBaseCli.__init__(self)