def _main(base, args): """Run the dnf program from a command line interface.""" dnf.i18n.setup_locale() dnf.i18n.setup_stdout() # our core object for the cli base.logging.presetup() cli = dnf.cli.cli.Cli(base) # do our cli parsing and config file setup # also sanity check the things being passed on the cli try: cli.configure(map(ucd, args)) cli.check() except dnf.exceptions.LockError: raise except dnf.exceptions.Error as e: return ex_Error(e) except (IOError, OSError) as e: return ex_IOError(e) # Try to open the current directory to see if we have # read and execute access. If not, chdir to / try: f = open(".") except IOError as e: if e.errno == errno.EACCES: logger.critical( _('No read/execute access in current directory, moving to /')) os.chdir("/") else: f.close() try: cli.run() except dnf.exceptions.LockError: raise except dnf.exceptions.Error as e: return ex_Error(e) except (IOError, OSError) as e: return ex_IOError(e) if cli.demands.resolving: ret = resolving(cli, base) if ret: return ret return cli.demands.success_exit_status
def _main(base, args): """Run the yum program from a command line interface.""" dnf.i18n.setup_locale() dnf.i18n.setup_stdout() # our core object for the cli base.logging.presetup() cli = dnf.cli.cli.Cli(base) # do our cli parsing and config file setup # also sanity check the things being passed on the cli try: cli.configure(args) cli.check() except dnf.exceptions.LockError: raise except dnf.exceptions.Error as e: return ex_Error(e) except (IOError, OSError) as e: return ex_IOError(e) # Try to open the current directory to see if we have # read and execute access. If not, chdir to / try: f = open(".") except IOError as e: if e.errno == errno.EACCES: logger.critical(_('No read/execute access in current directory, moving to /')) os.chdir("/") else: f.close() try: cli.run() except dnf.exceptions.LockError: raise except dnf.exceptions.Error as e: return ex_Error(e) except (IOError, OSError) as e: return ex_IOError(e) if cli.demands.resolving: ret = resolving(cli, base) if ret: return ret return cli.demands.success_exit_status
def _main(base, args): """Run the yum program from a command line interface.""" dnf.i18n.setup_locale() dnf.i18n.setup_stdout() def exIOError(e): if e.errno == 32: logger.critical(_('Exiting on Broken Pipe')) else: logger.critical(exception2msg(e)) return 1 def exPluginExit(e): '''Called when a plugin raises PluginYumExit. Log the plugin's exit message if one was supplied. ''' exitmsg = exception2msg(e) if exitmsg: logger.warn('%s', exitmsg) return 1 def exFatal(e): if e.value is not None: logger.critical(exception2msg(e.value)) return 1 # our core object for the cli base.logging.presetup() cli = dnf.cli.cli.Cli(base) # do our cli parsing and config file setup # also sanity check the things being passed on the cli try: cli.configure(args) cli.check() except plugins.PluginYumExit, e: return exPluginExit(e)
def _main(base, args): """Run the yum program from a command line interface.""" dnf.i18n.setup_locale() dnf.i18n.setup_stdout() def exIOError(e): dnf.util.log_last_excpetion(logger) if e.errno == 32: logger.critical(_('Exiting on Broken Pipe')) else: logger.critical(exception2msg(e)) return 1 def exFatal(e): if e.value is not None: logger.critical(_('Error: %s'), exception2msg(e.value)) return 1 # our core object for the cli base.logging.presetup() cli = dnf.cli.cli.Cli(base) # do our cli parsing and config file setup # also sanity check the things being passed on the cli try: cli.configure(args) cli.check() except dnf.exceptions.LockError: raise except dnf.exceptions.Error as e: return exFatal(e) except (IOError, OSError) as e: return exIOError(e) # Try to open the current directory to see if we have # read and execute access. If not, chdir to / try: f = open(".") except IOError as e: if e.errno == errno.EACCES: logger.critical(_('No read/execute access in current directory, moving to /')) os.chdir("/") else: f.close() try: cli.run() except dnf.exceptions.LockError: raise except dnf.exceptions.Error as e: return exFatal(e) except (IOError, OSError) as e: return exIOError(e) if not cli.command.resolve: return cli.command.success_retval # Depsolve stage (if needed) if base.transaction is None: logger.info(_('Resolving dependencies')) try: got_transaction = base.resolve() except dnf.exceptions.Error as e: logger.critical(_('Error: %s'), e) return 1 logger.info(_('Dependencies resolved.')) else: got_transaction = len(base.transaction) # Act on the depsolve result if not got_transaction: print(_('Nothing to do.')) return 0 # Run the transaction try: return_code, resultmsgs = base.do_transaction() except dnf.exceptions.LockError: raise except dnf.exceptions.TransactionCheckError as err: return_code, resultmsgs = 1, cli.command.get_error_output(err) except dnf.exceptions.Error as e: return exFatal(e) except IOError as e: return exIOError(e) # rpm ts.check() failed. if resultmsgs: for msg in resultmsgs: logger.critical("%s", msg) if base._ts_save_file: logger.info(_("Your transaction was saved, rerun it with:\n yum load-transaction %s") % base._ts_save_file) elif return_code < 0: return_code = 1 # Means the pre-transaction checks failed... # This includes: # . No packages. # . Hitting N at the prompt. # . GPG check failures. if base._ts_save_file: logger.info(_("Your transaction was saved, rerun it with:\n yum load-transaction %s") % base._ts_save_file) else: base.plugins.run_transaction() logger.info(_('Complete!')) return return_code
def _main(base, args): """Run the yum program from a command line interface.""" dnf.i18n.setup_locale() dnf.i18n.setup_stdout() def exIOError(e): if e.errno == 32: logger.critical(_('Exiting on Broken Pipe')) else: logger.critical(exception2msg(e)) return 1 def exPluginExit(e): '''Called when a plugin raises PluginYumExit. Log the plugin's exit message if one was supplied. ''' exitmsg = exception2msg(e) if exitmsg: logger.warn('%s', exitmsg) return 1 def exFatal(e): if e.value is not None: logger.critical(exception2msg(e.value)) return 1 # our core object for the cli base.logging.presetup() cli = dnf.cli.cli.Cli(base) # do our cli parsing and config file setup # also sanity check the things being passed on the cli try: cli.configure(args) cli.check() except plugins.PluginYumExit as e: return exPluginExit(e) except dnf.exceptions.LockError: raise except dnf.exceptions.Error as e: return exFatal(e) # Try to open the current directory to see if we have # read and execute access. If not, chdir to / try: f = open(".") except IOError as e: if e.errno == errno.EACCES: logger.critical(_('No read/execute access in current directory, moving to /')) os.chdir("/") else: f.close() try: result, resultmsgs = cli.run() except plugins.PluginYumExit as e: return exPluginExit(e) except dnf.exceptions.LockError: raise except dnf.exceptions.Error as e: result = 1 resultmsgs = [exception2msg(e)] except IOError as e: return exIOError(e) # Act on the command/shell result if result == 0: # Normal exit for msg in resultmsgs: logger.info('%s', msg) return 0 elif result == 1: # Fatal error for msg in resultmsgs: logger.critical(_('Error: %s'), msg) return 1 elif result == 2: # Continue on pass elif result == 100: return 100 else: logger.critical(_('Unknown Error(s): Exit Code: %d:'), result) for msg in resultmsgs: logger.critical(msg) return 3 # Depsolve stage (if needed) if base.transaction is None: logger.info(_('Resolving dependencies')) try: got_transaction = base.resolve() except plugins.PluginYumExit as e: return exPluginExit(e) except dnf.exceptions.Error as e: prefix = _('Error: %s') logger.critical(prefix, str(e)) return 1 logger.info(_('Dependencies resolved.')) else: got_transaction = len(base.transaction) # Act on the depsolve result if not got_transaction: print(_('Nothing to do.')) return 0 # Run the transaction try: return_code, resultmsgs = base.do_transaction() except plugins.PluginYumExit as e: return exPluginExit(e) except dnf.exceptions.LockError: raise except dnf.exceptions.TransactionCheckError as err: return_code, resultmsgs = 1, cli.command.get_error_output(err) except dnf.exceptions.Error as e: return exFatal(e) except IOError as e: return exIOError(e) # rpm ts.check() failed. if resultmsgs: for msg in resultmsgs: logger.critical("%s", msg) if base._ts_save_file: logger.info(_("Your transaction was saved, rerun it with:\n yum load-transaction %s") % base._ts_save_file) elif return_code < 0: return_code = 1 # Means the pre-transaction checks failed... # This includes: # . No packages. # . Hitting N at the prompt. # . GPG check failures. if base._ts_save_file: logger.info(_("Your transaction was saved, rerun it with:\n yum load-transaction %s") % base._ts_save_file) else: logger.info(_('Complete!')) return return_code