Esempio n. 1
0
    def __init__(self, server = None, repoName = None, url = None):
        """
        Initialize an InsufficientPermission exception object.  This exception
        is raised when privileged methods are called without the correct
        authorization token.

        @param server: Name of the host where access is denied.
        @type server: string

        @param repoName: Name of the repository where access is denied.
        @type repoName: string

        @param url: URL of the call where access is denied.
        @type url: string
        """
        self.server = self.repoName = self.url = None
        serverMsg = repoMsg = urlMsg = ""
        if server:
            self.server = server
            serverMsg = ("server %s" % server)
        if repoName:
            self.repoName = repoName
            repoMsg = ("repository %s" % repoName)
        if url:
            self.url = url
            urlMsg = ("via %s" % (url,))
        if server or repoName or url:
            msg = "Insufficient permission to access %s %s %s" %(
                repoMsg, serverMsg, urlMsg)
        else:
            msg = "Insufficient permission"
        ConaryError.__init__(self, msg)
Esempio n. 2
0
    def __init__(self, right = None, wrong = None):
        if issubclass(right.__class__, list):
            right = list(right)

        self.right = right
        self.wrong = wrong
        if right and wrong:
            detail = ''
            if isinstance(right, list):
                # turn multiple server names into something more readable
                if len(right) > 1:
                    right = ', '.join('"%s"' %x for x in right)
                    right = 'one of ' + right
                else:
                    right = '"%s"' %right[0]
            else:
                right = '"%s"' %right
            msg = ('Repository name mismatch.  The correct repository name '
                   'is %s, but it was accessed as "%s".  Check for '
                   'incorrect repositoryMap configuration entries.'
                   % (right, wrong))
        else:
            msg = ('Repository name mismatch.  Check for incorrect '
                   'repositoryMap entries.')
        ConaryError.__init__(self, msg)
Esempio n. 3
0
    def __init__(self, server=None, repoName=None, url=None):
        """
        Initialize an InsufficientPermission exception object.  This exception
        is raised when privileged methods are called without the correct
        authorization token.

        @param server: Name of the host where access is denied.
        @type server: string

        @param repoName: Name of the repository where access is denied.
        @type repoName: string

        @param url: URL of the call where access is denied.
        @type url: string
        """
        self.server = self.repoName = self.url = None
        serverMsg = repoMsg = urlMsg = ""
        if server:
            self.server = server
            serverMsg = ("server %s" % server)
        if repoName:
            self.repoName = repoName
            repoMsg = ("repository %s" % repoName)
        if url:
            self.url = url
            urlMsg = ("via %s" % (url, ))
        if server or repoName or url:
            msg = "Insufficient permission to access %s %s %s" % (
                repoMsg, serverMsg, urlMsg)
        else:
            msg = "Insufficient permission"
        ConaryError.__init__(self, msg)
Esempio n. 4
0
    def __init__(self, right=None, wrong=None):
        if issubclass(right.__class__, list):
            right = list(right)

        self.right = right
        self.wrong = wrong
        if right and wrong:
            detail = ''
            if isinstance(right, list):
                # turn multiple server names into something more readable
                if len(right) > 1:
                    right = ', '.join('"%s"' % x for x in right)
                    right = 'one of ' + right
                else:
                    right = '"%s"' % right[0]
            else:
                right = '"%s"' % right
            msg = ('Repository name mismatch.  The correct repository name '
                   'is %s, but it was accessed as "%s".  Check for '
                   'incorrect repositoryMap configuration entries.' %
                   (right, wrong))
        else:
            msg = ('Repository name mismatch.  Check for incorrect '
                   'repositoryMap entries.')
        ConaryError.__init__(self, msg)
Esempio n. 5
0
 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))
Esempio n. 6
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)