Exemplo n.º 1
0
    def __init__(self, stepObj, errStr, *args, **kwargs):
        ReleaseFrameworkError.__init__(self, errStr, stepObj)

        assert isinstance(stepObj, Step), "StepErrors require a Step object"

        self._partnerStr = ""
        if isinstance(stepObj, PartnerStep):
            self._partnerStr = " (partner: %s)" % (stepObj.activePartner)
Exemplo n.º 2
0
    def __init__(self, stepObj, errStr, *args, **kwargs):
        ReleaseFrameworkError.__init__(self, errStr, stepObj)

        assert isinstance(stepObj, Step), "StepErrors require a Step object"

        self._partnerStr = ""
        if isinstance(stepObj, PartnerStep):
            self._partnerStr = " (partner: %s)" % (stepObj.activePartner)
Exemplo n.º 3
0
def PlatformCheck(conf):
    thisPlatform = GetBuildPlatform()
    supportedPlatforms = conf.Get('official_platforms', list)

    if thisPlatform not in supportedPlatforms:
        raise ReleaseFrameworkError(
            "This example has only been tested on the "
            "following platforms: %s. Your platform: %s" %
            (', '.join(supportedPlatforms), thisPlatform))
Exemplo n.º 4
0
 def __str__(self):
     return "Error in step %s%s: %s" % (self.erroredStep, self._partnerStr,
                                        ReleaseFrameworkError.__str__(self))
Exemplo n.º 5
0
 def __str__(self):
     return "ConfigSpec Error: " + ReleaseFrameworkError.__str__(self)
Exemplo n.º 6
0
 def __init__(self, errorStr, details=None):
     ReleaseFrameworkError.__init__(self, errorStr, details)
Exemplo n.º 7
0
 def __str__(self):
     return "Error in step %s%s: %s" % (self.erroredStep, self._partnerStr,
      ReleaseFrameworkError.__str__(self))
Exemplo n.º 8
0
def GetAvailableProcesses():
    """
    Search for and instantiate all of the defined QuickRelease L{Process}es.

    B{Note}: for performance reasons, a cache is used to store these L{Process}es after the first call to C{GetAvailableProcesses()}. There is currently no way to clear this cache.

    @return: A tuple of references to all defined QuickRelease L{Process}es in the provided "processes" directories.
    @rtype: C{tuple} of L{Process}

    @raise ReleaseFrameworkError: A L{ReleaseFrameworkError<quickrelease.exception.ReleaseFrameworkError>} is raised in the following circumstances:
      1. A L{Process} lists a L{Step<quickrelease.step.Step>}, but that Step is not defined.
      2. A L{Process} is attempting to import a module which has not been defined.
      3. A L{Process} is attempting to import a L{Step<quickrelease.step.Step>}, but that Step contains a syntax error.
      4. Other problems may cause L{NameError}s, L{ImportError}s, or L{SyntaxError}s to be recast into L{ReleaseFrameworkError<quickrelease.exception.ReleaseFrameworkError>}s with the original error message.
    """
    if Process._gAvailableProcessList is None:
        Process._gAvailableProcessList = []

        for path in gProcessAndStepDefnPath:
            #print "Checking process/step definition path: %s" % (path)
            cwd = os.getcwd()
            processModuleFiles = []

            try:
                os.chdir(JoinPaths(path, QUICKRELEASE_PROCESSES_DIR))
                processModuleFiles = glob('*.py')
            finally:
                os.chdir(cwd)

            processModuleFiles.remove(INIT_PY)

            if len(processModuleFiles) <= 0:
                continue

            filenameToModuleName = lambda f: '.'.join([
                os.path.basename(path), QUICKRELEASE_PROCESSES_DIR,
                os.path.splitext(f)[0]
            ])
            moduleFiles = map(filenameToModuleName, processModuleFiles)
            processList = []

            for f in moduleFiles:
                #print "Importing process module: " + f

                try:
                    mod = ImportModule(f)
                except NameError, ex:
                    nameErrorRegex = "name '(\w+)' is not defined"
                    nameErrorMatch = re.match(nameErrorRegex, str(ex))
                    if nameErrorMatch:
                        raise ReleaseFrameworkError(
                            "Step %s is specified as "
                            "part of process %s, but is not defined" %
                            (nameErrorMatch.group(1), f.split('.')[-1]))
                    else:
                        raise ReleaseFrameworkError(
                            "%s: NameError: %s" % (f, ex), ex)
                except ImportError, ex:
                    importErrorRegex = "No module named (.+)"
                    importErrorMatch = re.match(importErrorRegex, str(ex))
                    if importErrorMatch:
                        raise ReleaseFrameworkError(
                            "Process %s is trying to "
                            "import undefined module %s" %
                            (f, importErrorMatch.group(1)))
                    else:
                        raise ReleaseFrameworkError(
                            "%s: ImportError: %s" % (f, ex), ex)
                except SyntaxError, ex:
                    definitionType = None
                    parentDir = os.path.basename(os.path.dirname(ex.filename))
                    processDetailStr = ""
                    if parentDir == QUICKRELEASE_PROCESSES_DIR:
                        definitionType = "process"
                    elif parentDir == QUICKRELEASE_STEPS_DIR:
                        definitionType = "step"
                        processDetailStr = " (part of process %s)" % (
                            f.split('.')[-1])

                    raise ReleaseFrameworkError(
                        "Syntax error in %s "
                        "definition %s%s, line %d:\n%s" %
                        (definitionType, os.path.basename(ex.filename),
                         processDetailStr, ex.lineno, ex.text))

                for attr in dir(mod):
                    obj = getattr(mod, attr)
                    if inspect.isclass(obj):
                        if obj.__module__ == f and issubclass(obj, Process):
                            #print "Process class found: %s" % (obj.__name__)
                            processList.append(obj)
