Пример #1
0
 def exIOError(e):
     if e.errno == 32:
         logger.critical(_('\n\nExiting on Broken Pipe'))
     else:
         logger.critical(_('\n\n%s') % exception2msg(e))
     if unlock(): return 200
     return 1
Пример #2
0
 def exIOError(e):
     if e.errno == 32:
         logger.critical(_('\n\nExiting on Broken Pipe'))
     else:
         logger.critical(_('\n\n%s') % exception2msg(e))
     if unlock(): return 200
     return 1
Пример #3
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
Пример #4
0
 def waitForLock(self):
     """Establish the yum lock.  If another process is already
     holding the yum lock, by default this method will keep trying
     to establish the lock until it is successful.  However, if
     :attr:`self.conf.exit_on_lock` is set to True, it will
     raise a :class:`Errors.YumBaseError`.
     """
     lockerr = ""
     while True:
         try:
             self.doLock()
         except Errors.LockError, e:
             if exception2msg(e) != lockerr:
                 lockerr = exception2msg(e)
                 self.logger.critical(lockerr)
             if not self.conf.exit_on_lock:
                 self.logger.critical(
                     "Another app is currently holding the yum lock; waiting for it to exit..."
                 )
                 show_lock_owner(e.pid, self.logger)
                 time.sleep(2)
             else:
                 raise Errors.YumBaseError, _(
                     "Another app is currently holding the yum lock; exiting as configured by exit_on_lock"
                 )
         else:
             break
Пример #5
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
Пример #6
0
    def exIOError(self, e):
        """Output a message stating that the program is exiting due to
        an IO exception.

        :param e: the IO exception
        :return: the exit code
        """
        if e.errno == 32:
            self.logger.critical(_('\n\nExiting on Broken Pipe'))
        else:
            self.logger.critical(_('\n\n%s') % exception2msg(e))
        if self.unlock(): return 200
        return 1
Пример #7
0
    def exIOError(self, e):
        """Output a message stating that the program is exiting due to
        an IO exception.

        :param e: the IO exception
        :return: the exit code
        """
        if e.errno == 32:
            self.logger.critical(_('\n\nExiting on Broken Pipe'))
        else:
            self.logger.critical(_('\n\n%s') % exception2msg(e))
        if self.unlock(): return 200
        return 1
Пример #8
0
 def rpmdb_warn_checks():
     try:
         probs = base._rpmdb_warn_checks(out=verbose_logger.info, warn=False)
     except Errors.YumBaseError, e:
         # This is mainly for PackageSackError from rpmdb.
         verbose_logger.info(_(" Yum checks failed: %s"), exception2msg(e))
         probs = []
Пример #9
0
 def rpmdb_warn_checks():
     try:
         probs = base._rpmdb_warn_checks(out=verbose_logger.info,
                                         warn=False)
     except Errors.YumBaseError, e:
         # This is mainly for PackageSackError from rpmdb.
         verbose_logger.info(_(" Yum checks failed: %s"), exception2msg(e))
         probs = []
Пример #10
0
    def doUtilConfigSetup(self,
                          args=sys.argv[1:],
                          pluginsTypes=(plugins.TYPE_CORE, )):
        """Parse command line options, and perform configuration.

        :param args: list of arguments to use for configuration
        :param pluginsTypes: a sequence specifying the types of
           plugins to load
        :return: a dictionary containing the values of command line options
        """
        # Parse only command line options that affect basic yum setup
        opts = self._parser.firstParse(args)

        # go through all the setopts and set the global ones
        self._parseSetOpts(opts.setopts)

        if self.main_setopts:
            for opt in self.main_setopts.items:
                setattr(opts, opt, getattr(self.main_setopts, opt))

        # Just print out the version if that's what the user wanted
        if opts.version:
            self._printUtilVersion()
            sys.exit(0)
        # get the install root to use
        root = self._parser.getRoot(opts)
        if opts.quiet:
            opts.debuglevel = 0
        if opts.verbose:
            opts.debuglevel = opts.errorlevel = 6

        # Read up configuration options and initialise plugins
        try:
            pc = self.preconf
            pc.fn = opts.conffile
            pc.root = root
            pc.init_plugins = not opts.noplugins
            pc.plugin_types = pluginsTypes
            pc.optparser = self._parser
            pc.debuglevel = opts.debuglevel
            pc.errorlevel = opts.errorlevel
            if hasattr(opts, "disableplugins"):
                pc.disabled_plugins = self._parser._splitArg(
                    opts.disableplugins)
            if hasattr(opts, "enableplugins"):
                pc.enabled_plugins = self._parser._splitArg(opts.enableplugins)
            if hasattr(opts, "releasever"):
                pc.releasever = opts.releasever
            self.conf

            # now set  all the non-first-start opts from main from our setopts
            if self.main_setopts:
                for opt in self.main_setopts.items:
                    setattr(self.conf, opt, getattr(self.main_setopts, opt))

        except Errors.ConfigError, e:
            self.logger.critical(_('Config Error: %s'), exception2msg(e))
            sys.exit(1)
