Example #1
0
    def makeProduct(self, flavor, eupsPathDir=None, dbpath=None):
        """
        create a Product instance for the given flavor.  If the product has 
        not been declared for the flavor, a  ProductNotFound exception is 
        raised.

        @param flavor      : the desired flavor for the Product.  
        @param eupsPathDir : the product stack path to assume that product is 
                             installed under.  If the product install directory
                             is a relative path (product.dir), this eupsPathDir 
                             will be prepended in the output.  If None, no 
                             alterations of the product install directory will 
                             be done.
        @param dbpath      : the product database directory to store into 
                             the output product.db attribute.  If None, it will 
                             default to eupsPathDir/ups_db; if eupsPathDir is 
                             None, the product.db field will not be set.
        @return Product : a Product instance representing the product data
        """
        if flavor not in self.info:
            raise ProductNotFound(self.name, self.version, flavor)

        if eupsPathDir and not dbpath:
            dbpath = os.path.join(eupsPathDir, "ups_db")

        info = self.info[flavor]
        out = Product(self.name, self.version, flavor, 
                      info.get("productDir"), info.get("table_file"), 
                      db=dbpath, ups_dir=info.get("ups_dir"))
        out.resolvePaths()

        return out
Example #2
0
    def makeProduct(self, flavor, eupsPathDir=None, dbpath=None):
        """
        create a Product instance for the given flavor.  If the product has
        not been declared for the flavor, a  ProductNotFound exception is
        raised.

        @param flavor      : the desired flavor for the Product.
        @param eupsPathDir : the product stack path to assume that product is
                             installed under.  If the product install directory
                             is a relative path (product.dir), this eupsPathDir
                             will be prepended in the output.  If None, no
                             alterations of the product install directory will
                             be done.
        @param dbpath      : the product database directory to store into
                             the output product.db attribute.  If None, it will
                             default to eupsPathDir/ups_db; if eupsPathDir is
                             None, the product.db field will not be set.
        @return Product : a Product instance representing the product data
        """
        if flavor not in self.info:
            raise ProductNotFound(self.name, self.version, flavor)

        if eupsPathDir and not dbpath:
            dbpath = os.path.join(eupsPathDir, "ups_db")

        info = self.info[flavor]
        out = Product(self.name, self.version, flavor,
                      info.get("productDir"), info.get("table_file"),
                      db=dbpath, ups_dir=info.get("ups_dir"))
        out.resolvePaths()

        return out
Example #3
0
    def testProd1(self):
        pname = "newprod"
        pver = "2.0"
        pdir = os.path.join(self.eupsPathDir,"Linux",pname,pver)
        prod = Product("newprod", "2.0", "Linux", pdir, db=self.dbpath)

        self.assertEqual(prod.dir, pdir)
        self.assertEqual(prod.db, self.dbpath)
        self.assert_(prod.ups_dir is None)
        self.assert_(prod.tablefile is None)
        self.assertEqual(prod.tableFileName(),
                          os.path.join(pdir,"ups",pname+".table"))

        # test cloning (we'll use this later)
        clone = prod.clone()
        self.assertEqual(clone.dir, pdir)
        self.assertEqual(clone.db, self.dbpath)
        self.assert_(clone.ups_dir is None)
        self.assert_(clone.tablefile is None)
        self.assertEqual(clone.tableFileName(),
                          os.path.join(pdir,"ups",pname+".table"))

        # turn to absolute paths
        prod.resolvePaths()
        self.assertEqual(prod.dir, pdir)
        self.assertEqual(prod.db, self.dbpath)
        self.assertEqual(prod.tablefile,
                          os.path.join(pdir,"ups",pname+".table"))
        self.assertEqual(prod.ups_dir, os.path.join(pdir,"ups"))
        self.assertEqual(prod.tableFileName(),
                          os.path.join(pdir,"ups",pname+".table"))

        # turn to relative paths
        prod.canonicalizePaths()
        self.assertEqual(prod.dir, "Linux/newprod/2.0")
        self.assertEqual(prod.db, self.dbpath)
        self.assertEqual(prod.tablefile, pname+".table")
        self.assertEqual(prod.ups_dir, "ups")
        self.assertEqual(prod.tableFileName(),
                          os.path.join(pdir,"ups",pname+".table"))

        # round trip: turn back to absolute paths
        prod.resolvePaths()
        self.assertEqual(prod.dir, pdir)
        self.assertEqual(prod.db, self.dbpath)
        self.assertEqual(prod.tablefile,
                          os.path.join(pdir,"ups",pname+".table"))
        self.assertEqual(prod.ups_dir, os.path.join(pdir,"ups"))
        self.assertEqual(prod.tableFileName(),
                          os.path.join(pdir,"ups",pname+".table"))

        # turn original to relative paths
        clone.canonicalizePaths()
        self.assertEqual(clone.dir, "Linux/newprod/2.0")
        self.assertEqual(clone.db, self.dbpath)
        self.assertEqual(clone.tablefile, pname+".table")
        self.assertEqual(clone.ups_dir, "ups")
        self.assertEqual(clone.tableFileName(),
                          os.path.join(pdir,"ups",pname+".table"))

        # back to absolute paths
        clone.resolvePaths()
        self.assertEqual(clone.dir, pdir)
        self.assertEqual(clone.db, self.dbpath)
        self.assertEqual(clone.tablefile,
                          os.path.join(pdir,"ups",pname+".table"))
        self.assertEqual(clone.ups_dir, os.path.join(pdir,"ups"))
        self.assertEqual(clone.tableFileName(),
                          os.path.join(pdir,"ups",pname+".table"))
