Exemplo n.º 1
0
Arquivo: main.py Projeto: nphilipp/dnf
def cli_run(cli, base):
    # 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 (IOError, OSError) as e:
        return ex_IOError(e)

    if cli.demands.resolving:
        try:
            ret = resolving(cli, base)
        except dnf.exceptions.DepsolveError as e:
            ex_Error(e)
            if not cli.demands.allow_erasing:
                logger.info(_("(try to add '%s' to command line to"
                              " replace conflicting packages)"),
                            "--allowerasing")
            raise
        if ret:
            return ret

    cli.command.run_transaction()
    return cli.demands.success_exit_status
Exemplo n.º 2
0
Arquivo: main.py Projeto: lubomir/dnf
def cli_run(cli, base):
    # 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 (IOError, OSError) as e:
        return ex_IOError(e)

    if cli.demands.resolving:
        try:
            ret = resolving(cli, base)
        except dnf.exceptions.DepsolveError as e:
            ex_Error(e)
            if not cli.demands.allow_erasing:
                logger.info(
                    _("(try to add '%s' to command line to"
                      " replace conflicting packages)"), "--allowerasing")
            raise
        if ret:
            return ret

    cli.command.run_transaction()
    return cli.demands.success_exit_status
Exemplo n.º 3
0
def cli_run(cli, base):
    # 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 (IOError, OSError) as e:
        return ex_IOError(e)

    if cli.demands.resolving:
        try:
            ret = resolving(cli, base)
        except dnf.exceptions.DepsolveError as e:
            ex_Error(e)
            msg = ""
            if not cli.demands.allow_erasing and base._goal.problem_conflicts(
                    available=True):
                msg += _(
                    "try to add '{}' to command line to replace conflicting "
                    "packages").format("--allowerasing")
            if cli.base.conf.strict:
                if not msg:
                    msg += _("try to add '{}' to skip uninstallable packages"
                             ).format("--skip-broken")
                else:
                    msg += _(" or '{}' to skip uninstallable packages").format(
                        "--skip-broken")
            if cli.base.conf.best:
                opt = cli.base.conf._get_option("best")
                prio = opt._get_priority()
                if prio <= dnf.conf.PRIO_MAINCONFIG:
                    if not msg:
                        msg += _(
                            "try to add '{}' to use not only best candidate packages"
                        ).format("--nobest")
                    else:
                        msg += _(
                            " or '{}' to use not only best candidate packages"
                        ).format("--nobest")
            if msg:
                logger.info("({})".format(msg))
            raise
        if ret:
            return ret

    cli.command.run_transaction()
    return cli.demands.success_exit_status
Exemplo n.º 4
0
Arquivo: main.py Projeto: rcutmore/dnf
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(list(map(ucd, args)))
        cli.check()
    except dnf.exceptions.LockError:
        raise
    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 (IOError, OSError) as e:
        return ex_IOError(e)

    if cli.demands.resolving:
        try:
            ret = resolving(cli, base)
        except dnf.exceptions.DepsolveError as e:
            ex_Error(e)
            if not cli.demands.allow_erasing:
                logger.info(
                    _("(try to add '%s' to command line to"
                      " replace conflicting packages)"), "--allowerasing")
            raise
        if ret:
            return ret

    cli.command.run_transaction()
    return cli.demands.success_exit_status
Exemplo n.º 5
0
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(list(map(ucd, args)))
        cli.check()
    except dnf.exceptions.LockError:
        raise
    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 (IOError, OSError) as e:
        return ex_IOError(e)

    if cli.demands.resolving:
        try:
            ret = resolving(cli, base)
        except dnf.exceptions.DepsolveError as e:
            ex_Error(e)
            if not cli.demands.allow_erasing:
                logger.info(_("(try to add '%s' to command line to"
                              " replace conflicting packages)"),
                            "--allowerasing")
            raise
        if ret:
            return ret

    cli.command.run_transaction()
    return cli.demands.success_exit_status
Exemplo n.º 6
0
def cli_run(cli, base):
    # 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 (IOError, OSError) as e:
        return ex_IOError(e)

    if cli.demands.resolving:
        try:
            ret = resolving(cli, base)
        except dnf.exceptions.DepsolveError as e:
            ex_Error(e)
            msg = ""
            if not cli.demands.allow_erasing and base._goal.problem_conflicts(available=True):
                msg += _("try to add '{}' to command line to replace conflicting "
                         "packages").format("--allowerasing")
            if cli.base.conf.strict:
                if not msg:
                    msg += _("try to add '{}' to skip uninstallable packages").format(
                        "--skip-broken")
                else:
                    msg += _(" or '{}' to skip uninstallable packages").format("--skip-broken")
            if cli.base.conf.best:
                prio = cli.base.conf._get_priority("best")
                if prio <= dnf.conf.PRIO_MAINCONFIG:
                    if not msg:
                        msg += _("try to add '{}' to use not only best candidate packages").format(
                            "--nobest")
                    else:
                        msg += _(" or '{}' to use not only best candidate packages").format(
                            "--nobest")
            if msg:
                logger.info("({})".format(msg))
            raise
        if ret:
            return ret

    cli.command.run_transaction()
    return cli.demands.success_exit_status