Пример #11
0
    def exUserCancel(self):
        """Output a message stating that the operation was cancelled
        by the user.

        :return: the exit code
        """
        self.logger.critical(_('\n\nExiting on user cancel'))
        if self.unlock(): return 200
        return 1
Пример #12
0
    def exUserCancel(self):
        """Output a message stating that the operation was cancelled
        by the user.

        :return: the exit code
        """
        self.logger.critical(_('\n\nExiting on user cancel'))
        if self.unlock(): return 200
        return 1
Пример #13
0
    def doUtilConfigSetup(self,args = sys.argv[1:],pluginsTypes=(plugins.TYPE_CORE,)):
        """Parse command line options, and perform configuration.

        :param args: list of arguments to use for configuration
        :param pluginsTypes: a sequence specifying the types of
           plugins to load
        :return: a dictionary containing the values of command line options
        """
        # Parse only command line options that affect basic yum setup
        opts = self._parser.firstParse(args)

        # go through all the setopts and set the global ones
        self._parseSetOpts(opts.setopts)

        if self.main_setopts:
            for opt in self.main_setopts.items:
                setattr(opts, opt, getattr(self.main_setopts, opt))

        # Just print out the version if that's what the user wanted
        if opts.version:
            self._printUtilVersion()
            sys.exit(0)
        # get the install root to use
        root = self._parser.getRoot(opts)
        if opts.quiet:
            opts.debuglevel = 0
        if opts.verbose:
            opts.debuglevel = opts.errorlevel = 6
        
        # Read up configuration options and initialise plugins
        try:
            pc = self.preconf
            pc.fn = opts.conffile
            pc.root = root
            pc.init_plugins = not opts.noplugins
            pc.plugin_types = pluginsTypes
            pc.optparser = self._parser
            pc.debuglevel = opts.debuglevel
            pc.errorlevel = opts.errorlevel
            if hasattr(opts, "disableplugins"):
                pc.disabled_plugins =self._parser._splitArg(opts.disableplugins)
            if hasattr(opts, "enableplugins"):
                pc.enabled_plugins = self._parser._splitArg(opts.enableplugins)
            if hasattr(opts, "releasever"):
                pc.releasever = opts.releasever
            self.conf

            # now set  all the non-first-start opts from main from our setopts
            if self.main_setopts:
                for opt in self.main_setopts.items:
                    setattr(self.conf, opt, getattr(self.main_setopts, opt))

        except Errors.ConfigError, e:
            self.logger.critical(_('Config Error: %s'), exception2msg(e))
            sys.exit(1)
Пример #14
0
 def waitForLock(self):
     """Establish the yum lock.  If another process is already
     holding the yum lock, by default this method will keep trying
     to establish the lock until it is successful.  However, if
     :attr:`self.conf.exit_on_lock` is set to True, it will
     raise a :class:`Errors.YumBaseError`.
     """
     lockerr = ""
     while True:
         try:
             self.doLock()
         except Errors.LockError, e:
             if exception2msg(e) != lockerr:
                 lockerr = exception2msg(e)
                 self.logger.critical(lockerr)
             if not self.conf.exit_on_lock:
                 self.logger.critical("Another app is currently holding the yum lock; waiting for it to exit...")  
                 show_lock_owner(e.pid, self.logger)
                 time.sleep(2)
             else:
                 raise Errors.YumBaseError, _("Another app is currently holding the yum lock; exiting as configured by exit_on_lock")
         else:
             break