Example #4
0
    def testProd2(self):
        """
        Test $UPS_DB transformations
        """
        pname = "newprod"
        pver = "2.0"
        pdir = os.path.join(self.eupsPathDir,"Linux",pname,pver)
        prod = Product("newprod", "2.0", "Linux", pdir, db=self.dbpath,
                       table=os.path.join(self.dbpath,pname,'Linux',
                                          pver+".table"))

        self.assertEqual(prod.dir, pdir)
        self.assertEqual(prod.db, self.dbpath)
        self.assertEqual(prod.tablefile,
                          os.path.join(self.dbpath,"newprod/Linux/2.0.table"))
        self.assert_(prod.ups_dir is None)
        self.assertEqual(prod.tableFileName(),
                          os.path.join(self.dbpath,"newprod/Linux/2.0.table"))

        # test cloning (we'll use this later)
        clone = prod.clone()
        self.assertEqual(clone.dir, pdir)
        self.assertEqual(clone.db, self.dbpath)
        self.assertEqual(clone.tablefile,
                          os.path.join(self.dbpath,"newprod/Linux/2.0.table"))
        self.assert_(clone.ups_dir is None)
        self.assertEqual(clone.tableFileName(),
                          os.path.join(self.dbpath,"newprod/Linux/2.0.table"))

        # turn to absolute paths
        prod.resolvePaths()
        self.assertEqual(prod.dir, pdir)
        self.assertEqual(prod.db, self.dbpath)
        self.assert_(prod.ups_dir is None)
        self.assertEqual(prod.tablefile,
                          os.path.join(self.dbpath,"newprod/Linux/2.0.table"))
        self.assertEqual(prod.tableFileName(),
                          os.path.join(self.dbpath,"newprod/Linux/2.0.table"))

        prod.canonicalizePaths()
        self.assertEqual(prod.dir, "Linux/newprod/2.0")
        self.assertEqual(prod.db, self.dbpath)
        self.assertEqual(prod.ups_dir, "$UPS_DB/newprod/Linux")
        self.assertEqual(prod.tablefile, "2.0.table")
        self.assertEqual(prod.tableFileName(),
                          os.path.join(self.dbpath,"newprod/Linux/2.0.table"))

        # turn original to relative paths
        clone.canonicalizePaths()
        self.assertEqual(clone.dir, "Linux/newprod/2.0")
        self.assertEqual(clone.db, self.dbpath)
        self.assertEqual(clone.ups_dir, "$UPS_DB/newprod/Linux")
        self.assertEqual(clone.tablefile, "2.0.table")
        self.assertEqual(clone.tableFileName(),
                          os.path.join(self.dbpath,"newprod/Linux/2.0.table"))

        # back to absolute paths
        clone.resolvePaths()
        self.assertEqual(clone.dir, pdir)
        self.assertEqual(clone.db, self.dbpath)
        self.assertEqual(clone.ups_dir,
                          os.path.join(self.dbpath,pname,"Linux"))
        self.assertEqual(clone.tablefile,
                          os.path.join(self.dbpath,"newprod/Linux/2.0.table"))
        self.assertEqual(clone.tableFileName(),
                          os.path.join(self.dbpath,"newprod/Linux/2.0.table"))
