Exemple #1
0
def clearCache(path=None, flavors=None, inUserDir=False, verbose=0):
    """
    remove the product cache for given stacks/databases and flavors
    @param path     the stacks to clear caches for.  This can be given either
                        as a python list or a colon-delimited string.  If 
                        None (default), EUPS_PATH will be used.
    @param flavors  the flavors to clear the cache for.  This can either 
                        be a python list or space-delimited string.  If None,
                        clear caches for all flavors.
    @param inUserDir  if True (default), it will be assumed that it is the
                        cache in the user's data directory that should be
                        cleared.
    @params verbose   chattiness
    """
    if path is None:
        path = os.environ["EUPS_PATH"]
    if isinstance(path, str):
        path = path.split(":")

    userDataDir = utils.defaultUserDataDir()
    path.append(userDataDir)

    if not inUserDir:
        userDataDir = None  # Clear the system cache, not the one in userDataDir

    if isinstance(flavors, str):
        flavors = flavors.split()

    for p in path:
        dbpath = os.path.join(p, Eups.ups_db)

        persistDir = dbpath
        if p != userDataDir:  # no need to use a surrogate directory as we can write userDataDir
            persistDir = utils.userStackCacheFor(p, userDataDir)

        if not os.path.exists(persistDir):
            print >> utils.stdwarn, "No cache yet for %s; skipping..." % p
            continue

        flavs = flavors
        if flavs is None:
            flavs = ProductStack.findCachedFlavors(persistDir)
        if not flavs:
            continue

        ProductStack.fromCache(dbpath,
                               flavs,
                               persistDir=persistDir,
                               autosave=False).clearCache(verbose=verbose)
Exemple #2
0
def clearCache(path=None, flavors=None, inUserDir=False, verbose=0):
    """
    remove the product cache for given stacks/databases and flavors
    @param path     the stacks to clear caches for.  This can be given either
                        as a python list or a colon-delimited string.  If 
                        None (default), EUPS_PATH will be used.
    @param flavors  the flavors to clear the cache for.  This can either 
                        be a python list or space-delimited string.  If None,
                        clear caches for all flavors.
    @param inUserDir  if True (default), it will be assumed that it is the
                        cache in the user's data directory that should be
                        cleared.
    @params verbose   chattiness
    """
    if path is None:
        path = os.environ["EUPS_PATH"]
    if isinstance(path, str):
        path = path.split(":")

    userDataDir = utils.defaultUserDataDir()
    path.append(userDataDir)
    
    if not inUserDir:
        userDataDir = None              # Clear the system cache, not the one in userDataDir

    if isinstance(flavors, str):
        flavors = flavors.split()

    for p in path:
        dbpath = os.path.join(p, Eups.ups_db)

        persistDir = dbpath
        if p != userDataDir:            # no need to use a surrogate directory as we can write userDataDir
            persistDir = utils.userStackCacheFor(p, userDataDir)

        if not os.path.exists(persistDir):
            print >> utils.stdwarn, "No cache yet for %s; skipping..." % p
            continue

        flavs = flavors
        if flavs is None:
            flavs = ProductStack.findCachedFlavors(persistDir)
        if not flavs:
            continue

        ProductStack.fromCache(dbpath, flavs, persistDir=persistDir,
                               autosave=False).clearCache(verbose=verbose)
Exemple #3
0
def listCache(path=None, verbose=0, flavor=None):
    if path is None:
        path = os.environ["EUPS_PATH"]
    if isinstance(path, str):
        path = path.split(":")

    if not flavor:
        flavor = utils.determineFlavor()

    userDataDir = utils.defaultUserDataDir()
    if not userDataDir in path:
        path.append(userDataDir)

    for p in path:
        dbpath = os.path.join(p, Eups.ups_db)
        cache = ProductStack.fromCache(dbpath,
                                       flavor,
                                       updateCache=False,
                                       autosave=False)

        productNames = cache.getProductNames()
        productNames.sort()

        colon = ""
        if verbose:
            colon = ":"

        print "%-30s (%-3d products) [cache verison %s]%s" % \
            (p, len(productNames), cacheVersion, colon)

        if not verbose:
            continue

        for productName in productNames:
            versionNames = cache.getVersions(productName)
            versionNames.sort(hooks.version_cmp)

            print "  %-20s %s" % (productName, " ".join(versionNames))
Exemple #4
0
def listCache(path=None, verbose=0, flavor=None):
    if path is None:
        path = os.environ["EUPS_PATH"]
    if isinstance(path, str):
        path = path.split(":")

    if not flavor:
        flavor = utils.determineFlavor()

    userDataDir = utils.defaultUserDataDir()
    if not userDataDir in path:
        path.append(userDataDir)
        
    for p in path:
        dbpath = os.path.join(p, Eups.ups_db)
        cache = ProductStack.fromCache(dbpath, flavor, updateCache=False, 
                                       autosave=False)

        productNames = cache.getProductNames()
        productNames.sort()

        colon = ""
        if verbose:
            colon = ":"

        print "%-30s (%-3d products) [cache verison %s]%s" % \
            (p, len(productNames), cacheVersion, colon)

        if not verbose:
            continue

        for productName in productNames:
            versionNames = cache.getVersions(productName)
            versionNames.sort(hooks.version_cmp)

            print "  %-20s %s" % (productName, " ".join(versionNames))