Example #1
0
def getDependencies(productName,
                    versionName=None,
                    eupsenv=None,
                    setup=False,
                    shouldRaise=False,
                    followExact=None,
                    topological=False):
    """
    Return a list of productName's dependent products : [(productName, VersionName, optional, recursionDepth), ...]
    @param productName     Desired product's name
    @param versionName     Desired version of product
    @param eupsenv         the Eups instance to use; if None, a default will be created.  
    @param setup           Return the versions of dependent products that are actually setup
    @param shouldRaise     Raise an exception if setup is True and a required product isn't setup
    @param followExact     If None use the exact/inexact status in eupsenv; if non-None set desired exactness

    See also Eups.getDependentProducts()
    """

    if not eupsenv:
        eupsenv = Eups()

    topProduct = eupsenv.findProduct(productName, versionName)
    if not topProduct:  # it's never been declared (at least not with this version)
        return []

    return [(
        product.name, product.version, optional, recursionDepth
    ) for product, optional, recursionDepth in eupsenv.getDependentProducts(
        topProduct, setup, shouldRaise, followExact, topological=topological)]
Example #2
0
def productDir(productName=None, versionName=Tag("setup"), eupsenv=None):
    """
    return the installation directory (PRODUCT_DIR) for the specified 
    product.  None is returned if no matching product can be found
    @param productName   the name of the product of interest; if None return a dictionary of all productDirs
    @param version       the desired version.  This can in one of the 
                         following forms:
                          *  an explicit version 
                          *  a version expression (e.g. ">=3.3")
                          *  a Tag instance 
                          *  None, in which case, the (most) preferred 
                               version will be returned.
                         The default is the global tag "setup".  
    @param eupsenv       The Eups instance to use to find the product.  If 
                            not provided, a default will created.  
    """
    if productName and versionName == Tag("setup"): # we can take a shortcut
        return os.environ.get(utils.dirEnvNameFor(productName))

    if not eupsenv:
        eupsenv = Eups()

    if not productName:
        tags = None
        if versionName == Tag("setup"):
            tags = versionName
            versionName = ""
            
        productList = eupsenv.findProducts(productName, versionName, tags)
        productDirs = {}
        for prod in productList:
            pdir = prod.dir
            if pdir == "none":
                pdir = None
            productDirs[prod.name] = pdir

        return productDirs

    prod = eupsenv.findProduct(productName, versionName)
    if not prod:
        return None

    pdir = prod.dir
    if pdir == "none":
        pdir = None
        
    return pdir
Example #3
0
def productDir(productName=None, versionName=Tag("setup"), eupsenv=None):
    """
    return the installation directory (PRODUCT_DIR) for the specified 
    product.  None is returned if no matching product can be found
    @param productName   the name of the product of interest; if None return a dictionary of all productDirs
    @param version       the desired version.  This can in one of the 
                         following forms:
                          *  an explicit version 
                          *  a version expression (e.g. ">=3.3")
                          *  a Tag instance 
                          *  None, in which case, the (most) preferred 
                               version will be returned.
                         The default is the global tag "setup".  
    @param eupsenv       The Eups instance to use to find the product.  If 
                            not provided, a default will created.  
    """
    if productName and versionName == Tag("setup"):  # we can take a shortcut
        return os.environ.get(utils.dirEnvNameFor(productName))

    if not eupsenv:
        eupsenv = Eups()

    if not productName:
        tags = None
        if versionName == Tag("setup"):
            tags = versionName
            versionName = ""

        productList = eupsenv.findProducts(productName, versionName, tags)
        productDirs = {}
        for prod in productList:
            pdir = prod.dir
            if pdir == "none":
                pdir = None
            productDirs[prod.name] = pdir

        return productDirs

    prod = eupsenv.findProduct(productName, versionName)
    if not prod:
        return None

    pdir = prod.dir
    if pdir == "none":
        pdir = None

    return pdir
Example #4
0
def findProduct(productName, versionName=None, eupsenv=None):
    """
    return the specified product.  None is returned if no matching product can be found
    @param productName   the name of the product of interest
    @param version       the desired version (default: current).  This can in one of the 
    following forms:
    *  an explicit version 
    *  a version expression (e.g. ">=3.3")
    *  a Tag instance 
    *  None, in which case, the (most) preferred 
    version will be returned.
    @param eupsenv       The Eups instance to use to find the product.  If 
    not provided, a default will created.  
    """
    if not eupsenv:
        eupsenv = Eups()

    if versionName is None:
        versionName = Tag("current")

    return eupsenv.findProduct(productName, versionName)
Example #5
0
def findProduct(productName, versionName=None, eupsenv=None):
    """
    return the specified product.  None is returned if no matching product can be found
    @param productName   the name of the product of interest
    @param version       the desired version (default: current).  This can in one of the 
    following forms:
    *  an explicit version 
    *  a version expression (e.g. ">=3.3")
    *  a Tag instance 
    *  None, in which case, the (most) preferred 
    version will be returned.
    @param eupsenv       The Eups instance to use to find the product.  If 
    not provided, a default will created.  
    """
    if not eupsenv:
        eupsenv = Eups()

    if versionName is None:
        versionName = Tag("current")

    return eupsenv.findProduct(productName, versionName)
Example #6
0
def getDependencies(productName, versionName=None, eupsenv=None, setup=False, shouldRaise=False,
                    followExact=None, topological=False):
    """
    Return a list of productName's dependent products : [(productName, VersionName, optional, recursionDepth), ...]
    @param productName     Desired product's name
    @param versionName     Desired version of product
    @param eupsenv         the Eups instance to use; if None, a default will be created.  
    @param setup           Return the versions of dependent products that are actually setup
    @param shouldRaise     Raise an exception if setup is True and a required product isn't setup
    @param followExact     If None use the exact/inexact status in eupsenv; if non-None set desired exactness

    See also Eups.getDependentProducts()
    """

    if not eupsenv:
        eupsenv = Eups()

    topProduct = eupsenv.findProduct(productName, versionName)
    if not topProduct:                  # it's never been declared (at least not with this version)
        return []
        
    return [(product.name, product.version, optional, recursionDepth) for product, optional, recursionDepth in
            eupsenv.getDependentProducts(topProduct, setup, shouldRaise, followExact,
                                         topological=topological)]