Пример #15
0
                                    sys.stdout.write(msg)
                                    sys.stdout.flush()
                                    self.lastmsg = msg
                                if bytes == total:
                                    print " "

        elif what == rpm.RPMCALLBACK_UNINST_START:
            pass

        elif what == rpm.RPMCALLBACK_UNINST_PROGRESS:
            pass

        elif what == rpm.RPMCALLBACK_UNINST_STOP:
            self.total_removed += 1
            if self.filelog and h not in self.installed_pkg_names:
                logmsg = _("Erased: %s" % (h))
                self.logger.info(logmsg)

            if self.output and sys.stdout.isatty():
                if h not in self.installed_pkg_names:
                    process = _("Removing")
                else:
                    process = _("Cleanup")
                percent = 100
                fmt = self._makefmt(percent, False)
                msg = fmt % (process, h)
                sys.stdout.write(msg + "\n")
                sys.stdout.flush()

        elif what == rpm.RPMCALLBACK_REPACKAGE_START:
            pass
Пример #16
0
    def __init__(self, output=1):
        self.output = output
        self.callbackfilehandles = {}
        self.total_actions = 0
        self.total_installed = 0
        self.installed_pkg_names = []
        self.total_removed = 0
        self.mark = "#"
        self.marks = 27
        self.lastmsg = None
        self.logger = logging.getLogger("yum.filelogging.RPMInstallCallback")
        self.filelog = False

        self.myprocess = {
            TS_UPDATE: _("Updating"),
            TS_ERASE: _("Erasing"),
            TS_INSTALL: _("Installing"),
            TS_TRUEINSTALL: _("Installing"),
            TS_OBSOLETED: _("Obsoleted"),
            TS_OBSOLETING: _("Installing"),
        }
        self.mypostprocess = {
            TS_UPDATE: _("Updated"),
            TS_ERASE: _("Erased"),
            TS_INSTALL: _("Installed"),
            TS_TRUEINSTALL: _("Installed"),
            TS_OBSOLETED: _("Obsoleted"),
            TS_OBSOLETING: _("Installed"),
        }

        self.tsInfo = None  # this needs to be set for anything else to work
Пример #17
0
        try:
            base.closeRpmDB()
            base.doUnlock()
        except Errors.LockError, e:
            return 200
        return 0

    def rpmdb_warn_checks():
        try:
            probs = base._rpmdb_warn_checks(out=verbose_logger.info, warn=False)
        except Errors.YumBaseError, e:
            # This is mainly for PackageSackError from rpmdb.
            verbose_logger.info(_(" Yum checks failed: %s"), exception2msg(e))
            probs = []
        if not probs:
            verbose_logger.info(_(" You could try running: rpm -Va --nofiles --nodigest"))

    logger = logging.getLogger("yum.main")
    verbose_logger = logging.getLogger("yum.verbose.main")

    # our core object for the cli
    base = cli.YumBaseCli()

    # do our cli parsing and config file setup
    # also sanity check the things being passed on the cli
    try:
        base.getOptionsConfig(args)
    except plugins.PluginYumExit, e:
        return exPluginExit(e)
    except Errors.YumBaseError, e:
        return exFatal(e)
Пример #18
0
 def exUserCancel():
     logger.critical(_('\n\nExiting on user cancel'))
     if unlock(): return 200
     return 1
