How to use the instawow.exceptions.PkgNotInstalled function in instawow

To help you get started, we’ve selected a few instawow 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 layday / instawow / instawow / cli.py View on Github external
def reveal(obj: M, addon: Defn):
    "Bring an add-on up in your file manager."
    pkg = obj.m.get_pkg_from_substr(addon)
    if pkg:
        import webbrowser

        webbrowser.open((obj.m.config.addon_dir / pkg.folders[0].name).as_uri())
    else:
        Report([(addon, E.PkgNotInstalled())]).generate_and_exit()
github layday / instawow / instawow / cli.py View on Github external
def rollback(ctx: click.Context, addon: Defn, undo: bool):
    "Roll an add-on back to an older version."
    from .prompts import Choice, select

    manager: CliManager = ctx.obj.m
    limit = 10

    pkg = manager.get_pkg(addon)
    if not pkg:
        Report([(addon, E.PkgNotInstalled())]).generate_and_exit()
        return  # noop

    resolver = manager.resolvers[pkg.source]
    if not resolver.supports_rollback:
        Report(
            [(addon, E.PkgFileUnavailable('source does not support rollback'))]
        ).generate_and_exit()

    if undo:
        Report(
            chain(
                manager.run(manager.remove([addon])).items(),
                manager.run(manager.install([addon], replace=False)).items(),
            )
        ).generate_and_exit()
github layday / instawow / instawow / manager.py View on Github external
async def remove(self, defns: Sequence[Defn]) -> Dict[Defn, E.ManagerResult]:
        pkgs_by_defn = ((d, self.get_pkg(d)) for d in defns)
        coros = dict_chain(
            defns,
            partial(_error_out, E.PkgNotInstalled()),
            ((d, partial(self.remove_one, p)) for d, p in pkgs_by_defn if p),
        )
        return await self._consume_seq(coros)
github layday / instawow / instawow / manager.py View on Github external
checked_defns = {Defn.from_pkg(p) if p else c: p for c, p in maybe_pkgs}
        # Results can contain errors
        # installables are those results which are packages
        # and updatables are packages with updates
        results = await self.resolve([d for d, p in checked_defns.items() if p])
        installables = {d: r for d, r in results.items() if is_pkg(r)}
        updatables = {
            (d, checked_defns[d], p): download_archive(self, p)
            for d, p in installables.items()
            if p.version != cast(Pkg, checked_defns[d]).version
        }
        archives = await gather(updatables.values())

        coros = dict_chain(
            checked_defns,
            partial(_error_out, E.PkgNotInstalled()),
            ((d, partial(_error_out, r)) for d, r in results.items()),
            ((d, partial(_error_out, E.PkgUpToDate())) for d in installables),
            ((d, partial(self.update_one, *p, a)) for (d, *p), a in zip(updatables, archives)),
        )
        return await self._consume_seq(coros)