コード例 #1
0
 def raise_error():
     # failure.parents[-1] will be the exception class for local
     # failures and the string name of the exception class
     # for remote failures (which might not exist in our
     # namespace)
     #
     # failure.value will be the tuple of arguments to the
     # exception in the local case, or a string
     # representation of that in the remote case (see
     # pb.CopyableFailure.getStateToCopy()).
     #
     # we can only reproduce a remote exception if the
     # exception class is in our namespace, and it only takes
     # one string argument. if either condition is not true,
     # we wrap the strings in a default Exception.
     if common.versionStringToTuple(version.short()) >= (11, 1, 0):
         k, v = failure.parents[0], failure.value
     else:
         k, v = failure.parents[-1], failure.value
     try:
         if isinstance(k, str):
             k = reflect.namedClass(k)
         if isinstance(v, tuple):
             e = k(*v)
         else:
             e = k(v)
     except Exception:
         e = Exception('%s: %r' % (failure.type, v))
     raise e
コード例 #2
0
ファイル: config.py プロジェクト: ylatuya/Flumotion
 def _buildVersionTuple(self, version):
     if version is None:
         return configure.versionTuple
     elif isinstance(version, tuple):
         assert len(version) == 4
         return version
     elif isinstance(version, str):
         try:
             return common.versionStringToTuple(version)
         except:
             raise errors.ConfigError(
                 "<component> version %r not parseable" % version)
     raise errors.ConfigError(
         "<component> version %r not parseable" % version)
コード例 #3
0
ファイル: config.py プロジェクト: sharky93/flumotion
 def _buildVersionTuple(self, version):
     if version is None:
         return configure.versionTuple
     elif isinstance(version, tuple):
         assert len(version) == 4
         return version
     elif isinstance(version, str):
         try:
             return common.versionStringToTuple(version)
         except:
             raise errors.ConfigError(
                 "<component> version %r not parseable" % version)
     raise errors.ConfigError("<component> version %r not parseable" %
                              version)
コード例 #4
0
ファイル: manager.py プロジェクト: flyapen/UgFlu
    def _addComponent(self, conf, parent, identity):
        """
        Add a component state for the given component config entry.

        @rtype: L{flumotion.common.planet.ManagerComponentState}
        """

        self.debug('adding component %s to %s'
                   % (conf.name, parent.get('name')))

        if identity != LOCAL_IDENTITY:
            self.adminAction(identity, '_addComponent', (conf, parent), {})

        state = planet.ManagerComponentState()
        state.set('name', conf.name)
        state.set('type', conf.getType())
        state.set('workerRequested', conf.worker)
        state.setMood(moods.sleeping.value)
        state.set('config', conf.getConfigDict())

        state.set('parent', parent)
        parent.append('components', state)

        avatarId = conf.getConfigDict()['avatarId']

        self.clearMessage('loadComponent-%s' % avatarId)

        configDict = conf.getConfigDict()
        projectName = configDict['project']
        versionTuple = configDict['version']

        projectVersion = None
        try:
            projectVersion = project.get(projectName, 'version')
        except errors.NoProjectError:
            m = messages.Warning(T_(N_(
                "This component is configured for Flumotion project '%s', "
                "but that project is not installed.\n"),
                    projectName))
            state.append('messages', m)

        if projectVersion:
            self.debug('project %s, version %r, project version %r' % (
                projectName, versionTuple, projectVersion))
            if not common.checkVersionsCompat(
                    versionTuple,
                    common.versionStringToTuple(projectVersion)):
                m = messages.Warning(T_(N_(
                    "This component is configured for "
                    "Flumotion '%s' version %s, "
                    "but you are running version %s.\n"
                    "Please update the configuration of the component.\n"),
                        projectName, common.versionTupleToString(versionTuple),
                        projectVersion))
                state.append('messages', m)

        # add to mapper
        m = ComponentMapper()
        m.state = state
        m.id = avatarId
        self._componentMappers[state] = m
        self._componentMappers[avatarId] = m

        return state