Пример #19
0
        return
    boot_time = None
    for line in open("/proc/stat"):
        if line.startswith("btime "):
            boot_time = int(line[len("btime "):-1])
            break
    if boot_time is None:
        return
    ps_stat = open("/proc/%d/stat" % pid).read().split()
    ps['utime'] = jiffies_to_seconds(ps_stat[13])
    ps['stime'] = jiffies_to_seconds(ps_stat[14])
    ps['cutime'] = jiffies_to_seconds(ps_stat[15])
    ps['cstime'] = jiffies_to_seconds(ps_stat[16])
    ps['start_time'] = boot_time + jiffies_to_seconds(ps_stat[21])
    ps['state'] = {
        'R': _('Running'),
        'S': _('Sleeping'),
        'D': _('Uninterruptible'),
        'Z': _('Zombie'),
        'T': _('Traced/Stopped')
    }.get(ps_stat[2], _('Unknown'))

    return ps


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
Пример #20
0
                                    sys.stdout.write(msg)
                                    sys.stdout.flush()
                                    self.lastmsg = msg
                                if bytes == total:
                                    print " "

        elif what == rpm.RPMCALLBACK_UNINST_START:
            pass

        elif what == rpm.RPMCALLBACK_UNINST_PROGRESS:
            pass

        elif what == rpm.RPMCALLBACK_UNINST_STOP:
            self.total_removed += 1
            if self.filelog and h not in self.installed_pkg_names:
                logmsg = _('Erased: %s' % (h))
                self.logger.info(logmsg)

            if self.output and sys.stdout.isatty():
                if h not in self.installed_pkg_names:
                    process = _("Removing")
                else:
                    process = _("Cleanup")
                percent = 100
                fmt = self._makefmt(percent, False)
                msg = fmt % (process, h)
                sys.stdout.write(msg + "\n")
                sys.stdout.flush()

        elif what == rpm.RPMCALLBACK_REPACKAGE_START:
            pass
Пример #21
0
    def callback(self, what, bytes, total, h, user):
        """Handle callbacks from the RPM library.

        :param what: number identifying the type of callback
        :param bytes: the number of bytes associated with the
           callback; the exact meaning depends on the type of 
           the callback.  For example, for a RPMCALLBACK_INST_PROGRESS
           callback, bytes will represent the current amount of work done
        :param total: the total amount of work associated with the
           callback; the exact meaning depends on the type of the
           callback. For example, *total* may represent the total
           number of transactions in a transaction set
        :param h: a package object or string identifying the package
           involved in the callback
        :param user: unused
        """
        if what == rpm.RPMCALLBACK_TRANS_START:
            if bytes == 6:
                self.total_actions = total

        elif what == rpm.RPMCALLBACK_TRANS_PROGRESS:
            pass

        elif what == rpm.RPMCALLBACK_TRANS_STOP:
            pass

        elif what == rpm.RPMCALLBACK_INST_OPEN_FILE:
            self.lastmsg = None
            hdr = None
            if h is not None:
                hdr, rpmloc = h
                handle = self._makeHandle(hdr)
                fd = os.open(rpmloc, os.O_RDONLY)
                self.callbackfilehandles[handle] = fd
                self.total_installed += 1
                self.installed_pkg_names.append(hdr['name'])
                return fd
            else:
                self._localprint(_("No header - huh?"))

        elif what == rpm.RPMCALLBACK_INST_CLOSE_FILE:
            hdr = None
            if h is not None:
                hdr, rpmloc = h
                handle = self._makeHandle(hdr)
                os.close(self.callbackfilehandles[handle])
                fd = 0

                # log stuff
                pkgtup = self._dopkgtup(hdr)

                txmbrs = self.tsInfo.getMembers(pkgtup=pkgtup)
                for txmbr in txmbrs:
                    try:
                        process = self.myprocess[txmbr.output_state]
                        processed = self.mypostprocess[txmbr.output_state]
                    except KeyError:
                        pass

                    if self.filelog:
                        pkgrep = self._logPkgString(hdr)
                        msg = '%s: %s' % (processed, pkgrep)
                        self.logger.info(msg)

        elif what == rpm.RPMCALLBACK_INST_PROGRESS:
            if h is not None:
                # If h is a string, we're repackaging.
                # Why the RPMCALLBACK_REPACKAGE_PROGRESS flag isn't set, I have no idea
                if type(h) == type(""):
                    if total == 0:
                        percent = 0
                    else:
                        percent = (bytes * 100L) / total
                    if self.output and sys.stdout.isatty():
                        fmt = self._makefmt(percent)
                        msg = fmt % (_('Repackage'), h)
                        if bytes == total:
                            msg = msg + "\n"

                        if msg != self.lastmsg:
                            sys.stdout.write(msg)
                            sys.stdout.flush()
                            self.lastmsg = msg
                else:
                    hdr, rpmloc = h
                    if total == 0:
                        percent = 0
                    else:
                        percent = (bytes * 100L) / total
                    pkgtup = self._dopkgtup(hdr)

                    txmbrs = self.tsInfo.getMembers(pkgtup=pkgtup)
                    for txmbr in txmbrs:
                        try:
                            process = self.myprocess[txmbr.output_state]
                        except KeyError, e:
                            print _("Error: invalid output state: %s for %s") % \
                               (txmbr.output_state, hdr['name'])
                        else:
                            if self.output and (sys.stdout.isatty()
                                                or bytes == total):
                                fmt = self._makefmt(percent)
                                msg = fmt % (process, hdr['name'])
                                if msg != self.lastmsg:
                                    sys.stdout.write(msg)
                                    sys.stdout.flush()
                                    self.lastmsg = msg
                                if bytes == total:
                                    print " "
