コード例 #1
0
ファイル: main.py プロジェクト: 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
コード例 #2
0
ファイル: main.py プロジェクト: 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
コード例 #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
コード例 #4
0
ファイル: main.py プロジェクト: 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
コード例 #5
0
ファイル: main.py プロジェクト: MattSturgeon/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
コード例 #6
0
ファイル: main.py プロジェクト: rpm-software-management/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)
            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
コード例 #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
コード例 #8
0
ファイル: completion_helper.py プロジェクト: max9631/dnf
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()
コード例 #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()
コード例 #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)
コード例 #11
0
ファイル: completion_helper.py プロジェクト: edynox/dnf
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)
コード例 #12
0
ファイル: main.py プロジェクト: 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