How to use the pyalpm.SIG_DATABASE_OPTIONAL function in pyalpm

To help you get started, we’ve selected a few pyalpm 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 archlinux / pyalpm / test / tests.py View on Github external
import pyalpm

h = pyalpm.Handle("/", "/var/lib/pacman")

localdb = h.get_localdb()
print("Local database information")
print("  DB name:", localdb.name, "servers:", localdb.servers)
print("  Packages:", len(localdb.pkgcache))

for name, pkgs in localdb.grpcache:
    print("  Group:", name, [pkg.name for pkg in pkgs])
print("")

print("Registering [core], [extra], [community]...")
core = h.register_syncdb("core", pyalpm.SIG_DATABASE_OPTIONAL)
extra = h.register_syncdb("extra", pyalpm.SIG_DATABASE_OPTIONAL)
community = h.register_syncdb("community", pyalpm.SIG_DATABASE_OPTIONAL)
print("")

print("Available sync DBs")
for db in h.get_syncdbs():
    print("  DB:", db.name, "servers:", db.servers)
print("")

print("Package information about glibc")
pkg = localdb.get_pkg("glibc")
for attr in dir(pkg):
    if attr.startswith('_'):
        continue
    if attr == "files":
        print("  ", len(pkg.files), "files")
    else:
github archlinux / pyalpm / test / tests.py View on Github external
import os
import pyalpm

h = pyalpm.Handle("/", "/var/lib/pacman")

localdb = h.get_localdb()
print("Local database information")
print("  DB name:", localdb.name, "servers:", localdb.servers)
print("  Packages:", len(localdb.pkgcache))

for name, pkgs in localdb.grpcache:
    print("  Group:", name, [pkg.name for pkg in pkgs])
print("")

print("Registering [core], [extra], [community]...")
core = h.register_syncdb("core", pyalpm.SIG_DATABASE_OPTIONAL)
extra = h.register_syncdb("extra", pyalpm.SIG_DATABASE_OPTIONAL)
community = h.register_syncdb("community", pyalpm.SIG_DATABASE_OPTIONAL)
print("")

print("Available sync DBs")
for db in h.get_syncdbs():
    print("  DB:", db.name, "servers:", db.servers)
print("")

print("Package information about glibc")
pkg = localdb.get_pkg("glibc")
for attr in dir(pkg):
    if attr.startswith('_'):
        continue
    if attr == "files":
        print("  ", len(pkg.files), "files")
github lfos / aurweb / aurweb / scripts / aurblup.py View on Github external
def main():
    blacklist = set()
    providers = set()
    repomap = dict()

    h = pyalpm.Handle("/", db_path)
    for sync_db in sync_dbs:
        repo = h.register_syncdb(sync_db, pyalpm.SIG_DATABASE_OPTIONAL)
        repo.servers = [server.replace("%s", sync_db)]
        t = h.init_transaction()
        repo.update(False)
        t.release()

        for pkg in repo.pkgcache:
            blacklist.add(pkg.name)
            [blacklist.add(x) for x in pkg.replaces]
            providers.add((pkg.name, pkg.name))
            repomap[(pkg.name, pkg.name)] = repo.name
            for provision in pkg.provides:
                provisionname = re.sub(r'(<|=|>).*', '', provision)
                providers.add((pkg.name, provisionname))
                repomap[(pkg.name, provisionname)] = repo.name

    conn = aurweb.db.Connection()