當前位置: 首頁>>代碼示例>>Python>>正文


Python rpm.TransactionSet方法代碼示例

本文整理匯總了Python中rpm.TransactionSet方法的典型用法代碼示例。如果您正苦於以下問題:Python rpm.TransactionSet方法的具體用法?Python rpm.TransactionSet怎麽用?Python rpm.TransactionSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rpm的用法示例。


在下文中一共展示了rpm.TransactionSet方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import TransactionSet [as 別名]
def __init__(self, *args, **kwargs):
        ReviewBot.ReviewBot.__init__(self, *args, **kwargs)

        self.no_review = False
        self.force = False

        self.ts = rpm.TransactionSet()
        self.ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES)

        # reports of source submission
        self.reports = []
        # textual report summary for use in accept/decline message
        # or comments
        self.text_summary = ''

        self.session = DB.db_session()

        self.dblogger = LogToDB(self.session)

        self.logger.addFilter(self.dblogger)

        self.commentapi = CommentAPI(self.apiurl)

        self.current_request = None 
開發者ID:openSUSE,項目名稱:openSUSE-release-tools,代碼行數:26,代碼來源:abichecker.py

示例2: get_rpm_info

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import TransactionSet [as 別名]
def get_rpm_info(path):
    ts = rpm.TransactionSet()

    # disable signature checks, we might not have the key or the file might be unsigned
    # pre 4.15 RPM needs to use the old name of the bitmask
    try:
        vsflags = rpm.RPMVSF_MASK_NOSIGNATURES
    except AttributeError:
        vsflags = rpm._RPMVSF_NOSIGNATURES
    ts.setVSFlags(vsflags)

    with open(path) as rpmfile:
        rpmhdr = ts.hdrFromFdno(rpmfile)

    name = rpmhdr[rpm.RPMTAG_NAME].decode('ascii')
    epoch = rpmhdr[rpm.RPMTAG_EPOCHNUM]
    version = rpmhdr[rpm.RPMTAG_VERSION].decode('ascii')
    release = rpmhdr[rpm.RPMTAG_RELEASE].decode('ascii')
    arch = rpmhdr[rpm.RPMTAG_ARCH].decode('ascii')

    return (name, epoch, version, release, arch) 
開發者ID:theforeman,項目名稱:foreman-ansible-modules,代碼行數:23,代碼來源:content_upload.py

示例3: _get_rpms

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import TransactionSet [as 別名]
def _get_rpms(self):
        # TODO: External dep!
        import rpm

        chroot_os = os.path.join(self.dest, "rootfs")
        ts = rpm.TransactionSet(chroot_os)
        ts.setVSFlags((rpm._RPMVSF_NOSIGNATURES | rpm._RPMVSF_NODIGESTS))
        image_rpms = []
        for hdr in ts.dbMatch():  # No sorting
            if hdr['name'] == 'gpg-pubkey':
                continue
            else:
                foo = "{0}-{1}-{2}-{3}-{4}".format(hdr['name'],
                                                   hdr['epochnum'],
                                                   hdr['version'],
                                                   hdr['release'],
                                                   hdr['arch'])
                image_rpms.append(foo)
        return image_rpms 
開發者ID:OpenSCAP,項目名稱:openscap-daemon,代碼行數:21,代碼來源:scan.py

示例4: __init__

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import TransactionSet [as 別名]
def __init__(self, *args, **kwargs):
        cmdln.Cmdln.__init__(self, args, kwargs)
        self.ts = rpm.TransactionSet()
        self.ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES) 
開發者ID:openSUSE,項目名稱:openSUSE-release-tools,代碼行數:6,代碼來源:factory-package-news.py

示例5: get_rpm_list

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import TransactionSet [as 別名]
def get_rpm_list(tags=None, separator=';'):
    """
    Return a list of RPMs in the format expected by parse_rpm_output.
    """
    if tags is None:
        tags = image_component_rpm_tags
    ts = rpm.TransactionSet()
    mi = ts.dbMatch()
    rpms = []
    for h in mi:
        rpms.append(separator.join([h.sprintf("%%{%s}" % tag) for tag in tags]))
    return rpms 
開發者ID:containerbuildsystem,項目名稱:atomic-reactor,代碼行數:14,代碼來源:rpm.py

示例6: openshift_installed

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import TransactionSet [as 別名]
def openshift_installed():
        ''' check if openshift is installed '''
        import rpm

        transaction_set = rpm.TransactionSet()
        rpmquery = transaction_set.dbMatch("name", "atomic-openshift")

        return rpmquery.count() > 0

    # Disabling too-many-branches.  This is a yaml dictionary comparison function
    # pylint: disable=too-many-branches,too-many-return-statements,too-many-statements 
開發者ID:RedHatOfficial,項目名稱:ansible-redhat_openshift_utils,代碼行數:13,代碼來源:oc_obj.py