Пример #22
0
 def exUserCancel():
     logger.critical(_('\n\nExiting on user cancel'))
     if unlock(): return 200
     return 1
Пример #23
0
            base.doUnlock()
        except Errors.LockError, e:
            return 200
        return 0

    def rpmdb_warn_checks():
        try:
            probs = base._rpmdb_warn_checks(out=verbose_logger.info,
                                            warn=False)
        except Errors.YumBaseError, e:
            # This is mainly for PackageSackError from rpmdb.
            verbose_logger.info(_(" Yum checks failed: %s"), exception2msg(e))
            probs = []
        if not probs:
            verbose_logger.info(
                _(" You could try running: rpm -Va --nofiles --nodigest"))

    logger = logging.getLogger("yum.main")
    verbose_logger = logging.getLogger("yum.verbose.main")

    # our core object for the cli
    base = cli.YumBaseCli()

    # do our cli parsing and config file setup
    # also sanity check the things being passed on the cli
    try:
        base.getOptionsConfig(args)
    except plugins.PluginYumExit, e:
        return exPluginExit(e)
    except Errors.YumBaseError, e:
        return exFatal(e)
Пример #24
0
    def callback(self, what, bytes, total, h, user):
        """Handle callbacks from the RPM library.

        :param what: number identifying the type of callback
        :param bytes: the number of bytes associated with the
           callback; the exact meaning depends on the type of 
           the callback.  For example, for a RPMCALLBACK_INST_PROGRESS
           callback, bytes will represent the current amount of work done
        :param total: the total amount of work associated with the
           callback; the exact meaning depends on the type of the
           callback. For example, *total* may represent the total
           number of transactions in a transaction set
        :param h: a package object or string identifying the package
           involved in the callback
        :param user: unused
        """
        if what == rpm.RPMCALLBACK_TRANS_START:
            if bytes == 6:
                self.total_actions = total

        elif what == rpm.RPMCALLBACK_TRANS_PROGRESS:
            pass

        elif what == rpm.RPMCALLBACK_TRANS_STOP:
            pass

        elif what == rpm.RPMCALLBACK_INST_OPEN_FILE:
            self.lastmsg = None
            hdr = None
            if h is not None:
                hdr, rpmloc = h
                handle = self._makeHandle(hdr)
                fd = os.open(rpmloc, os.O_RDONLY)
                self.callbackfilehandles[handle] = fd
                self.total_installed += 1
                self.installed_pkg_names.append(hdr["name"])
                return fd
            else:
                self._localprint(_("No header - huh?"))

        elif what == rpm.RPMCALLBACK_INST_CLOSE_FILE:
            hdr = None
            if h is not None:
                hdr, rpmloc = h
                handle = self._makeHandle(hdr)
                os.close(self.callbackfilehandles[handle])
                fd = 0

                # log stuff
                pkgtup = self._dopkgtup(hdr)

                txmbrs = self.tsInfo.getMembers(pkgtup=pkgtup)
                for txmbr in txmbrs:
                    try:
                        process = self.myprocess[txmbr.output_state]
                        processed = self.mypostprocess[txmbr.output_state]
                    except KeyError:
                        pass

                    if self.filelog:
                        pkgrep = self._logPkgString(hdr)
                        msg = "%s: %s" % (processed, pkgrep)
                        self.logger.info(msg)

        elif what == rpm.RPMCALLBACK_INST_PROGRESS:
            if h is not None:
                # If h is a string, we're repackaging.
                # Why the RPMCALLBACK_REPACKAGE_PROGRESS flag isn't set, I have no idea
                if type(h) == type(""):
                    if total == 0:
                        percent = 0
                    else:
                        percent = (bytes * 100L) / total
                    if self.output and sys.stdout.isatty():
                        fmt = self._makefmt(percent)
                        msg = fmt % (_("Repackage"), h)
                        if bytes == total:
                            msg = msg + "\n"

                        if msg != self.lastmsg:
                            sys.stdout.write(msg)
                            sys.stdout.flush()
                            self.lastmsg = msg
                else:
                    hdr, rpmloc = h
                    if total == 0:
                        percent = 0
                    else:
                        percent = (bytes * 100L) / total
                    pkgtup = self._dopkgtup(hdr)

                    txmbrs = self.tsInfo.getMembers(pkgtup=pkgtup)
                    for txmbr in txmbrs:
                        try:
                            process = self.myprocess[txmbr.output_state]
                        except KeyError, e:
                            print _("Error: invalid output state: %s for %s") % (txmbr.output_state, hdr["name"])
                        else:
                            if self.output and (sys.stdout.isatty() or bytes == total):
                                fmt = self._makefmt(percent)
                                msg = fmt % (process, hdr["name"])
                                if msg != self.lastmsg:
                                    sys.stdout.write(msg)
                                    sys.stdout.flush()
                                    self.lastmsg = msg
                                if bytes == total:
                                    print " "
