コード例 #1
0
    def cacheIsUpToDate(self, flavor, cacheDir=None):
        """
        return True if there is a cache file on disk with product information
        for a given flavor which is newer than the information in the
        product database.  False is returned if the file does not exist
        or otherwise appears out-of-date.

        Note that this is different from cacheIsInSync()
        """
        if not cacheDir:
            cacheDir = self.dbpath
        cache = self._persistPath(flavor, cacheDir)
        if not os.path.exists(cache):
            return False

        # get the modification time of the cache file
        cache_mtime = os.stat(cache).st_mtime

        # check for user tag updates
        if cacheDir != self.dbpath and \
           Database(cacheDir).isNewerThan(cache_mtime):
            return False

        # this is slightly inaccurate: if data for any flavor in the database
        # is newer than this time, this isNewerThan() returns True
        return not Database(self.dbpath).isNewerThan(cache_mtime)
コード例 #2
0
ファイル: ProductStack.py プロジェクト: PaulPrice/eups
    def _tryCache(self, dbpath, cacheDir, flavors, verbose=0):
        if not cacheDir or not os.path.exists(cacheDir):
            return False

        cacheOkay = True
        for flav in flavors:
            if not self.cacheIsUpToDate(flav, cacheDir):
                cacheOkay = False
                if verbose > 1:
                    print >> sys.stderr, \
                          "Regenerating missing or out-of-date cache for %s in %s" % (flav, dbpath)
                break

        if cacheOkay:
            self.reload(flavors, cacheDir, verbose=verbose)

            # do a final consistency check; do we have the same products
            dbnames = Database(dbpath).findProductNames()
            dbnames.sort()
            dbnames = " ".join(dbnames)

            cachenames = self.getProductNames()
            cachenames.sort()
            cachenames = " ".join(cachenames)

            if dbnames != cachenames:
                cacheOkay = False
                self.lookup = {}  # forget loaded data
                if verbose:
                    print >> sys.stderr, \
                     "Regenerating out-of-date cache for %s in %s" % (flav, dbpath)

        return cacheOkay
コード例 #3
0
ファイル: testDb.py プロジェクト: airnandez/eups
    def setUp(self):
        self.dbpath = os.path.join(testEupsStack, "ups_db")
        self.userdb = os.path.join(testEupsStack, "user_ups_db")
        if not os.path.exists(self.userdb):
            os.makedirs(self.userdb)

        self.db = Database(self.dbpath, self.userdb)

        self.pycur = os.path.join(self.dbpath, "python", "current.chain")
        if os.path.isfile(self.pycur + ".bak"):
            os.rename(self.pycur + ".bak", self.pycur)
コード例 #4
0
    def _loadUserTags(self, userTagDir=None):
        if not userTagDir:
            userTagDir = self.persistDir
        if not userTagDir or not os.path.exists(userTagDir):
            return

        db = Database(self.dbpath, userTagDir)
        prodnames = db.findProductNames()
        for pname in prodnames:
            for tag, version, flavor in db.getTagAssignments(pname,
                                                             glob=False):
                self.assignTag(tag, pname, version, flavor)
コード例 #5
0
    def refreshFromDatabase(self, userTagDir=None):
        """
        load product information directly from the database files on disk,
        overwriting any previous information.  If userTagDir is provided,
        user tag assignments will be explicitly loaded into the stack
        (otherwise, the stack may not have user tags in it).
        """
        db = Database(self.dbpath, userTagDir)

        # forget!
        self.lookup = {}

        for prodname in db.findProductNames():
            for product in db.findProducts(prodname):
                self.addProduct(product)