How to use the pikaur.pprint.print_error 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 / main.py View on Github external
def check_runtime_deps(dep_names: Optional[List[str]] = None) -> None:
    if sys.version_info.major < 3 or sys.version_info.minor < 7:
        print_error(
            _("pikaur requires Python >= 3.7 to run."),
        )
        sys.exit(65)
    if running_as_root() and not check_systemd_dynamic_users():
        print_error(
            _("pikaur requires systemd >= 235 (dynamic users) to be run as root."),
        )
        sys.exit(65)
    if not dep_names:
        dep_names = [
            "fakeroot",
        ] + (['sudo'] if not running_as_root() else [])
    for dep_bin in dep_names:
        if not shutil.which(dep_bin):
            print_error("'{}' {}.".format(
                bold_line(dep_bin),
                "executable not found"
            ))
            sys.exit(2)
github actionless / pikaur / pikaur / build.py View on Github external
deps_packages_installed = local_packages_after.difference(local_packages_before)
        deps_packages_removed = local_packages_before.difference(local_packages_after)

        # check if there is diff incosistency because of the package replacement:
        if deps_packages_removed:
            for removed_pkg_name in list(deps_packages_removed):
                for installed_pkg_name in list(deps_packages_installed):
                    if (
                            removed_pkg_name in local_provided_pkgs
                    ) and (installed_pkg_name in local_provided_pkgs[removed_pkg_name]):
                        deps_packages_installed.remove(installed_pkg_name)
                        deps_packages_removed.remove(removed_pkg_name)
                        continue

        if deps_packages_removed:
            print_error(
                _("Failed to remove installed dependencies, packages inconsistency: {}").format(
                    bold_line(', '.join(deps_packages_removed))
                )
            )
            if not ask_to_continue():
                raise SysExit(125)
        if not deps_packages_installed or self.args.keepbuilddeps:
            return

        print_stderr('{} {}:'.format(
            color_line('::', 13),
            _("Removing already installed dependencies for {}").format(
                bold_line(', '.join(self.package_names)))
        ))
        retry_interactive_command_or_exit(
            sudo(
github actionless / pikaur / pikaur / build.py View on Github external
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,
        )
        if pkgver_result.returncode != 0:
            print_error(_("failed to retrieve latest dev sources:"))
            print_stderr(pkgver_result.stdout_text)
            if not ask_to_continue(default_yes=False):
                raise SysExit(125)
        SrcInfo(self.build_dir).regenerate()
        self._source_repo_updated = True
github actionless / pikaur / pikaur / news.py View on Github external
def fetch_latest(self) -> None:
        try:
            http_response: Union[HTTPResponse, urllib.response.addinfourl] = \
                urllib.request.urlopen(self.URL)
        except urllib.error.URLError:
            print_error(_('Could not fetch archlinux.org news'))
            return
        str_response: str = ''
        for line in http_response:
            str_response += line.decode('UTF-8').strip()
        if not str_response:  # could not get data
            return
        self._news_feed = xml.etree.ElementTree.fromstring(str_response)
github actionless / pikaur / pikaur / install_cli.py View on Github external
self.repo_packages_by_name = {}

        for pkg_name in self.manually_excluded_packages_names:
            if pkg_name in self.install_package_names:
                self.install_package_names.remove(pkg_name)

        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:
github actionless / pikaur / pikaur / main.py View on Github external
print_error(
            _("pikaur requires Python >= 3.7 to run."),
        )
        sys.exit(65)
    if running_as_root() and not check_systemd_dynamic_users():
        print_error(
            _("pikaur requires systemd >= 235 (dynamic users) to be run as root."),
        )
        sys.exit(65)
    if not dep_names:
        dep_names = [
            "fakeroot",
        ] + (['sudo'] if not running_as_root() else [])
    for dep_bin in dep_names:
        if not shutil.which(dep_bin):
            print_error("'{}' {}.".format(
                bold_line(dep_bin),
                "executable not found"
            ))
            sys.exit(2)
github actionless / pikaur / pikaur / srcinfo.py View on Github external
def regenerate(self) -> None:
        result = spawn(
            isolate_root_cmd(
                MakePkgCommand.get() + ['--printsrcinfo'] +
                ['-p', os.path.basename(self.pkgbuild_path)],
                cwd=self.repo_path
            ), cwd=self.repo_path
        )
        if result.returncode != 0:
            print_error(_("failed to generate .SRCINFO from {}:").format(self.pkgbuild_path))
            print_stderr(result.stderr_text)
            raise SysExit(5)
        with open_file(self.path, 'w') as srcinfo_file:
            srcinfo_file.write(result.stdout_text)
        self.load_config()
github actionless / pikaur / pikaur / search_cli.py View on Github external
def package_search_thread_aur(queries: List[str]) -> Dict[str, List[Any]]:
    args = parse_args()
    result = {}
    if queries:
        use_as_filters: List[str] = []
        with ThreadPool() as pool:
            requests = {}
            for query in queries:
                requests[query] = pool.apply_async(aur_rpc_search_name_desc, (query, ))
            pool.close()
            for query, request in requests.items():
                try:
                    result[query] = request.get()
                except AURError as exc:
                    if exc.error == "Too many package results.":
                        print_error(
                            _("AUR: Too many package results for '{query}'").format(
                                query=query
                            )
                        )
                        use_as_filters.append(query)
                    else:
                        raise
            pool.join()
        for query in use_as_filters:
            result = filter_aur_results(result, query)
        if args.namesonly:
            for subindex, subresult in result.items():
                result[subindex] = [
                    pkg for pkg in subresult
                    if subindex in pkg.name
                ]
github actionless / pikaur / pikaur / news.py View on Github external
except (IOError, ValueError):
            # if file doesn't exist or corrupted,
            # this feature was run the first time
            # then we get take the date from the last installed package:
            last_pkg_date: datetime.datetime = datetime.datetime.fromtimestamp(
                PackageDB.get_last_installed_package_date()
            )
            last_pkg_date = last_pkg_date.replace(
                tzinfo=datetime.datetime.now().astimezone().tzinfo
            )
            time_formatted: str = last_pkg_date.strftime(DT_FORMAT)
            try:
                with open(self.CACHE_FILE, 'w') as last_seen_fd:
                    last_seen_fd.write(time_formatted)
            except IOError:
                print_error(_('Could not initialize {}').format(self.CACHE_FILE))
            return last_pkg_date