How to use the transaction.initReadOnlyTransaction function in transaction

To help you get started, we’ve selected a few transaction 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 dagwieers / mrepo / up2date_client / rpmUtils.py View on Github external
def installedHeaderByKeyword(**kwargs):
    _ts = transaction.initReadOnlyTransaction()
    mi = _ts.dbMatch()
    for keyword in kwargs.keys():
        mi.pattern(keyword, rpm.RPMMIRE_GLOB, kwargs[keyword])
    # we really shouldnt be getting multiples here, but what the heck
    headerList = []
    for h in mi:
        #print "%s-%s-%s.%s" % ( h['name'], h['version'], h['release'], h['arch'])
        
        headerList.append(h)

    return headerList
github dagwieers / mrepo / up2date_client / rpmUtils.py View on Github external
def checkRpmMd5(fileName):
    _ts = transaction.initReadOnlyTransaction()
    # XXX Verify only header+payload MD5 with f*cked up contrapositive logic
    _ts.pushVSFlags(~(rpm.RPMVSF_NOMD5|rpm.RPMVSF_NEEDPAYLOAD))
    
    fdno = os.open(fileName, os.O_RDONLY)
    try:
        h = _ts.hdrFromFdno(fdno)
    except rpm.error, e:
        _ts.popVSFlags()
        return 0
    os.close(fdno)
    _ts.popVSFlags()
    return 1
github uyuni-project / uyuni / client / debian / packages-already-in-debian / rhn-client-tools / src / up2date_client / up2dateUtils.py View on Github external
def _getOSVersionAndRelease():
        ts = transaction.initReadOnlyTransaction()
        for h in ts.dbMatch('Providename', "redhat-release"):
            osVersionRelease = (h['name'], h['version'], h['release'])
            return osVersionRelease
        else:
            for h in ts.dbMatch('Providename', "distribution-release"):
                osVersionRelease = (h['name'], h['version'], h['release'])
                # zypper requires a exclusive lock on the rpmdb. So we need
                # to close it here.
                ts.ts.closeDB()
                return osVersionRelease
            else:
                raise up2dateErrors.RpmError(
                    "Could not determine what version of Red Hat Linux you "\
                    "are running.\nIf you get this error, try running \n\n"\
github dagwieers / mrepo / up2date_client / rpmSource.py View on Github external
def __init__(self, cacheObject = None):
        # this is the cache, stuff here is only in storageDir
        self.cfg = config.initUp2dateConfig()
        self.log = up2dateLog.initLog()
        self.dir_list = [self.cfg["storageDir"]]
        self.ts =  transaction.initReadOnlyTransaction()
        PackageSource.__init__(self, cacheObject = cacheObject)
github dagwieers / mrepo / up2date_client / rhnErrata.py View on Github external
def getAdvisoryInfo(pkg, warningCallback=None):
    log = up2dateLog.initLog()
    cfg = config.initUp2dateConfig()
    # no errata for non rhn use
    if not cfg['useRhn']:
        return None
        
    s = rpcServer.getServer()

    ts = transaction.initReadOnlyTransaction()
    mi = ts.dbMatch('Providename', pkg[0])
    if not mi:
	return None

    # odd,set h to last value in mi. mi has to be iterated
    # to get values from it...
    h = None
    for h in mi:
        break

    info = None

    # in case of package less errata that somehow apply
    if h:
        try:
            pkgName = "%s-%s-%s" % (h['name'],
github dagwieers / mrepo / up2date_client / rpmUtils.py View on Github external
def installedHeaderIndex(**kwargs):
    _ts = transaction.initReadOnlyTransaction()
    mi = _ts.dbMatch()
    for keyword in kwargs.keys():
        mi.pattern(keyword, rpm.RPMMIRE_GLOB, kwargs[keyword])
        
    # we really shouldnt be getting multiples here, but what the heck
    instanceList = []
    for h in mi:
        instance = mi.instance()
        instanceList.append(instance)

    return instanceList