Exemplo n.º 1
0
def request_install_missing_deps(pkgname: str, deps: List[Tuple[str, str]],
                                 watcher: ProcessWatcher, i18n: I18n) -> bool:
    msg = '<p>{}</p>'.format(i18n['arch.missing_deps.body'].format(
        name=bold(pkgname) if pkgname else '', deps=bold(str(len(deps)))))

    opts = []

    repo_deps = [d[0] for d in deps if d[1] != 'aur']
    sizes = pacman.get_update_size(repo_deps) if repo_deps else {}

    for dep in deps:
        size = sizes.get(dep[0])
        op = InputOption(
            '{} ({}: {}) - {}: {}'.format(
                dep[0], i18n['repository'], dep[1].lower(),
                i18n['size'].capitalize(),
                get_human_size_str(size) if size else '?'), dep[0])
        op.read_only = True
        op.icon_path = _get_repo_icon(dep[1])
        opts.append(op)

    comp = MultipleSelectComponent(label='',
                                   options=opts,
                                   default_options=set(opts))
    return watcher.request_confirmation(
        i18n['arch.missing_deps.title'],
        msg, [comp],
        confirmation_label=i18n['continue'].capitalize(),
        deny_label=i18n['cancel'].capitalize())
Exemplo n.º 2
0
def request_optional_deps(pkgname: str, pkg_repos: dict,
                          watcher: ProcessWatcher, i18n: I18n) -> Set[str]:
    opts = []

    repo_deps = [
        p for p, data in pkg_repos.items() if data['repository'] != 'aur'
    ]
    sizes = pacman.get_update_size(repo_deps) if repo_deps else {}

    for p, d in pkg_repos.items():
        size = sizes.get(p)
        op = InputOption(
            '{}{} ({}: {}) - {}: {}'.format(
                p, ': ' + d['desc'] if d['desc'] else '', i18n['repository'],
                d['repository'].lower(), i18n['size'].capitalize(),
                get_human_size_str(size) if size else '?'), p)
        op.icon_path = _get_repo_icon(d['repository'])
        opts.append(op)

    view_opts = MultipleSelectComponent(label='',
                                        options=opts,
                                        default_options=set(opts))

    install = watcher.request_confirmation(
        title=i18n['arch.install.optdeps.request.title'],
        body='<p>{}.</p><p>{}:</p>'.format(
            i18n['arch.install.optdeps.request.body'].format(bold(pkgname)),
            i18n['arch.install.optdeps.request.help']),
        components=[view_opts],
        confirmation_label=i18n['install'].capitalize(),
        deny_label=i18n['do_not.install'].capitalize())

    if install:
        return {o.value for o in view_opts.values}
Exemplo n.º 3
0
def request_install_missing_deps(pkgname: str, deps: List[Tuple[str, str]],
                                 watcher: ProcessWatcher, i18n: I18n) -> bool:
    msg = '<p>{}</p>'.format(i18n['arch.missing_deps.body'].format(
        name=bold(pkgname) if pkgname else '', deps=bold(str(len(deps)))))

    opts = []

    sorted_deps = [*deps]
    sorted_deps.sort(key=lambda e: e[0])

    for dep in sorted_deps:
        op = InputOption(
            '{} ( {}: {} )'.format(dep[0], i18n['repository'], dep[1].upper()),
            dep[0])
        op.read_only = True
        op.icon_path = _get_mirror_icon(dep[1])
        opts.append(op)

    comp = MultipleSelectComponent(label='',
                                   options=opts,
                                   default_options=set(opts))

    return watcher.request_confirmation(
        i18n['arch.missing_deps.title'],
        msg, [comp],
        confirmation_label=i18n['continue'].capitalize(),
        deny_label=i18n['cancel'].capitalize())
