How to use the pikaur.pprint.color_line function in pikaur

To help you get started, we’ve selected a few pikaur examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github actionless / pikaur / pikaur / build.py View on Github external
def _install_repo_deps(self) -> None:
        if not self.all_deps_to_install:
            return
        # @TODO: use lock file?
        print_stderr('{} {}:'.format(
            color_line('::', 13),
            _("Installing repository dependencies for {}").format(
                bold_line(', '.join(self.package_names)))
        ))
        retry_interactive_command_or_exit(
            sudo(
                self._get_pacman_command() + [
                    '--sync',
                    '--asdeps',
                ] + self.all_deps_to_install
            ),
            pikspect=True,
            conflicts=self.resolved_conflicts,
        )
        PackageDB.discard_local_cache()
github actionless / pikaur / pikaur / install_cli.py View on Github external
pkg_name = packages_to_be_built[index]
            repo_status = self.package_builds_by_name[pkg_name]
            if self.args.needed and repo_status.version_already_installed:
                packages_to_be_built.remove(pkg_name)
                continue

            try:
                repo_status.build(
                    all_package_builds=self.package_builds_by_name,
                    resolved_conflicts=self.resolved_conflicts
                )
            except (BuildError, DependencyError) as exc:
                print_stderr(exc)
                print_stderr(
                    color_line(_("Can't build '{name}'.").format(name=pkg_name) + '\n', 9)
                )
                # if not ask_to_continue():
                #     raise SysExit(125)
                for _pkg_name in repo_status.package_names:
                    failed_to_build_package_names.append(_pkg_name)
                    self.discard_install_info(_pkg_name)
                    for remaining_aur_pkg_name in packages_to_be_built[:]:
                        if remaining_aur_pkg_name not in self.all_aur_packages_names:
                            packages_to_be_built.remove(remaining_aur_pkg_name)
            except DependencyNotBuiltYet:
                index += 1
                for _pkg_name in repo_status.package_names:
                    deps_fails_counter.setdefault(_pkg_name, 0)
                    deps_fails_counter[_pkg_name] += 1
                    if deps_fails_counter[_pkg_name] > len(self.all_aur_packages_names):
                        print_error(
github actionless / pikaur / pikaur / main.py View on Github external
def cli_clean_packages_cache() -> None:
    args = parse_args()
    if not args.repo:
        for directory, message, minimal_clean_level in (
                (BUILD_CACHE_PATH, _("Build directory"), 1, ),
                (PACKAGE_CACHE_PATH, _("Packages directory"), 2, ),
        ):
            if minimal_clean_level <= args.clean and os.path.exists(directory):
                print_stdout('\n' + "{}: {}".format(message, directory))
                if ask_to_continue(text='{} {}'.format(
                        color_line('::', 12),
                        _("Do you want to remove all files?")
                )):
                    remove_dir(directory)
    if not args.aur:
        raise SysExit(
            interactive_spawn(sudo(
                [PikaurConfig().misc.PacmanPath.get_str(), ] + reconstruct_args(args)
            )).returncode
github actionless / pikaur / pikaur / install_cli.py View on Github external
try:
            self.install_info = InstallInfoFetcher(
                install_package_names=self.install_package_names,
                not_found_repo_pkgs_names=self.not_found_repo_pkgs_names,
                pkgbuilds_paths=self.pkgbuilds_paths,
                manually_excluded_packages_names=self.manually_excluded_packages_names,
            )
        except PackagesNotFoundInAUR as exc:
            if exc.wanted_by:
                print_error(bold_line(
                    _("Dependencies missing for {}").format(', '.join(exc.wanted_by))
                ))
            print_not_found_packages(exc.packages)
            raise SysExit(131)
        except DependencyVersionMismatch as exc:
            print_stderr(color_line(_("Version mismatch:"), 11))
            print_stderr(
                _("{what} depends on: '{dep}'\n found in '{location}': '{version}'").format(
                    what=bold_line(exc.who_depends),
                    dep=exc.dependency_line,
                    location=exc.location,
                    version=exc.version_found,
                )
            )
            raise SysExit(131)
        else:
            self.aur_deps_relations = self.install_info.aur_deps_relations

        if self.args.repo and self.not_found_repo_pkgs_names:
            print_not_found_packages(self.not_found_repo_pkgs_names, repo=True)
            raise SysExit(6)
github actionless / pikaur / pikaur / prompt.py View on Github external
**kwargs
) -> bool:
    args = parse_args()
    while True:
        good = None
        if pikspect:
            # pylint:disable=import-outside-toplevel
            from .pikspect import pikspect as pikspect_spawn
            good = pikspect_spawn(cmd_args, **kwargs).returncode == 0
        else:
            if 'conflicts' in kwargs:
                del kwargs['conflicts']
            good = interactive_spawn(cmd_args, **kwargs).returncode == 0
        if good:
            return good
        print_stderr(color_line(_("Command '{}' failed to execute.").format(
            ' '.join(cmd_args)
        ), 9))
        if not ask_to_continue(
                text=_("Do you want to retry?"),
                default_yes=not args.noconfirm
        ):
            return False
github actionless / pikaur / pikaur / build.py View on Github external
def get_latest_dev_sources(self, check_dev_pkgs=True) -> None:
        self.prepare_build_destination()
        if (
                self._source_repo_updated
        ) or (
            not (is_devel_pkg(self.package_base) and check_dev_pkgs)
        ) or (
            (self.last_installed_hash != self.current_hash) and not self.reviewed
        ):
            return
        print_stdout('{} {}...'.format(
            color_line('::', 15),
            _n(
                "Downloading the latest sources for a devel package {}",
                "Downloading the latest sources for devel packages {}",
                len(self.package_names)
            ).format(
                bold_line(', '.join(self.package_names))
            )
        ))
        pkgver_result = joined_spawn(
            isolate_root_cmd(
                MakePkgCommand.get() + [
                    '--nobuild', '--noprepare', '--nocheck', '--nodeps'
                ],
                cwd=self.build_dir
            ),
            cwd=self.build_dir,
github actionless / pikaur / pikaur / build.py View on Github external
)
            print_stdout()
            build_succeeded = result.returncode == 0
            if build_succeeded:
                break

            print_stderr(color_line(_("Command '{}' failed to execute.").format(
                ' '.join(cmd_args)
            ), 9))
            if PikaurConfig().build.SkipFailedBuild.get_bool():
                answer = _("s")
            elif self.args.noconfirm:
                answer = _("a")
            else:  # pragma: no cover
                prompt = '{} {}\n{}\n> '.format(
                    color_line('::', 11),
                    _("Try recovering?"),
                    "\n".join((
                        _("[R] retry build"),
                        _("[p] PGP check skip"),
                        _("[c] checksums skip"),
                        _("[i] ignore architecture"),
                        _("[d] delete build dir and try again"),
                        _("[e] edit PKGBUILD"),
                        "-" * 24,
                        _("[s] skip building this package"),
                        _("[a] abort building all the packages"),
                    ))
                )
                answer = get_input(
                    prompt,
                    _('r').upper() + _('p') + _('c') + _('i') + _('d') + _('e') +
github actionless / pikaur / pikaur / install_cli.py View on Github external
def _confirm_sysupgrade(verbose=False) -> str:
            _print_sysupgrade(verbose=verbose)
            prompt = '{} {}\n{} {}\n>> '.format(
                color_line('::', 12),
                bold_line(_('Proceed with installation? [Y/n] ')),
                color_line('::', 12),
                bold_line(_('[v]iew package details   [m]anually select packages')))

            answer = get_input(prompt, _('y').upper() + _('n') + _('v') + _('m'))

            return answer
github actionless / pikaur / pikaur / pikspect.py View on Github external
cmd,
        print_output=print_output,
        default_questions=default_questions,
        **kwargs
    )

    extra_questions = extra_questions or {}
    if conflicts:
        extra_questions[YesNo.ANSWER_Y] = (
            extra_questions.get(YesNo.ANSWER_Y, []) + format_conflicts(conflicts)
        )
    if extra_questions:
        proc.add_answers(extra_questions)

    if parse_args().verbose:
        print_stderr(color_line('=> ', 14) + ' '.join(cmd))
    proc.run()
    return proc
github actionless / pikaur / pikaur / build.py View on Github external
def build_with_makepkg(self) -> bool:  # pylint: disable=too-many-branches,too-many-statements
        makepkg_args = []
        if not self.args.needed:
            makepkg_args.append('--force')
        if not color_enabled():
            makepkg_args.append('--nocolor')

        print_stderr('\n{} {}:'.format(
            color_line('::', 13),
            _('Starting the build')
        ))
        build_succeeded = False
        skip_pgp_check = False
        skip_file_checksums = False
        while True:
            cmd_args = MakePkgCommand.get() + makepkg_args
            if skip_pgp_check:
                cmd_args += ['--skippgpcheck']
            if skip_file_checksums:
                cmd_args += ['--skipchecksums']
            if self.skip_carch_check:
                cmd_args += ['--ignorearch']
            cmd_args = isolate_root_cmd(cmd_args, cwd=self.build_dir)
            spawn_kwargs: Dict[str, Any] = {}
            if self.args.hide_build_log: