How to use the pikaur.config.PikaurConfig 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 main() -> None:
    try:
        args = parse_args()
    except ArgumentError as exc:
        print_stderr(exc)
        sys.exit(22)
    check_runtime_deps()

    create_dirs()
    # initialize config to avoid race condition in threads:
    PikaurConfig.get_config()

    atexit.register(restore_tty)
    signal.signal(signal.SIGPIPE, signal.SIG_DFL)
    if not args.verbose:
        signal.signal(signal.SIGINT, handle_sig_int)

    try:
        cli_entry_point()
    except BrokenPipeError:
        # @TODO: should it be 32?
        sys.exit(0)
    except SysExit as exc:
        sys.exit(exc.code)
    sys.exit(0)
github actionless / pikaur / pikaur / prompt.py View on Github external
def get_input(prompt: str, answers: Iterable[str] = ()) -> str:
    require_confirm = max(len(choice) > 1 for choice in answers) if answers else False
    with PrintLock():
        if not(
                require_confirm or PikaurConfig().ui.RequireEnterConfirm.get_bool()
        ):
            answer = read_answer_from_tty(prompt, answers=answers)
        else:
            from .pikspect import TTYRestore  # pylint:disable=import-outside-toplevel
            sub_tty = TTYRestore()
            TTYRestore.restore()
            try:
                answer = input(split_last_line(prompt)).lower()
            except EOFError:
                raise SysExit(125)
            finally:
                sub_tty.restore_new()
            if not answer:
                for choice in answers:
                    if choice.isupper():
                        return choice.lower()
github actionless / pikaur / pikaur / core.py View on Github external
def get_sudo_refresh_command() -> List[str]:
    pacman_path = PikaurConfig().misc.PacmanPath.get_str()
    return sudo([pacman_path, '-T'])
github actionless / pikaur / pikaur / print_department.py View on Github external
installed = color_line(_("[installed]") + ' ', 14)

            rating = ''
            if (
                    isinstance(package, AURPackageInfo)
            ) and (
                package.numvotes is not None
            ) and (
                package.popularity is not None
            ):
                rating = color_line('({}, {:.2f})'.format(
                    package.numvotes,
                    package.popularity
                ), 3)

            color_config = PikaurConfig().colors
            version_color = color_config.Version.get_int()
            version = package.version

            if isinstance(package, AURPackageInfo) and package.outofdate is not None:
                version_color = color_config.VersionDiffOld.get_int()
                version = "{} [{}: {}]".format(
                    package.version,
                    _("outofdate"),
                    datetime.fromtimestamp(package.outofdate).strftime('%Y/%m/%d')
                )

            print("{}{}{} {} {}{}{}".format(
                idx,
                repo,
                bold_line(pkg_name),
                color_line(version, version_color),
github actionless / pikaur / pikaur / package_update.py View on Github external
pkg_name = aur_pkg.name
        aur_version = aur_pkg.version
        current_version = local_packages[pkg_name].version
        compare_aur_pkg = compare_versions(current_version, aur_version)
        if compare_aur_pkg < 0:
            aur_updates.append(PackageUpdate(
                name=pkg_name,
                new_version=aur_version,
                current_version=current_version,
                description=aur_pkg.desc,
                package=aur_pkg,
            ))
        else:
            aur_pkgs_up_to_date.append(aur_pkg)
    if aur_pkgs_up_to_date:
        sync_config = PikaurConfig().sync
        devel_packages_expiration = sync_config.get_int('DevelPkgsExpiration')
        if args.devel:
            devel_packages_expiration = 0
        if devel_packages_expiration > -1:
            aur_updates += find_aur_devel_updates(
                aur_pkgs_up_to_date,
                package_ttl_days=devel_packages_expiration
            )
    return aur_updates, not_found_aur_pkgs
github actionless / pikaur / pikaur / build.py View on Github external
self.repo_path = dirname(pkgbuild_path)
            self.pkgbuild_path = pkgbuild_path
            srcinfo = SrcInfo(pkgbuild_path=pkgbuild_path)
            pkgbase = srcinfo.get_value('pkgbase')
            if pkgbase and srcinfo.pkgnames:
                self.package_names = srcinfo.pkgnames
                self.package_base = pkgbase
            else:
                raise BuildError(_("Can't get package name from PKGBUILD"))
        else:
            raise NotImplementedError('Either `package_names` or `pkgbuild_path` should be set')

        self.build_dir = os.path.join(BUILD_CACHE_PATH, self.package_base)
        self.built_packages_paths = {}
        self.keep_build_dir = self.args.keepbuild or (
            is_devel_pkg(self.package_base) and PikaurConfig().build.KeepDevBuildDir.get_bool()
        )

        if os.path.exists(self.repo_path):
            # pylint: disable=simplifiable-if-statement
            if os.path.exists(os.path.join(self.repo_path, '.git')):
                self.pull = True
            else:
                self.clone = True
        else:
            os.makedirs(self.repo_path)
            self.clone = True
github actionless / pikaur / pikaur / args.py View on Github external
def get_pikaur_bool_opts() -> ArgSchema:
    return [
        (None, 'noedit', PikaurConfig().build.NoEdit.get_bool()),
        (None, 'edit', None),
        (None, 'namesonly', None),
        (None, 'repo', None),
        ('a', 'aur', None),
        (None, 'keepbuild', PikaurConfig().build.KeepBuildDir.get_bool()),
        (None, 'keepbuilddeps', PikaurConfig().build.KeepBuildDeps.get_bool()),
        (None, 'nodiff', PikaurConfig().build.NoDiff.get_bool()),
        (None, 'rebuild', None),
        (None, 'dynamic-users', PikaurConfig().build.AlwaysUseDynamicUsers.get_bool()),
        ('P', 'pkgbuild', None),
        (None, 'install', None),
        ('G', 'getpkgbuild', None),
        (None, 'deps', None),
        # undocumented options:
        (None, 'print-commands', PikaurConfig().ui.PrintCommands.get_bool()),
        (None, 'hide-build-log', None),
        (None, 'print-args-and-exit', None),
    ]
github actionless / pikaur / pikaur / core.py View on Github external
def sudo_loop(once=False) -> None:
    """
    get sudo for further questions
    """
    sudo_loop_interval = PikaurConfig().misc.SudoLoopInterval.get_int()
    if sudo_loop_interval == -1:
        return
    while True:
        interactive_spawn(get_sudo_refresh_command())
        if once:
            break
        sleep(sudo_loop_interval)