Exemplo n.º 4
0
def request_optional_deps(pkgname: str, pkg_mirrors: dict,
                          watcher: ProcessWatcher, i18n: I18n) -> Set[str]:
    opts = []

    for p, d in pkg_mirrors.items():
        op = InputOption(
            '{}{} ( {}: {} )'.format(p, ': ' + d['desc'] if d['desc'] else '',
                                     i18n['repository'], d['mirror'].upper()),
            p)
        op.icon_path = _get_mirror_icon(d['mirror'])
        opts.append(op)

    view_opts = MultipleSelectComponent(label='',
                                        options=opts,
                                        default_options=set(opts))

    install = watcher.request_confirmation(
        title=i18n['arch.install.optdeps.request.title'],
        body='<p>{}.</p><p>{}:</p>'.format(
            i18n['arch.install.optdeps.request.body'].format(bold(pkgname)),
            i18n['arch.install.optdeps.request.help']),
        components=[view_opts],
        confirmation_label=i18n['install'].capitalize(),
        deny_label=i18n['do_not.install'].capitalize())

    if install:
        return {o.value for o in view_opts.values}
Exemplo n.º 5
0
def request_optional_deps(pkgname: str, pkg_repos: dict, watcher: ProcessWatcher, i18n: I18n) -> Set[str]:
    opts = []

    repo_deps = [p for p, data in pkg_repos.items() if data['repository'] != 'aur']
    sizes = pacman.map_update_sizes(repo_deps) if repo_deps else {}

    for p, d in pkg_repos.items():
        size = sizes.get(p)
        label = f"{p} ({i18n['repository']}: {d['repository'].lower()}) | " \
                f"{i18n['size'].capitalize()}: {get_human_size_str(size) if size is not None else '?'}"
        op = InputOption(label=label, value=p, tooltip=d.get('desc') or None)
        op.icon_path = _get_repo_icon(d['repository'])
        opts.append(op)

    view_opts = MultipleSelectComponent(label='',
                                        options=opts,
                                        default_options=set(opts))

    msg = f"<p>{i18n['arch.install.optdeps.request.success'].format(pkg=bold(pkgname))}</p>" \
          f"<p>{i18n['arch.install.optdeps.request.body']}:</p>"

    install = watcher.request_confirmation(title=i18n['arch.install.optdeps.request.title'],
                                           body=msg,
                                           components=[view_opts],
                                           confirmation_label=i18n['install'].capitalize(),
                                           deny_label=i18n['do_not.install'].capitalize(),
                                           min_width=600,
                                           min_height=200)

    if install:
        return {o.value for o in view_opts.values}
Exemplo n.º 6
0
def confirm_missing_deps(deps: Collection[Tuple[str, str]], watcher: ProcessWatcher, i18n: I18n) -> bool:
    opts = []

    total_isize, total_dsize = None, None
    pkgs_data = pacman.map_updates_data(pkgs=tuple(d[0] for d in deps if d[1] != 'aur'), description=True) or dict()

    for dep in deps:
        ver, desc, isize, dsize = None, None, None, None
        data = pkgs_data.get(dep[0])

        if data:
            desc, isize, dsize = (data.get(f) for f in ('des', 's', 'ds'))

            if isize is not None:
                if total_isize is None:
                    total_isize = 0

                total_isize += isize

            if dsize is not None:
                if total_dsize is None:
                    total_dsize = 0

                total_dsize += dsize

        label = f"{dep[0]} | " \
                f"{i18n['size'].capitalize()}: {get_human_size_str(isize) if isize is not None else '?'}" \
                f"{' ({}: {})'.format(i18n['download'].capitalize(), get_human_size_str(dsize)) if dsize else ''}"

        op = InputOption(label=label, value=dep[0], tooltip=desc)
        op.read_only = True
        op.icon_path = _get_repo_icon(dep[1])
        opts.append(op)

    comp = MultipleSelectComponent(label='', options=opts, default_options=set(opts))

    body = StringIO()
    body.write('<p>')
    body.write(i18n['arch.missing_deps.body'].format(deps=bold(str(len(deps)))))

    if total_isize is not None or total_dsize is not None:
        body.write(' (')

        if total_isize is not None:
            body.write(f"{i18n['size'].capitalize()}: {bold(get_human_size_str(total_isize))} | ")

        if total_dsize is not None:
            body.write(f"{i18n['download'].capitalize()}: {bold(get_human_size_str(total_dsize))}")

        body.write(')')

    body.write(':</p>')

    return watcher.request_confirmation(title=i18n['arch.missing_deps.title'],
                                        body=body.getvalue(),
                                        components=[comp],
                                        confirmation_label=i18n['continue'].capitalize(),
                                        deny_label=i18n['cancel'].capitalize(),
                                        min_width=625)