예제 #1
0
파일: Database.py 프로젝트: jhoblitt/eups
    def undeclare(self, product):
        """
        undeclare the given Product.  Only the name, version, and flavor 
        will be paid attention to.  False is returned if the product was 
        not found in the database.

        @param product : the Product instance to undeclare.
        @return bool : False if nothing was undeclared
        @throws UnderSpecifiedProduct if the name, version, and flavor are
                   not all set
        """
        if not isinstance(product, Product):
            raise RuntimeError("Database.declare(): argument not a Product: " +
                               product)
        if not product.name or not product.version or not product.flavor:
            raise UnderSpecifiedProduct(
                msg="Product not fully specified: %s %s %s" 
                    % (str(product.name), str(product.version),
                       str(product.flavor))
            )

        pdir = self._productDir(product.name)
        vfile = self._versionFileInDir(pdir, product.version)
        if not os.path.exists(vfile):
            return False

        versionFile = VersionFile(vfile)
        if versionFile.hasFlavor(product.flavor):
            # unassign tags associated with this product
            tags = self.findTags(product.name, product.version, product.flavor)
            for tag in tags:
                self.unassignTag(tag, product.name, product.flavor)

        changed = versionFile.removeFlavor(product.flavor)
        if changed:  versionFile.write()

        # do a little clean up: if we got rid of the version file, try 
        # deleting the directory
        if not os.path.exists(vfile):
            try:
                os.rmdir(pdir)
            except:
                pass

        return changed
예제 #2
0
    def undeclare(self, product):
        """
        undeclare the given Product.  Only the name, version, and flavor 
        will be paid attention to.  False is returned if the product was 
        not found in the database.

        @param product : the Product instance to undeclare.
        @return bool : False if nothing was undeclared
        @throws UnderSpecifiedProduct if the name, version, and flavor are
                   not all set
        """
        if not isinstance(product, Product):
            raise RuntimeError("Database.declare(): argument not a Product: " +
                               product)
        if not product.name or not product.version or not product.flavor:
            raise UnderSpecifiedProduct(
                msg="Product not fully specified: %s %s %s" %
                (str(product.name), str(product.version), str(product.flavor)))

        pdir = self._productDir(product.name)
        vfile = self._versionFileInDir(pdir, product.version)
        if not os.path.exists(vfile):
            return False

        versionFile = VersionFile(vfile)
        if versionFile.hasFlavor(product.flavor):
            # unassign tags associated with this product
            tags = self.findTags(product.name, product.version, product.flavor)
            for tag in tags:
                self.unassignTag(tag, product.name, product.flavor)

        changed = versionFile.removeFlavor(product.flavor)
        if changed: versionFile.write()

        # do a little clean up: if we got rid of the version file, try
        # deleting the directory
        if not os.path.exists(vfile):
            try:
                os.rmdir(pdir)
            except:
                pass

        return changed