Exemplo n.º 7
0
def cli_run(cli, base):
    # 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 (IOError, OSError) as e:
        return ex_IOError(e)

    if cli.demands.resolving:
        try:
            ret = resolving(cli, base)
        except dnf.exceptions.DepsolveError as e:
            ex_Error(e)
            if not cli.demands.allow_erasing and base._goal.problem_conflicts(
                    available=True):
                msg = _(
                    "(try to add '%s' to command line to replace conflicting "
                    "packages") % "--allowerasing"
                if cli.base.conf.strict:
                    msg += _(" or '%s' to skip uninstallable packages)"
                             ) % "--skip-broken"
                else:
                    msg += ")"
                logger.info(msg)
            raise
        if ret:
            return ret

    cli.command.run_transaction()
    return cli.demands.success_exit_status
Exemplo n.º 8
0
def main(args):
    base = dnf.cli.cli.BaseCli()
    cli = dnf.cli.Cli(base)
    if args[0] == "_cmds":
        base.plugins.load(base.conf.pluginpath, [])
        base.plugins.run_init(base, cli)
        print("\n".join(filter_list_by_kw(args[1], cli.cli_commands)))
        return
    cli.cli_commands.clear()
    cli.register_command(RemoveCompletionCommand)
    cli.register_command(InstallCompletionCommand)
    cli.register_command(ReinstallCompletionCommand)
    cli.register_command(ListCompletionCommand)
    cli.register_command(RepoListCompletionCommand)
    cli.register_command(UpgradeCompletionCommand)
    cli.register_command(DowngradeCompletionCommand)
    cli.register_command(CleanCompletionCommand)
    cli.register_command(HistoryCompletionCommand)
    cli.configure(args)
    cli.run()
Exemplo n.º 9
0
def main(args):
    base = dnf.cli.cli.BaseCli()
    cli = dnf.cli.Cli(base)
    if args[0] == "_cmds":
        base.plugins.load(base.conf.pluginpath, [])
        base.plugins.run_init(base, cli)
        print("\n".join(filter_list_by_kw(args[1], cli.cli_commands)))
        return
    cli.cli_commands.clear()
    cli.register_command(RemoveCompletionCommand)
    cli.register_command(InstallCompletionCommand)
    cli.register_command(ReinstallCompletionCommand)
    cli.register_command(ListCompletionCommand)
    cli.register_command(RepoListCompletionCommand)
    cli.register_command(UpgradeCompletionCommand)
    cli.register_command(DowngradeCompletionCommand)
    cli.register_command(CleanCompletionCommand)
    cli.register_command(HistoryCompletionCommand)
    cli.configure(args)
    cli.run()
Exemplo n.º 10
0
def main(args):
    base = dnf.cli.cli.BaseCli()
    cli = dnf.cli.Cli(base)
    if args[0] == "_cmds":
        base.init_plugins([], [], cli)
        print("\n".join(filter_list_by_kw(args[1], cli.cli_commands)))
        return
    cli.cli_commands.clear()
    cli.register_command(RemoveCompletionCommand)
    cli.register_command(InstallCompletionCommand)
    cli.register_command(ReinstallCompletionCommand)
    cli.register_command(ListCompletionCommand)
    cli.register_command(RepoListCompletionCommand)
    cli.register_command(UpgradeCompletionCommand)
    cli.register_command(DowngradeCompletionCommand)
    cli.register_command(CleanCompletionCommand)
    cli.configure(args)
    try:
        cli.run()
    except dnf.exceptions.Error:
        sys.exit(0)
Exemplo n.º 11
0
def main(args):
    base = dnf.cli.cli.BaseCli()
    cli = dnf.cli.Cli(base)
    if args[0] == "_cmds":
        base.init_plugins([], [], cli)
        print("\n".join(filter_list_by_kw(args[1], cli.cli_commands)))
        return
    cli.cli_commands.clear()
    cli.register_command(RemoveCompletionCommand)
    cli.register_command(InstallCompletionCommand)
    cli.register_command(ReinstallCompletionCommand)
    cli.register_command(ListCompletionCommand)
    cli.register_command(RepoListCompletionCommand)
    cli.register_command(UpgradeCompletionCommand)
    cli.register_command(DowngradeCompletionCommand)
    cli.register_command(CleanCompletionCommand)
    cli.register_command(HistoryCompletionCommand)
    cli.configure(args)
    try:
        cli.run()
    except dnf.exceptions.Error:
        sys.exit(0)
Exemplo n.º 12
0
Arquivo: main.py Projeto: dmach/dnf
def cli_run(cli, base):
    # 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 (IOError, OSError) as e:
        return ex_IOError(e)

    if cli.demands.resolving:
        try:
            ret = resolving(cli, base)
        except dnf.exceptions.DepsolveError as e:
            ex_Error(e)
            if not cli.demands.allow_erasing and base._goal.problem_conflicts(available=True):
                msg = _("(try to add '%s' to command line to replace conflicting "
                        "packages") % "--allowerasing"
                if cli.base.conf.strict:
                    msg += _(" or '%s' to skip uninstalable packages)") % "--skip-broken"
                else:
                    msg += ")"
                logger.info(msg)
            raise
        if ret:
            return ret

    cli.command.run_transaction()
    return cli.demands.success_exit_status