Changeset 516 for yum/trunk/yummain.py
- Timestamp:
- Feb 3, 2015, 9:39:54 AM (11 years ago)
- Location:
- yum/trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
yummain.py (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
yum/trunk
-
Property svn:mergeinfo
set to
/yum/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
yum/trunk/yummain.py
r2 r516 24 24 import logging 25 25 import time 26 import errno 26 27 27 28 from yum import Errors … … 32 33 import yum.misc 33 34 import cli 34 from utils import suppress_keyboard_interrupt_message, show_lock_owner 35 from utils import suppress_keyboard_interrupt_message, show_lock_owner, exception2msg 35 36 36 37 def main(args): … … 48 49 logger.critical(_('\n\nExiting on Broken Pipe')) 49 50 else: 50 logger.critical(_('\n\n%s') % str(e))51 logger.critical(_('\n\n%s') % exception2msg(e)) 51 52 if unlock(): return 200 52 53 return 1 … … 57 58 Log the plugin's exit message if one was supplied. 58 59 ''' # ' xemacs hack 59 exitmsg = str(e)60 exitmsg = exception2msg(e) 60 61 if exitmsg: 61 62 logger.warn('\n\n%s', exitmsg) … … 64 65 65 66 def exFatal(e): 66 logger.critical('\n\n%s', to_unicode(e.value))67 logger.critical('\n\n%s', exception2msg(e.value)) 67 68 if unlock(): return 200 68 69 return 1 … … 76 77 return 0 77 78 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")) 78 88 79 89 logger = logging.getLogger("yum.main") … … 92 102 return exFatal(e) 93 103 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 94 115 lockerr = "" 95 116 while True: … … 97 118 base.doLock() 98 119 except Errors.LockError, e: 99 if "%s" %(e.msg,) != lockerr:100 lockerr = "%s" %(e.msg,)120 if exception2msg(e) != lockerr: 121 lockerr = exception2msg(e) 101 122 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 105 136 else: 106 137 break … … 112 143 except Errors.YumBaseError, e: 113 144 result = 1 114 resultmsgs = [ unicode(e)]145 resultmsgs = [exception2msg(e)] 115 146 except KeyboardInterrupt: 116 147 return exUserCancel() … … 153 184 except Errors.YumBaseError, e: 154 185 result = 1 155 resultmsgs = [ unicode(e)]186 resultmsgs = [exception2msg(e)] 156 187 except KeyboardInterrupt: 157 188 return exUserCancel() … … 170 201 prefix2nd = (' ' * (utf8_width(prefix) - 2)) 171 202 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() 176 207 if unlock(): return 200 177 208 return 1 … … 200 231 return exIOError(e) 201 232 202 # rpm _check_debugfailed.233 # rpm ts.check() failed. 203 234 if type(return_code) == type((0,)) and len(return_code) == 2: 204 235 (result, resultmsgs) = return_code 205 236 for msg in resultmsgs: 206 237 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() 209 239 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... 210 244 else: 211 245 verbose_logger.log(logginglevels.INFO_2, _('Complete!'))
Note:
See TracChangeset
for help on using the changeset viewer.
