Changeset 516 for yum/trunk/yummain.py


Ignore:
Timestamp:
Feb 3, 2015, 9:39:54 AM (11 years ago)
Author:
Yuri Dario
Message:

yum: update trunk to 3.4.3.

Location:
yum/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • yum/trunk

  • yum/trunk/yummain.py

    r2 r516  
    2424import logging
    2525import time
     26import errno
    2627
    2728from yum import Errors
     
    3233import yum.misc
    3334import cli
    34 from utils import suppress_keyboard_interrupt_message, show_lock_owner
     35from utils import suppress_keyboard_interrupt_message, show_lock_owner, exception2msg
    3536
    3637def main(args):
     
    4849            logger.critical(_('\n\nExiting on Broken Pipe'))
    4950        else:
    50             logger.critical(_('\n\n%s') % str(e))
     51            logger.critical(_('\n\n%s') % exception2msg(e))
    5152        if unlock(): return 200
    5253        return 1
     
    5758        Log the plugin's exit message if one was supplied.
    5859        ''' # ' xemacs hack
    59         exitmsg = str(e)
     60        exitmsg = exception2msg(e)
    6061        if exitmsg:
    6162            logger.warn('\n\n%s', exitmsg)
     
    6465
    6566    def exFatal(e):
    66         logger.critical('\n\n%s', to_unicode(e.value))
     67        logger.critical('\n\n%s', exception2msg(e.value))
    6768        if unlock(): return 200
    6869        return 1
     
    7677        return 0
    7778
     79    def rpmdb_warn_checks():
     80        try:
     81            probs = base._rpmdb_warn_checks(out=verbose_logger.info, warn=False)
     82        except Errors.YumBaseError, e:
     83            # This is mainly for PackageSackError from rpmdb.
     84            verbose_logger.info(_(" Yum checks failed: %s"), exception2msg(e))
     85            probs = []
     86        if not probs:
     87            verbose_logger.info(_(" You could try running: rpm -Va --nofiles --nodigest"))
    7888
    7989    logger = logging.getLogger("yum.main")
     
    92102        return exFatal(e)
    93103
     104    # Try to open the current directory to see if we have
     105    # read and write access. If not, chdir to /
     106    try:
     107        f = open(".")
     108    except IOError, e:
     109        if e.errno == errno.EACCES:
     110            logger.critical(_('No read/write access in current directory, moving to /'))
     111            os.chdir("/")
     112    else:
     113        close(f)
     114
    94115    lockerr = ""
    95116    while True:
     
    97118            base.doLock()
    98119        except Errors.LockError, e:
    99             if "%s" %(e.msg,) != lockerr:
    100                 lockerr = "%s" %(e.msg,)
     120            if exception2msg(e) != lockerr:
     121                lockerr = exception2msg(e)
    101122                logger.critical(lockerr)
    102             logger.critical(_("Another app is currently holding the yum lock; waiting for it to exit..."))
    103             show_lock_owner(e.pid, logger)
    104             time.sleep(2)
     123            if (e.errno not in (errno.EPERM, errno.EACCES) and
     124                not base.conf.exit_on_lock):
     125                logger.critical(_("Another app is currently holding the yum lock; waiting for it to exit..."))
     126                tm = 0.1
     127                if show_lock_owner(e.pid, logger):
     128                    tm = 2
     129                time.sleep(tm)
     130            elif e.errno in (errno.EPERM, errno.EACCES):
     131                logger.critical(_("Can't create lock file; exiting"))
     132                return 1
     133            else:
     134                logger.critical(_("Another app is currently holding the yum lock; exiting as configured by exit_on_lock"))
     135                return 1
    105136        else:
    106137            break
     
    112143    except Errors.YumBaseError, e:
    113144        result = 1
    114         resultmsgs = [unicode(e)]
     145        resultmsgs = [exception2msg(e)]
    115146    except KeyboardInterrupt:
    116147        return exUserCancel()
     
    153184    except Errors.YumBaseError, e:
    154185        result = 1
    155         resultmsgs = [unicode(e)]
     186        resultmsgs = [exception2msg(e)]
    156187    except KeyboardInterrupt:
    157188        return exUserCancel()
     
    170201            prefix2nd = (' ' * (utf8_width(prefix) - 2))
    171202            logger.critical(prefix, msg.replace('\n', '\n' + prefix2nd))
    172         if not base.conf.skip_broken:
    173             verbose_logger.info(_(" You could try using --skip-broken to work around the problem"))
    174         if not base._rpmdb_warn_checks(out=verbose_logger.info, warn=False):
    175             verbose_logger.info(_(" You could try running: rpm -Va --nofiles --nodigest"))
     203        if base._depsolving_failed:
     204            if not base.conf.skip_broken:
     205                verbose_logger.info(_(" You could try using --skip-broken to work around the problem"))
     206            rpmdb_warn_checks()
    176207        if unlock(): return 200
    177208        return 1
     
    200231        return exIOError(e)
    201232
    202     # rpm_check_debug failed.
     233    # rpm ts.check() failed.
    203234    if type(return_code) == type((0,)) and len(return_code) == 2:
    204235        (result, resultmsgs) = return_code
    205236        for msg in resultmsgs:
    206237            logger.critical("%s", msg)
    207         if not base._rpmdb_warn_checks(out=verbose_logger.info, warn=False):
    208             verbose_logger.info(_(" You could try running: rpm -Va --nofiles --nodigest"))
     238        rpmdb_warn_checks()
    209239        return_code = result
     240        if base._ts_save_file:
     241            verbose_logger.info(_("Your transaction was saved, rerun it with: yum load-transaction %s") % base._ts_save_file)
     242    elif return_code < 0:
     243        return_code = 1 # Means the pre-transaction checks failed...
    210244    else:
    211245        verbose_logger.log(logginglevels.INFO_2, _('Complete!'))
Note: See TracChangeset for help on using the changeset viewer.