Exemplo n.º 9
0
IMPORT_PATH_DASH_WARNING_STR = (
    "Warning: paths containing dashes (-) in the "
    "QUICKRELEASE_DEFINITIONS_PATH may cause import statement errors, depending on "
    "their location. If this doesn't affect your setup, set the "
    "QUICKRELEASE_DISABLE_IMPORT_DASH_WARNING environment variable.")

gProcessAndStepDefnPath = []

QUICKRELEASE_DEFINITIONS_PATH = os.getenv('QUICKRELEASE_DEFINITIONS_PATH')

if QUICKRELEASE_DEFINITIONS_PATH is not None:
    for path in QUICKRELEASE_DEFINITIONS_PATH.split(os.path.pathsep):
        if re.search('\-', path):
            if os.getenv('QUICKRELEASE_DISABLE_IMPORT_DASH_WARNING') is None:
                raise ReleaseFrameworkError(IMPORT_PATH_DASH_WARNING_STR)
        absPath = os.path.abspath(path)
        gProcessAndStepDefnPath.append(absPath)
        sys.path.append(os.path.dirname(absPath))

if os.getenv('QUICKRELEASE_OVERRIDE_DEFAULT_DEFINITIONS') is None:
    gProcessAndStepDefnPath.append(os.path.dirname(os.path.abspath(__file__)))

INIT_PY_MISSING_ERR_STR = (
    "The specified directory '%s' in "
    "QUICKRELEASE_DEFINITIONS_PATH is missing an __init__.py file; please add "
    "one.")

for path in gProcessAndStepDefnPath:
    if not os.path.isfile(JoinPaths(path, INIT_PY)):
        raise RuntimeWarning(INIT_PY_MISSING_ERR_STR % (path))
Exemplo n.º 10
0
 def __str__(self):
     return "ConfigSpec Error: " + ReleaseFrameworkError.__str__(self)
Exemplo n.º 11
0
 def __init__(self, errorStr, details=None):
     ReleaseFrameworkError.__init__(self, errorStr, details)