Пример #25
0
    def __init__(self, output=1):
        self.output = output
        self.callbackfilehandles = {}
        self.total_actions = 0
        self.total_installed = 0
        self.installed_pkg_names = []
        self.total_removed = 0
        self.mark = "#"
        self.marks = 27
        self.lastmsg = None
        self.logger = logging.getLogger('yum.filelogging.RPMInstallCallback')
        self.filelog = False

        self.myprocess = {
            TS_UPDATE: _('Updating'),
            TS_ERASE: _('Erasing'),
            TS_INSTALL: _('Installing'),
            TS_TRUEINSTALL: _('Installing'),
            TS_OBSOLETED: _('Obsoleted'),
            TS_OBSOLETING: _('Installing')
        }
        self.mypostprocess = {
            TS_UPDATE: _('Updated'),
            TS_ERASE: _('Erased'),
            TS_INSTALL: _('Installed'),
            TS_TRUEINSTALL: _('Installed'),
            TS_OBSOLETED: _('Obsoleted'),
            TS_OBSOLETING: _('Installed')
        }

        self.tsInfo = None  # this needs to be set for anything else to work
Пример #26
0
    if 'vmsize' not in ps:
        return
    boot_time = None
    for line in open("/proc/stat"):
        if line.startswith("btime "):
            boot_time = int(line[len("btime "):-1])
            break
    if boot_time is None:
        return
    ps_stat = open("/proc/%d/stat" % pid).read().split()
    ps['utime'] = jiffies_to_seconds(ps_stat[13])
    ps['stime'] = jiffies_to_seconds(ps_stat[14])
    ps['cutime'] = jiffies_to_seconds(ps_stat[15])
    ps['cstime'] = jiffies_to_seconds(ps_stat[16])
    ps['start_time'] = boot_time + jiffies_to_seconds(ps_stat[21])
    ps['state'] = {'R' : _('Running'),
                   'S' : _('Sleeping'),
                   'D' : _('Uninterruptible'),
                   'Z' : _('Zombie'),
                   'T' : _('Traced/Stopped')
                   }.get(ps_stat[2], _('Unknown'))
                   
    return ps

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