예제 #1
0
파일: logger.py 프로젝트: tensor5/conary
 def _waitedTooLong(i, stage):
     if i > 10000:
         # 100 seconds is too long to wait for a pty; something's wrong
         syncFile.seek(0, 2)
         length = syncFile.tell()
         raise ConaryError(
             'Log file synchronization %s failure with length %d' %
             (stage, length))
예제 #2
0
def displayTroves(
        cfg,
        troveSpecs=[],
        pathList=[],
        whatProvidesList=[],
        # query options
        versionFilter=VERSION_FILTER_LATEST,
        flavorFilter=FLAVOR_FILTER_BEST,
        useAffinity=False,
        # trove options
        info=False,
        digSigs=False,
        showDeps=False,
        showBuildReqs=False,
        showBuildLog=False,
        filesToShow=[],
        # file options
        ls=False,
        lsl=False,
        ids=False,
        sha1s=False,
        tags=False,
        fileDeps=False,
        fileVersions=False,
        fileFlavors=False,
        capsules=False,
        # collection options
        showTroves=False,
        recurse=None,
        showAllTroves=False,
        weakRefs=False,
        showTroveFlags=False,
        alwaysDisplayHeaders=False,
        troveTypes=trovesource.TROVE_QUERY_PRESENT):
    """
       Displays information about troves found in repositories

       @param cfg: conary config
       @type cfg: conarycfg.ConaryConfiguration
       @param troveSpecs: troves to search for
       @type troveSpecs: list of troveSpecs (n[=v][[f]])
       @param versionFilter: add documentation here.  Check man page for
       general description
       @type versionFilter: bool
       @param flavorFilter: add documentation here.  Check man page for
       general description.
       @type flavorFilter: bool
       @param useAffinity: If False, disallow affinity database use.
       @type useAffinity: bool
       @param info: If true, display general information about the trove
       @type info: bool
       @param digSigs: If true, display digital signatures for a trove.
       @type digSigs: bool
       @param showBuildReqs: If true, display the versions and flavors of the
       build requirements that were used to build the given troves
       @type showBuildReqs: bool
       @param showDeps: If true, display provides and requires information
       for the trove.
       @type showDeps: bool
       @param ls: If true, list files in the trove
       @type ls: bool
       @param lsl: If true, list files in the trove + ls -l information
       @type lsl: bool
       @param ids: If true, list pathIds for files in the troves
       @type ids: bool
       @param sha1s: If true, list sha1s for files in the troves
       @type sha1s: bool
       @param tags: If true, list tags for files in the troves
       @type tags: bool
       @param fileDeps: If true, print file-level dependencies
       @type fileDeps: bool
       @param fileVersions: If true, print fileversions
       @type fileVersions: bool
       @param showTroves: If true, display byDefault True child troves of this
       trove
       @type showTroves: bool
       @param recurse: display child troves of this trove, recursively
       @type recurse: bool
       @param showAllTroves: If true, display all byDefault False child troves
       of this trove
       @type showAllTroves: bool
       @param weakRefs: display both weak and strong references of this trove.
       @type weakRefs: bool
       @param showTroveFlags: display [<flags>] list with information about
       the given troves.
       @type showTroveFlags: bool
       @param alwaysDisplayHeaders: If true, display headers even when listing
       files.
       @type alwaysDisplayHeaders: bool
       @rtype: None
    """

    if showBuildLog and len(troveSpecs) > 1:
        raise ConaryError(
            'Error: can not show build log for several packages. Please specify one'
        )
    if filesToShow and len(troveSpecs) > 1:
        raise ConaryError(
            'Error: can not show files log for several packages. Please specify one'
        )

    client = conaryclient.ConaryClient(cfg)
    repos = client.getRepos()

    if useAffinity:
        affinityDb = client.db
    else:
        affinityDb = None

    whatProvidesList = [deps.parseDep(x) for x in whatProvidesList]

    troveTups = getTrovesToDisplay(repos,
                                   troveSpecs,
                                   pathList,
                                   whatProvidesList,
                                   versionFilter,
                                   flavorFilter,
                                   cfg.installLabelPath,
                                   cfg.flavor,
                                   affinityDb,
                                   troveTypes=troveTypes)

    if (filesToShow or showBuildLog) and len(troveTups) > 1:
        raise ConaryError('Error: %s is ambigious. Please specify one of: \n%s' % \
                    (troveSpecs[0],
                    "\n".join([x[0]+"="+str(x[1].trailingLabel()) for x in troveTups]) ))

    dcfg = display.DisplayConfig(repos, affinityDb)

    dcfg.setTroveDisplay(deps=showDeps,
                         info=info,
                         showBuildReqs=showBuildReqs,
                         showBuildLog=showBuildLog,
                         filesToShow=filesToShow,
                         digSigs=digSigs,
                         fullVersions=cfg.fullVersions,
                         showLabels=cfg.showLabels,
                         fullFlavors=cfg.fullFlavors,
                         showComponents=cfg.showComponents,
                         baseFlavors=cfg.flavor)

    dcfg.setFileDisplay(ls=ls,
                        lsl=lsl,
                        ids=ids,
                        sha1s=sha1s,
                        tags=tags,
                        fileDeps=fileDeps,
                        fileVersions=fileVersions,
                        fileFlavors=fileFlavors,
                        capsules=capsules)

    recurseOne = showTroves or showAllTroves or weakRefs
    if recurse is None and not recurseOne and troveSpecs:
        # if we didn't explicitly set recurse and we're not recursing one
        # level explicitly and we specified troves (so everything won't
        # show up at the top level anyway), guess at whether to recurse
        recurse = True in (ls, lsl, ids, sha1s, tags, showDeps, fileDeps,
                           fileVersions, fileFlavors)
    displayHeaders = alwaysDisplayHeaders or showTroveFlags

    dcfg.setChildDisplay(recurseAll=recurse,
                         recurseOne=recurseOne,
                         showNotByDefault=showAllTroves or showBuildLog,
                         showWeakRefs=weakRefs,
                         showTroveFlags=showTroveFlags,
                         displayHeaders=displayHeaders,
                         checkExists=False)

    if troveSpecs:
        dcfg.setPrimaryTroves(set(troveTups))

    formatter = display.TroveFormatter(dcfg)

    display.displayTroves(dcfg, formatter, troveTups)