Пример #1
0
def collapseHGR(string):
    """
        Returns all computable values of HRI_GLOBAL_ROOT with an
        ${HRI_GLOBAL_ROOT} placeholder.

        Deprecated: $HRI_GLOBAL_ROOT is not supposed to be used anymore.
                    If not defined this function uses the value of $SIT
                    instead.

    """
    envValue = FastScript.getEnv('HRI_GLOBAL_ROOT')

    # may no longer be defined, if so we use $SIT
    if not envValue:
        envValue = FastScript.getEnv('SIT')

    if not Any.isTextNonEmpty(envValue):
        raise EnvironmentError("Environment variable $SIT not defined")

    # replace all occurrences of ${HRI_GLOBAL_ROOT} or its value
    tmp = FastScript.collapseVar(string, 'HRI_GLOBAL_ROOT')

    # if existing, replace the path where ${HRI_GLOBAL_ROOT}/parentTree points to
    linkName = os.path.join(envValue, parentLink)

    try:
        linkTarget = os.readlink(linkName)
        tmp = tmp.replace(linkTarget + '/', '')
    except (
            OSError,  # probably has no such link
            AttributeError):  # os.readlink n/a on Windows
        pass

    return tmp
Пример #2
0
def collapseSIT(string):
    """
        Returns all computable values of SIT with an ${SIT} placeholder.
    """
    return FastScript.collapseVar(string, 'SIT')