Example #1
0
    def _ValidateEachComponent(self, result, recipeID, recipeDict):
        perComponentValidationFuncs = [
            self._ValidateComponentViewIsDefined,
            self._ValidateComponentSpawnInputs,
            self._ValidateComponentDependencies,
            self._ValidateCustomComponentInfo
        ]
        for componentID in recipeDict:
            componentView = BaseComponentView.GetComponentViewByID(componentID)
            componentResult = ValidationMessage(
                name=self._GetComponentName(componentView, componentID))
            for validationFunc in perComponentValidationFuncs:
                try:
                    canContinue = validationFunc(componentResult, recipeID,
                                                 recipeDict, componentView,
                                                 componentID)
                except Exception as e:
                    self.LogError(
                        'An error occurred while running validation for component "%s" at recipeID=%s'
                        % (componentView.__COMPONENT_DISPLAY_NAME__, recipeID))
                    log.LogException(e)
                    componentResult.AddMessage(
                        'An error occurred while running validation for this component'
                    )
                    canContinue = True

                if not canContinue:
                    break

            result.AddMessage(componentResult)
Example #2
0
def GetComponentName(componentID):
    componentView = BaseComponentView.GetComponentViewByID(componentID)
    if type(componentID) is str:
        return componentID
    if componentView is None:
        log.LogTraceback('UNKNOWN COMPONENT %s' % componentID)
        return 'UNKNOWN COMPONENT %s' % componentID
    return componentView.__COMPONENT_CODE_NAME__
Example #3
0
def ShouldSpawnOn(componentIDList, spawnLoc):
    shouldSpawn = False
    for componentID in componentIDList:
        componentView = BaseComponentView.GetComponentViewByID(componentID)
        spawnHere = componentView.__SHOULD_SPAWN__.get(spawnLoc, None)
        if spawnHere is False:
            return False
        if spawnHere:
            shouldSpawn = True

    return shouldSpawn
def GetComponentName(componentID):
    """
    Important Distinction:
      This gets the CODE name of the component, that is used as a real code variable name.
    It's QUITE urgent that those code names are never changed once defined,
      due to a bunch of weird things the components do, and how they're used.
    """
    componentView = BaseComponentView.GetComponentViewByID(componentID)
    if type(componentID) is str:
        return componentID
    if componentView is None:
        log.LogTraceback('UNKNOWN COMPONENT %s' % componentID)
        return 'UNKNOWN COMPONENT %s' % componentID
    return componentView.__COMPONENT_CODE_NAME__
def ShouldSpawnOn(componentIDList, spawnLoc):
    """
    Takes in a list of componentID's and based on this determines if for the
    boot role specified if these components would be spawned on this role.
    """
    shouldSpawn = False
    for componentID in componentIDList:
        componentView = BaseComponentView.GetComponentViewByID(componentID)
        spawnHere = componentView.__SHOULD_SPAWN__.get(spawnLoc, None)
        if spawnHere is False:
            return False
        if spawnHere:
            shouldSpawn = True

    return shouldSpawn
Example #6
0
    def _ValidateComponentDependencies(self, result, recipeID, recipeDict,
                                       componentView, componentID):
        dependentComponentIDs = componentView.GetDependencies()
        for otherComponentID in dependentComponentIDs:
            otherComponentView = BaseComponentView.GetComponentViewByID(
                otherComponentID)
            if otherComponentView is None:
                result.AddMessage(
                    'Contact Programmer: Invalid dependent component: %s' %
                    otherComponentID)
                continue
            if otherComponentID not in recipeDict:
                result.AddMessage(
                    'Missing component: %s' %
                    otherComponentView.__COMPONENT_DISPLAY_NAME__)

        return True