示例7: yieldSrpmHeaders

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import TransactionSet [as 別名]
def yieldSrpmHeaders(srpms, plainRpmOk=0):
    import rpm
    ts = rpm.TransactionSet('/')
    # When RPM > 4.14.90 is common we can use RPMVSF_MASK_NOSIGNATURES, RPMVSF_MASK_NODIGESTS
    # pylint: disable=protected-access
    flags = (rpm._RPMVSF_NOSIGNATURES | rpm._RPMVSF_NODIGESTS)
    ts.setVSFlags(flags)
    for srpm in srpms:
        srpm = host_file(srpm)
        try:
            fd = os.open(srpm, os.O_RDONLY)
        except OSError as e:
            raise exception.Error("Cannot find/open srpm: %s. Error: %s"
                                  % (srpm, e))
        try:
            hdr = ts.hdrFromFdno(fd)
        except rpm.error as e:
            raise exception.Error(
                "Cannot find/open srpm: %s. Error: %s" % (srpm, e))
        finally:
            os.close(fd)

        if not plainRpmOk and hdr[rpm.RPMTAG_SOURCEPACKAGE] != 1:
            raise exception.Error("File is not an srpm: %s." % srpm)

        yield hdr 
開發者ID:rpm-software-management,項目名稱:mock,代碼行數:28,代碼來源:util.py

示例8: newest_kernel_and_initrd

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import TransactionSet [as 別名]
def newest_kernel_and_initrd():
    ts = rpm.TransactionSet()
    p = max(ts.dbMatch('name', 'kernel'))
    k = [ x for x in p['filenames']
         if fnmatch.fnmatch(x, '/boot/vmlinuz-*') ][0]
    #The initrd is not owned by the kernel rpm but generated in the %post script   
    i = '/boot/initrd-%s.img' % k[len('/boot/vmlinuz-'):]
    return (k, i) 
開發者ID:ActiveState,項目名稱:code,代碼行數:10,代碼來源:recipe-491277.py

示例9: get_package_ver

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import TransactionSet [as 別名]
def get_package_ver(self, path, package):
        rpm.addMacro("_dbpath", path + '/var/lib/rpm')
        ts = rpm.TransactionSet()
        versions = list()

        try:
            mi = ts.dbMatch('name', package)
            for h in mi:
                version = "%s-%s.%s" % (h['VERSION'], h['RELEASE'], h['ARCH'])
                versions.append(version)
        except rpm.error:
            return []

        return versions 
開發者ID:dchirikov,項目名稱:luna,代碼行數:16,代碼來源:osimage.py

示例10: getCapsuleKeysFromTarget

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import TransactionSet [as 別名]
def getCapsuleKeysFromTarget(self):
        txnSet = rpm.TransactionSet(self.root)
        matchIter = txnSet.dbMatch()
        headersByKey = {}
        for rpmlibHeader in matchIter:
            nevra = rpmhelper.NEVRA.fromHeader(rpmlibHeader)
            if nevra.name.startswith('gpg-pubkey') and not nevra.arch:
                # Skip fake packages that RPM/yum uses to hold PGP keys
                continue
            digest = self._digest(rpmlibHeader)
            key = capsules.PartialTuple((nevra, digest))
            headersByKey[key] = rpmlibHeader
        return headersByKey 
開發者ID:sassoftware,項目名稱:conary,代碼行數:15,代碼來源:rpmcapsule.py

示例11: testTestSuiteRpmLockOverride

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import TransactionSet [as 別名]
def testTestSuiteRpmLockOverride(self):
        import rpm
        class simpleCallback:
            def __init__(self):
                self.fdnos = {}

            def callback(self, what, amount, total, mydata, wibble):
                if what == rpm.RPMCALLBACK_INST_OPEN_FILE:
                    hdr, path = mydata
                    fd = os.open(path, os.O_RDONLY)
                    nvr = '%s-%s-%s' % (hdr['name'],
                                        hdr['version'],
                                        hdr['release'])
                    self.fdnos[nvr] = fd
                    return fd

        def go(root):
            ts = rpm.TransactionSet(root)
            ts.setVSFlags(~(rpm.RPMVSF_NORSA|rpm.RPMVSF_NODSA))
            ts.initDB()
            rpmloc = resources.get_archive() + '/epoch-1.0-1.i386.rpm'
            fdno = os.open(rpmloc, os.O_RDONLY)
            hdr = ts.hdrFromFdno(fdno)
            os.close(fdno)
            ts.addInstall(hdr, (hdr, rpmloc), 'u')
            ts.check()
            ts.order()
            cb = simpleCallback()
            ts.run(cb.callback,'')
            ts.closeDB()
        d = tempfile.mkdtemp()
        os.chmod(d, 0777)
        try:
            go(d + '/root1')
            util.rmtree(d + '/root1')
            go(d + '/root2')
            self.assertTrue(os.path.exists(d+'/root2/normal'))
        finally:
            util.rmtree(d) 
開發者ID:sassoftware,項目名稱:conary,代碼行數:41,代碼來源:rpmtest.py


注:本文中的rpm.TransactionSet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。