def getUserDefinedTags(user): """Return all the tags that a given user defines N.b. we do this by executing their startup file in a new context """ startupFile = os.path.join(utils.defaultUserDataDir(user), hooks.config.Eups.startupFileName) myGlobals, myLocals = {}, {} class Foo(list): # a place to put attributes def __getattr__(self, attr): return self myGlobals["hooks"] = Foo() myGlobals["hooks"].config = Foo() myGlobals["hooks"].config.distrib = dict(builder = dict(variables = {})) myEups = Foo() myGlobals["hooks"].config.Eups = myEups myGlobals["eups"] = Foo() # # Define lists that might be appended to # for c in [c for c in dir(globals()["hooks"].config.Eups) if not re.search("^_", c)]: setattr(myEups, c, []) try: execfile(startupFile, myGlobals, myLocals) except Exception, e: print >> utils.stderr, "Error processing %s's startup file: %s" % (user, e) return []
def getUserDefinedTags(user): """Return all the tags that a given user defines N.b. we do this by executing their startup file in a new context """ startupFile = os.path.join(utils.defaultUserDataDir(user), hooks.config.Eups.startupFileName) myGlobals, myLocals = {}, {} class Foo(list): # a place to put attributes def __getattr__(self, attr): return self myGlobals["hooks"] = Foo() myGlobals["hooks"].config = Foo() myGlobals["hooks"].config.distrib = dict(builder=dict(variables={})) myEups = Foo() myGlobals["hooks"].config.Eups = myEups myGlobals["eups"] = Foo() # # Define lists that might be appended to # for c in [ c for c in dir(globals()["hooks"].config.Eups) if not re.search("^_", c) ]: setattr(myEups, c, []) try: execfile(startupFile, myGlobals, myLocals) except Exception, e: print >> utils.stderr, "Error processing %s's startup file: %s" % ( user, e) return []
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)
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))