当前位置: 首页>>代码示例>>Python>>正文


Python File.decompress方法代码示例

本文整理汇总了Python中pisi.file.File.decompress方法的典型用法代码示例。如果您正苦于以下问题:Python File.decompress方法的具体用法?Python File.decompress怎么用?Python File.decompress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pisi.file.File的用法示例。


在下文中一共展示了File.decompress方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testDecompress

# 需要导入模块: from pisi.file import File [as 别名]
# 或者: from pisi.file.File import decompress [as 别名]
 def testDecompress(self):
     localfile = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read)
     compress = File('repos/contrib-2007/pisi-index.xml', File.read)
     self.assert_(File.decompress(localfile,compress))
开发者ID:Pardus-Linux,项目名称:pisi,代码行数:6,代码来源:filetest.py

示例2: main

# 需要导入模块: from pisi.file import File [as 别名]
# 或者: from pisi.file.File import decompress [as 别名]
def main():
    global options

    # Parse options
    parser = OptionParser(usage="%prog [options]", version="%prog 1.0")

    parser.add_option("-N", "--no-color",
                      action="store_false", dest="color", default=True,
                      help=_("don't use colors"))
    parser.add_option("-p", "--packages",
                      action="store_true", dest="packages", default=False,
                      help=_("show package names"))
    parser.add_option("-l", "--long",
                      action="store_true", dest="long", default=False,
                      help=_("show details of advisories"))
    parser.add_option("-a", "--all",
                      action="store_false", dest="affected", default=True,
                      help=_("show all advisories"))
    parser.add_option("-F", "--no-fetch",
                      action="store_false", dest="fetch", default=True,
                      help=_("don't download PLSA index"))

    (options, args) = parser.parse_args()
    
    # Get locale
    lang = os.environ["LC_ALL"].split("_")[0]

    # Show package details in --long
    if options.long:
        options.packages = True

    # Create work directory
    if not os.access("/tmp/plsa", os.F_OK):
        os.mkdir("/tmp/plsa")

    # Init PISI API
    pisi.api.init(database=True, comar=False, write=False)

    # Get installed packages
    installed_packages = {}
    for package in ctx.installdb.list_installed():
        # Release comparison seems enough
        installed_packages[package] = int(ctx.installdb.get_version(package)[1])

    # List of orphaned packages
    orphaned = []

    # Get list of reporsitories
    plsas = {}
    for repo in ctx.repodb.list():
        uri = ctx.repodb.get_repo(repo).indexuri.get_uri()
        plsafile = "%s/plsa-index.xml.bz2" % uri[0:uri.rfind("/")]
        tmpfile = "/tmp/plsa/%s.xml" % repo

        if options.fetch:
            print _("Downloading PLSA database of %s") % repo
            try:
                fetch_url(plsafile, "/tmp/plsa", progress=ctx.ui.Progress)
            except FetchError, e:
                print _("Unable to download %s: %s") % (plsafile, e)
                continue

            print _("Checking file integrity of %s") % repo
            try:
                fetch_url("%s.sha1sum" % plsafile, "/tmp/plsa")
            except FetchError, e:
                print _("Unable to download checksum of %s") % repo
                continue

            orig_sha1sum = file("%s.sha1sum" % plsafile).readlines()[0].split()[0]
            if sha1_file(plsafile) != orig_sha1sum:
                print _("File integrity of %s compromised.") % plsafile
                continue

            print _("Unpacking PLSA database of %s") % repo
            try:
                File.decompress("/tmp/plsa/plsa-index.xml.bz2", File.bz2)
            except:
                print _("Unable to decompress %s") % plsafile
                continue
            
            os.rename("/tmp/plsa/plsa-index.xml", tmpfile)
            os.unlink("/tmp/plsa/plsa-index.xml.bz2")
            plsas[repo] = tmpfile
开发者ID:Tayyib,项目名称:uludag,代码行数:86,代码来源:plsa-check.py


注:本文中的pisi.file.File.decompress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。