Example #5
0
    def testProd1(self):
        pname = "newprod"
        pver = "2.0"
        pdir = os.path.join(self.eupsPathDir, "Linux", pname, pver)
        prod = Product("newprod", "2.0", "Linux", pdir, db=self.dbpath)

        self.assertEqual(prod.dir, pdir)
        self.assertEqual(prod.db, self.dbpath)
        self.assert_(prod.ups_dir is None)
        self.assert_(prod.tablefile is None)
        self.assertEqual(prod.tableFileName(),
                         os.path.join(pdir, "ups", pname + ".table"))

        # test cloning (we'll use this later)
        clone = prod.clone()
        self.assertEqual(clone.dir, pdir)
        self.assertEqual(clone.db, self.dbpath)
        self.assert_(clone.ups_dir is None)
        self.assert_(clone.tablefile is None)
        self.assertEqual(clone.tableFileName(),
                         os.path.join(pdir, "ups", pname + ".table"))

        # turn to absolute paths
        prod.resolvePaths()
        self.assertEqual(prod.dir, pdir)
        self.assertEqual(prod.db, self.dbpath)
        self.assertEqual(prod.tablefile,
                         os.path.join(pdir, "ups", pname + ".table"))
        self.assertEqual(prod.ups_dir, os.path.join(pdir, "ups"))
        self.assertEqual(prod.tableFileName(),
                         os.path.join(pdir, "ups", pname + ".table"))

        # turn to relative paths
        prod.canonicalizePaths()
        self.assertEqual(prod.dir, "Linux/newprod/2.0")
        self.assertEqual(prod.db, self.dbpath)
        self.assertEqual(prod.tablefile, pname + ".table")
        self.assertEqual(prod.ups_dir, "ups")
        self.assertEqual(prod.tableFileName(),
                         os.path.join(pdir, "ups", pname + ".table"))

        # round trip: turn back to absolute paths
        prod.resolvePaths()
        self.assertEqual(prod.dir, pdir)
        self.assertEqual(prod.db, self.dbpath)
        self.assertEqual(prod.tablefile,
                         os.path.join(pdir, "ups", pname + ".table"))
        self.assertEqual(prod.ups_dir, os.path.join(pdir, "ups"))
        self.assertEqual(prod.tableFileName(),
                         os.path.join(pdir, "ups", pname + ".table"))

        # turn original to relative paths
        clone.canonicalizePaths()
        self.assertEqual(clone.dir, "Linux/newprod/2.0")
        self.assertEqual(clone.db, self.dbpath)
        self.assertEqual(clone.tablefile, pname + ".table")
        self.assertEqual(clone.ups_dir, "ups")
        self.assertEqual(clone.tableFileName(),
                         os.path.join(pdir, "ups", pname + ".table"))

        # back to absolute paths
        clone.resolvePaths()
        self.assertEqual(clone.dir, pdir)
        self.assertEqual(clone.db, self.dbpath)
        self.assertEqual(clone.tablefile,
                         os.path.join(pdir, "ups", pname + ".table"))
        self.assertEqual(clone.ups_dir, os.path.join(pdir, "ups"))
        self.assertEqual(clone.tableFileName(),
                         os.path.join(pdir, "ups", pname + ".table"))
Example #6
0
    def testProd2(self):
        """
        Test $UPS_DB transformations
        """
        pname = "newprod"
        pver = "2.0"
        pdir = os.path.join(self.eupsPathDir, "Linux", pname, pver)
        prod = Product("newprod",
                       "2.0",
                       "Linux",
                       pdir,
                       db=self.dbpath,
                       table=os.path.join(self.dbpath, pname, 'Linux',
                                          pver + ".table"))

        self.assertEqual(prod.dir, pdir)
        self.assertEqual(prod.db, self.dbpath)
        self.assertEqual(prod.tablefile,
                         os.path.join(self.dbpath, "newprod/Linux/2.0.table"))
        self.assert_(prod.ups_dir is None)
        self.assertEqual(prod.tableFileName(),
                         os.path.join(self.dbpath, "newprod/Linux/2.0.table"))

        # test cloning (we'll use this later)
        clone = prod.clone()
        self.assertEqual(clone.dir, pdir)
        self.assertEqual(clone.db, self.dbpath)
        self.assertEqual(clone.tablefile,
                         os.path.join(self.dbpath, "newprod/Linux/2.0.table"))
        self.assert_(clone.ups_dir is None)
        self.assertEqual(clone.tableFileName(),
                         os.path.join(self.dbpath, "newprod/Linux/2.0.table"))

        # turn to absolute paths
        prod.resolvePaths()
        self.assertEqual(prod.dir, pdir)
        self.assertEqual(prod.db, self.dbpath)
        self.assert_(prod.ups_dir is None)
        self.assertEqual(prod.tablefile,
                         os.path.join(self.dbpath, "newprod/Linux/2.0.table"))
        self.assertEqual(prod.tableFileName(),
                         os.path.join(self.dbpath, "newprod/Linux/2.0.table"))

        prod.canonicalizePaths()
        self.assertEqual(prod.dir, "Linux/newprod/2.0")
        self.assertEqual(prod.db, self.dbpath)
        self.assertEqual(prod.ups_dir, "$UPS_DB/newprod/Linux")
        self.assertEqual(prod.tablefile, "2.0.table")
        self.assertEqual(prod.tableFileName(),
                         os.path.join(self.dbpath, "newprod/Linux/2.0.table"))

        # turn original to relative paths
        clone.canonicalizePaths()
        self.assertEqual(clone.dir, "Linux/newprod/2.0")
        self.assertEqual(clone.db, self.dbpath)
        self.assertEqual(clone.ups_dir, "$UPS_DB/newprod/Linux")
        self.assertEqual(clone.tablefile, "2.0.table")
        self.assertEqual(clone.tableFileName(),
                         os.path.join(self.dbpath, "newprod/Linux/2.0.table"))

        # back to absolute paths
        clone.resolvePaths()
        self.assertEqual(clone.dir, pdir)
        self.assertEqual(clone.db, self.dbpath)
        self.assertEqual(clone.ups_dir,
                         os.path.join(self.dbpath, pname, "Linux"))
        self.assertEqual(clone.tablefile,
                         os.path.join(self.dbpath, "newprod/Linux/2.0.table"))
        self.assertEqual(clone.tableFileName(),
                         os.path.join(self.dbpath, "newprod/Linux/2.0.table"))