免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1287 | 回复: 0
打印 上一主题 下一主题

Yum Code Snippets [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-09-10 22:07 |只看该作者 |倒序浏览

               
               
                [ray@localhost ~]$ python
Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
[GCC 4.3.2 20080917 (Red Hat 4.3.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import yum
>>> md = yum.repoMDObject.RepoMD('fedora', '/var/cache/yum/fedora/repomd.xml')
>>> md.repoid
'fedora'
>>> md.tags
{'content': set([]), 'distro': {}}
>>> md.fileTypes()
['group', 'filelists', 'group_gz', 'primary', 'primary_db', 'other_db', 'other', 'filelists_db']
>>> md.dump()
file timestamp: 1227132182
file length   : 2849
file checksum : md5/27e5eaef0355bdfd655ab62a94a9c9a5
file checksum : sha1/263de5c3f3664269fa33b7218ae1c58a46b9f8ea
file checksum : sha256/5bc05ae10476b8cb8b83745c83f223574f1f95a7cb5113b1160814d867fd72ad
revision: 1227126769
---- Data ----
  datatype: filelists
    location     : None repodata/34d42ab6240fbd8d5fd464fafea49c09f7acc93a-filelists.xml.gz
    timestamp    : 1227131096
    size         : None
    open size    : None
    checksum     : sha - 34d42ab6240fbd8d5fd464fafea49c09f7acc93a
    open checksum: sha - 835abf1dd955c86ce440c240579d4a2a13ae6c4d
    dbversion    : None
  datatype: filelists_db
    location     : None repodata/848f002818e918fb0dc1e258342c63c3587683bf-filelists.sqlite.bz2
    timestamp    : 1227131827
    size         : None
    open size    : None
    checksum     : sha - 848f002818e918fb0dc1e258342c63c3587683bf
    open checksum: sha - 7f4fe477864248d6d9cd4b96686a01b96ba5f6e6
    dbversion    : 10
  datatype: group
    location     : None repodata/99f2086106ff36f48ed144e90f8c8aebc7142670-comps-rawhide.xml
    timestamp    : 1227132182
    size         : None
    open size    : None
    checksum     : sha - 99f2086106ff36f48ed144e90f8c8aebc7142670
    open checksum: None - None
    dbversion    : None
  datatype: group_gz
    location     : None repodata/ebbef2b450b2c5de3600a1cb49def759be1f0fca-comps-rawhide.xml.gz
    timestamp    : 1227132182
    size         : None
    open size    : None
    checksum     : sha - ebbef2b450b2c5de3600a1cb49def759be1f0fca
    open checksum: sha - 99f2086106ff36f48ed144e90f8c8aebc7142670
    dbversion    : None
  datatype: other
    location     : None repodata/eb2d0a3e0d00a8c46468fc5ebabc417222c2821f-other.xml.gz
    timestamp    : 1227131096
    size         : None
    open size    : None
    checksum     : sha - eb2d0a3e0d00a8c46468fc5ebabc417222c2821f
    open checksum: sha - 868fc5462d8bdf088ded7ccbff27bbfb6e535a77
    dbversion    : None
  datatype: other_db
    location     : None repodata/3a3a9ddcaa815e9bd9f36d1d43ceca44fcb5e0bb-other.sqlite.bz2
    timestamp    : 1227131156
    size         : None
    open size    : None
    checksum     : sha - 3a3a9ddcaa815e9bd9f36d1d43ceca44fcb5e0bb
    open checksum: sha - 7f24728482a6bbb98801a51e14e6a15fa8ee8fbe
    dbversion    : 10
  datatype: primary
    location     : None repodata/beeea88d162e76993c25b9dd8139868274ee7fa1-primary.xml.gz
    timestamp    : 1227131096
    size         : None
    open size    : None
    checksum     : sha - beeea88d162e76993c25b9dd8139868274ee7fa1
    open checksum: sha - 95b0f369429584d337f84bba81e56f00afccc9c6
    dbversion    : None
  datatype: primary_db
    location     : None repodata/04da721e41b80b2a003de83f73387a6d7d30833f-primary.sqlite.bz2
    timestamp    : 1227132181
    size         : None
    open size    : None
    checksum     : sha - 04da721e41b80b2a003de83f73387a6d7d30833f
    open checksum: sha - fe268c32ce7a1ac643c71af17da5299b164948f4
    dbversion    : 10
>>> md.fileTypes()
['group', 'filelists', 'group_gz', 'primary', 'primary_db', 'other_db', 'other', 'filelists_db']
>>> md.getData('primary_db')
yum.repoMDObject.RepoData instance at 0x9fe91ec>
>>> md.getData('primary_db').type
'primary_db'
>>> md.getData('primary_db').location
(None, 'repodata/04da721e41b80b2a003de83f73387a6d7d30833f-primary.sqlite.bz2')
>>> md.fileTypes()
['group', 'filelists', 'group_gz', 'primary', 'primary_db', 'other_db', 'other', 'filelists_db']
>>> yb = yum.YumBase()
>>> yb.repos
yum.repos.RepoStorage instance at 0x9fc0fcc>
>>> yb.repos.findRepos('update')
[]
>>> yb.repos.findRepos('updates')
[yum.yumRepo.YumRepository object at 0xa0021cc>]
>>> yb.repos.findRepos('updates').id
Traceback (most recent call last):
  File "", line 1, in module>
AttributeError: 'list' object has no attribute 'id'
>>> yb.repos.findRepos('updates')[0]
yum.yumRepo.YumRepository object at 0xa0021cc>
>>> yb.repos.findRepos('updates')[0].id
'updates'
>>> yb.repos.findRepos('updates')[0].urls
['http://ftp.riken.jp/Linux/fedora/updates/10/i386/', 'http://ftp.jaist.ac.jp/pub/Linux/Fedora/updates/10/i386/', 'http://ftp.linux.org.tr/fedora/updates/10/i386/', 'http://mirror.yandex.ru/fedora/linux/updates/10/i386/', 'http://ftp.rhd.ru/pub/fedora/linux/updates/10/i386/', 'http://ftp.yz.yamagata-u.ac.jp/pub/linux/fedora/linux/updates/10/i386/', 'http://ftp.kddilabs.jp/Linux/packages/fedora/updates/10/i386/', 'http://mirror.nus.edu.sg/fedora/updates/10/i386/', 'http://mirror.corbina.net/pub/Linux/fedora/updates/10/i386/', 'http://mirrors.cytanet.com.cy/linux/fedora/linux/updates/10/i386/', 'ftp://ftp.num.edu.mn/updates/10/i386/']
>>> yb.repos.findRepos('updates')[0].cachedir
'/var/cache/yum/updates'
>>> yb.repos.findRepos('updates')[0].gpgdir
'/var/cache/yum/updates/gpgdir'
>>> yb.repos.findRepos('updates')[0].pkgdir
'/var/cache/yum/updates/packages'
>>> yb.repos.findRepos('updates')[0].cachedir
'/var/cache/yum/updates'
>>> yb.repos.findRepos('updates')[0]
yum.yumRepo.YumRepository object at 0xa0021cc>
>>> print yb.repos.findRepos('updates')[0].dump()
[updates]
bandwidth = 0
cachedir = /var/cache/yum/updates
enabled = True
enablegroups = True
exclude = []
gpgcheck = True
gpgkey = ['file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-i386']
hdrdir = /var/cache/yum/updates/headers
includepkgs = []
keepalive = True
metalink = None
mirrorlist = http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f10&arch=i386
name = Fedora 10 - i386 - Updates
pkgdir = /var/cache/yum/updates/packages
proxy = None
proxy_password = None
proxy_username = None
repo_gpgcheck = False
retries = 10
throttle = 0
timeout = 30.0
baseurl = http://ftp.riken.jp/Linux/fedora/updates/10/i386/
http://ftp.jaist.ac.jp/pub/Linux/Fedora/updates/10/i386/
http://ftp.linux.org.tr/fedora/updates/10/i386/
http://mirror.yandex.ru/fedora/linux/updates/10/i386/
http://ftp.rhd.ru/pub/fedora/linux/updates/10/i386/
http://ftp.yz.yamagata-u.ac.jp/pub/linux/fedora/linux/updates/10/i386/
http://ftp.kddilabs.jp/Linux/packages/fedora/updates/10/i386/
http://mirror.nus.edu.sg/fedora/updates/10/i386/
http://mirror.corbina.net/pub/Linux/fedora/updates/10/i386/
http://mirrors.cytanet.com.cy/linux/fedora/linux/updates/10/i386/
ftp://ftp.num.edu.mn/updates/10/i386/
>>> print yb.repos.findRepos('updates')[0].baseurl
['http://ftp.riken.jp/Linux/fedora/updates/10/i386/', 'http://ftp.jaist.ac.jp/pub/Linux/Fedora/updates/10/i386/', 'http://ftp.linux.org.tr/fedora/updates/10/i386/', 'http://mirror.yandex.ru/fedora/linux/updates/10/i386/', 'http://ftp.rhd.ru/pub/fedora/linux/updates/10/i386/', 'http://ftp.yz.yamagata-u.ac.jp/pub/linux/fedora/linux/updates/10/i386/', 'http://ftp.kddilabs.jp/Linux/packages/fedora/updates/10/i386/', 'http://mirror.nus.edu.sg/fedora/updates/10/i386/', 'http://mirror.corbina.net/pub/Linux/fedora/updates/10/i386/', 'http://mirrors.cytanet.com.cy/linux/fedora/linux/updates/10/i386/', 'ftp://ftp.num.edu.mn/updates/10/i386/']
>>> print yb.repos.findRepos('updates')[0].proxy
None
>>> print yb.repos.findRepos('updates')[0].metadata_cookie
/var/cache/yum/updates/cachecookie
>>> yb.repos.findRepos('updates')[0].repoMDFile
'repodata/repomd.xml'
>>> yb.repos.findRepos('updates')[0].repofile
'///etc/yum.repos.d/fedora-updates.repo'


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/68938/showart_2049961.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP