Exemplo n.º 1
0
def findEndModuleCandidates(path, prefix=configure.PACKAGE):
    """
    I take a directory and return a list of candidate python end modules
    (i.e., non-package modules) for the given module prefix.

    @param path:   the path under which to search for end modules
    @type  path:   string
    @param prefix: module prefix to check candidates under
    @type  prefix: string
    """
    pathPrefix = "/".join(prefix.split("."))
    files = _listPyFileRecursively(os.path.join(path, pathPrefix))

    # chop off the base path to get a list of "relative" import space paths
    importPaths = [x[len(path) + 1 :] for x in files]

    # remove some common candidates, like .svn subdirs, or containing -
    importPaths = [path for path in importPaths if path.find(".svn") == -1]
    importPaths = [path for path in importPaths if path.find("-") == -1]

    # convert paths to module namespace
    endModules = [common.pathToModuleName(x) for x in importPaths]

    # remove all not starting with prefix
    endModules = [module for module in endModules if module and module.startswith(prefix)]

    # sort them so that depending packages are after higher-up packages
    endModules.sort()

    # make unique
    res = {}
    for b in endModules:
        res[b] = 1

    return res.keys()
Exemplo n.º 2
0
        def gotEntryPoint((filename, procname)):
            # The manager always returns / as a path separator, replace them
            # with the separator since the rest of our infrastructure depends
            # on that.
            filename = filename.replace('/', os.path.sep)
            # getEntry for admin/gtk returns a factory function for creating
            # flumotion.component.base.admin_gtk.BaseAdminGtk
            # subclass instances
            modname = pathToModuleName(filename)

            # we call hostile code, so we should handle exceptions:
            d = admin.getBundledFunction(modname, procname)
            d.addErrback(admin.bundleErrback, filename)

            def handleSyntaxError(failure):
                failure.trap(errors.EntrySyntaxError)
                msg = failure.value.args[0]

                m = messages.Error(T_(
                    N_("This component has a UI bug.")), debug=msg)
                componentState.observe_append('messages', m)

                raise errors.HandledException(failure.value)

            d.addErrback(handleSyntaxError)

            return d
Exemplo n.º 3
0
        def gotEntryPoint((filename, procname)):
            # The manager always returns / as a path separator, replace them
            # with the separator since the rest of our infrastructure depends
            # on that.
            filename = filename.replace('/', os.path.sep)
            # getEntry for admin/gtk returns a factory function for creating
            # flumotion.component.base.admin_gtk.BaseAdminGtk
            # subclass instances
            modname = pathToModuleName(filename)

            # we call hostile code, so we should handle exceptions:
            d = admin.getBundledFunction(modname, procname)
            d.addErrback(admin.bundleErrback, filename)

            def handleSyntaxError(failure):
                failure.trap(errors.EntrySyntaxError)
                msg = failure.value.args[0]

                m = messages.Error(T_(N_("This component has a UI bug.")),
                                   debug=msg)
                componentState.observe_append('messages', m)

                raise errors.HandledException(failure.value)

            d.addErrback(handleSyntaxError)

            return d
Exemplo n.º 4
0
 def _collectFilenames(self, filenames):
     retval = {}
     for filename in filenames:
         moduleName = pathToModuleName(filename)
         if not moduleName in self._versions:
             continue
         retval[filename] = self._versions[moduleName]
     return retval
Exemplo n.º 5
0
 def _collectFilenames(self, filenames):
     retval = {}
     for filename in filenames:
         moduleName = pathToModuleName(filename)
         if not moduleName in self._versions:
             continue
         retval[filename] = self._versions[moduleName]
     return retval
Exemplo n.º 6
0
    def testPaths(self):
        tests = {
            'flumotion/common/common.py': 'flumotion.common.common',
            'flumotion/common/common.pyo': 'flumotion.common.common',
            'flumotion/common/__init__.pyc': 'flumotion.common',
            'flumotion/common': 'flumotion.common',
            'flumotion/configure/uninstalled.py.in': None,
        }

        for (path, module) in tests.items():
            self.assertEquals(common.pathToModuleName(path), module,
                "path %s did not give end module %s" % (path, module))
Exemplo n.º 7
0
    def testPaths(self):
        tests = {
            'flumotion/common/common.py': 'flumotion.common.common',
            'flumotion/common/common.pyo': 'flumotion.common.common',
            'flumotion/common/__init__.pyc': 'flumotion.common',
            'flumotion/common': 'flumotion.common',
            'flumotion/configure/uninstalled.py.in': None,
        }

        for (path, module) in tests.items():
            self.assertEquals(
                common.pathToModuleName(path), module,
                "path %s did not give end module %s" % (path, module))
Exemplo n.º 8
0
    def gotEntryCallback(self, result, name):
        entryPath, filename, methodName = result
        filepath = os.path.join(entryPath, filename)
        self.debug('Got the UI for %s and it lives in %s' % (name, filepath))
        self.uidir = os.path.split(filepath)[0]
        #handle = open(filepath, "r")
        #data = handle.read()
        #handle.close()

        # try loading the class
        moduleName = common.pathToModuleName(filename)
        statement = 'import %s' % moduleName
        self.debug('running %s' % statement)
        try:
            exec(statement)
        except SyntaxError, e:
            # the syntax error can happen in the entry file, or any import
            where = getattr(e, 'filename', "<entry file>")
            lineno = getattr(e, 'lineno', 0)
            msg = "Syntax Error at %s:%d while executing %s" % (where, lineno,
                                                                filename)
            self.warning(msg)
            raise errors.EntrySyntaxError(msg)
Exemplo n.º 9
0
    def gotEntryCallback(self, result, name):
        entryPath, filename, methodName = result
        filepath = os.path.join(entryPath, filename)
        self.debug('Got the UI for %s and it lives in %s' % (name, filepath))
        self.uidir = os.path.split(filepath)[0]
        #handle = open(filepath, "r")
        #data = handle.read()
        #handle.close()

        # try loading the class
        moduleName = common.pathToModuleName(filename)
        statement = 'import %s' % moduleName
        self.debug('running %s' % statement)
        try:
            exec(statement)
        except SyntaxError, e:
            # the syntax error can happen in the entry file, or any import
            where = getattr(e, 'filename', "<entry file>")
            lineno = getattr(e, 'lineno', 0)
            msg = "Syntax Error at %s:%d while executing %s" % (
                where, lineno, filename)
            self.warning(msg)
            raise errors.EntrySyntaxError(msg)
Exemplo n.º 10
0
def findEndModuleCandidates(path, prefix=configure.PACKAGE):
    """
    I take a directory and return a list of candidate python end modules
    (i.e., non-package modules) for the given module prefix.

    @param path:   the path under which to search for end modules
    @type  path:   string
    @param prefix: module prefix to check candidates under
    @type  prefix: string
    """
    pathPrefix = "/".join(prefix.split("."))
    files = _listPyFileRecursively(os.path.join(path, pathPrefix))

    # chop off the base path to get a list of "relative" import space paths
    importPaths = [x[len(path) + 1:] for x in files]

    # remove some common candidates, like .svn subdirs, or containing -
    importPaths = [path for path in importPaths if path.find('.svn') == -1]
    importPaths = [path for path in importPaths if path.find('-') == -1]

    # convert paths to module namespace
    endModules = [common.pathToModuleName(x) for x in importPaths]

    # remove all not starting with prefix
    endModules = [
        module for module in endModules if module and module.startswith(prefix)
    ]

    # sort them so that depending packages are after higher-up packages
    endModules.sort()

    # make unique
    res = {}
    for b in endModules:
        res[b] = 1

    return res.keys()
Exemplo n.º 11
0
class ConfigurationAssistant(SectionWizard):
    """This is the main configuration assistant class,
    it is responsible for::
    - executing tasks which will block the ui
    - showing a worker list in the UI
    - communicating with the manager, fetching bundles
      and registry information
    - running check defined by a step in a worker, for instance
      querying for hardware devices and their capabilities
    It extends SectionWizard which provides the basic user interface, such
    as sidebar, buttons, title bar and basic step navigation.
    """
    gsignal('finished', str)

    def __init__(self, parent=None):
        SectionWizard.__init__(self, parent)
        self.connect('help-clicked', self._on_assistant__help_clicked)
        # Set the name of the toplevel window, this is used by the
        # ui unittest framework
        self.window1.set_name('ConfigurationAssistant')
        self.message_area.disableTimestamps()

        self._cursorWatch = gdk.Cursor(gdk.WATCH)
        self._tasks = []
        self._adminModel = None
        self._workerHeavenState = None
        self._lastWorker = 0  # combo id last worker from step to step
        self._stepWorkers = {}
        self._scenario = None
        self._existingComponentNames = []
        self._porters = []
        self._mountPoints = []
        self._consumers = {}

        self._workerList = WorkerList()
        self.top_vbox.pack_start(self._workerList, False, False)
        self._workerList.connect('worker-selected',
                                 self.on_combobox_worker_changed)

    # SectionWizard

    def completed(self):
        saver = AssistantSaver()
        saver.setFlowName('default')
        saver.setExistingComponentNames(self._existingComponentNames)
        self._scenario.save(self, saver)

        xml = saver.getXML()
        self.emit('finished', xml)

    def destroy(self):
        SectionWizard.destroy(self)
        self._adminModel = None

    def beforeShowStep(self, step):
        if isinstance(step, WorkerWizardStep):
            self._workerList.show()
            if step.worker:
                self._workerList.selectWorker(step.worker)
            self._workerList.notifySelected()
        else:
            self._workerList.hide()

        self._fetchDescription(step)
        self._setupWorker(step, self._workerList.getWorker())

    def prepareNextStep(self, step):
        self._setupWorker(step, self._workerList.getWorker())
        SectionWizard.prepareNextStep(self, step)

    def blockNext(self, block):
        # Do not block/unblock if we have tasks running
        if self._tasks:
            return
        SectionWizard.blockNext(self, block)

    # Public API

    # FIXME: Remove this and make fgc create a new scenario

    def addInitialSteps(self):
        """Add the step sections of the wizard, can be
        overridden in a subclass
        """
        # These two steps are independent of the scenarios, they
        # should always be added.
        self.addStepSection(WelcomeStep)
        self.addStepSection(ScenarioStep)

    def setScenario(self, scenario):
        """Sets the current scenario of the assistant.
        Normally called by ScenarioStep to tell the assistant the
        current scenario just after creating it.
        @param scenario: the scenario of the assistant
        @type scenario: a L{flumotion.admin.assistant.scenarios.Scenario}
          subclass
        """
        self._scenario = scenario

    def getScenario(self):
        """Fetches the currently set scenario of the assistant.
        @returns scenario: the scenario of the assistant
        @rtype: a L{flumotion.admin.assistant.scenarios.Scenario} subclass
        """
        return self._scenario

    def setWorkerHeavenState(self, workerHeavenState):
        """
        Sets the worker heaven state of the assistant
        @param workerHeavenState: the worker heaven state
        @type workerHeavenState: L{WorkerComponentUIState}
        """
        self._workerHeavenState = workerHeavenState
        self._workerList.setWorkerHeavenState(workerHeavenState)

    def setAdminModel(self, adminModel):
        """
        Sets the admin model of the assistant
        @param adminModel: the admin model
        @type adminModel: L{AdminModel}
        """
        self._adminModel = adminModel
        self._adminModel.connect('connected', self.on_admin_connected_cb)
        self._adminModel.connect('disconnected', self.on_admin_disconnected_cb)

    def setHTTPPorters(self, porters):
        """
        Sets the list of currently configured porters so
        we can reuse them for future streamers.

        @param porters: list of porters
        @type porters : list of L{flumotion.admin.assistant.models.Porter}
        """

        self._porters = porters

    def getHTTPPorters(self):
        """
        Obtains the list of the currently configured porters.

        @rtype : list of L{flumotion.admin.assistant.models.Porter}
        """
        return self._porters

    def addMountPoint(self, worker, port, mount_point, consumer=None):
        """
        Marks a mount point as used on the given worker and port.
        If a consumer name is provided it means we are changing the
        mount point for that consumer and that we should keep track of
        it for further modifications.

        @param worker   : The worker where the mount_point is configured.
        @type  worker   : str
        @param port     : The port where the streamer should be listening.
        @type  port     : int
        @param mount_point : The mount point where the data will be served.
        @type  mount_point : str
        @param consumer : The consumer that is changing its mountpoint.
        @type  consumer : str

        @returns : True if the mount point is not used and has been
                   inserted correctly, False otherwise.
        @rtype   : boolean
        """
        if not worker or not port or not mount_point:
            return False

        if consumer in self._consumers:
            oldData = self._consumers[consumer]
            if oldData in self._mountPoints:
                self._mountPoints.remove(oldData)

        data = (worker, port, mount_point)

        if data in self._mountPoints:
            return False

        self._mountPoints.append(data)

        if consumer:
            self._consumers[consumer] = data

        return True

    def getAdminModel(self):
        """Gets the admin model of the assistant
        @returns adminModel: the admin model
        @rtype adminModel: L{AdminModel}
        """
        return self._adminModel

    def waitForTask(self, taskName):
        """Instruct the assistant that we're waiting for a task
        to be finished. This changes the cursor and prevents
        the user from continuing moving forward.
        Each call to this method should have another call
        to taskFinished() when the task is actually done.
        @param taskName: name of the name
        @type taskName: string
        """
        self.info("waiting for task %s" % (taskName, ))
        if not self._tasks:
            if self.window1.window is not None:
                self.window1.window.set_cursor(self._cursorWatch)
            self.blockNext(True)
        self._tasks.append(taskName)

    def taskFinished(self, blockNext=False):
        """Instruct the assistant that a task was finished.
        @param blockNext: if we should still next when done
        @type blockNext: boolean
        """
        if not self._tasks:
            raise AssertionError(
                "Stray call to taskFinished(), forgot to call waitForTask()?")

        taskName = self._tasks.pop()
        self.info("task %s has now finished" % (taskName, ))
        if not self._tasks:
            self.window1.window.set_cursor(None)
            self.blockNext(blockNext)

    def pendingTask(self):
        """Returns true if there are any pending tasks
        @returns: if there are pending tasks
        @rtype: bool
        """
        return bool(self._tasks)

    def checkElements(self, workerName, *elementNames):
        """Check if the given list of GStreamer elements exist on the
        given worker.
        @param workerName: name of the worker to check on
        @type workerName: string
        @param elementNames: names of the elements to check
        @type elementNames: list of strings
        @returns: a deferred returning a tuple of the missing elements
        @rtype: L{twisted.internet.defer.Deferred}
        """
        if not self._adminModel:
            self.debug('No admin connected, not checking presence of elements')
            return

        asked = python.set(elementNames)

        def _checkElementsCallback(existing, workerName):
            existing = python.set(existing)
            self.taskFinished()
            return tuple(asked.difference(existing))

        self.waitForTask('check elements %r' % (elementNames, ))
        d = self._adminModel.checkElements(workerName, elementNames)
        d.addCallback(_checkElementsCallback, workerName)
        return d

    def requireElements(self, workerName, *elementNames):
        """Require that the given list of GStreamer elements exists on the
        given worker. If the elements do not exist, an error message is
        posted and the next button remains blocked.
        @param workerName: name of the worker to check on
        @type workerName: string
        @param elementNames: names of the elements to check
        @type elementNames: list of strings
        @returns: element name
        @rtype: deferred -> list of strings
        """
        if not self._adminModel:
            self.debug('No admin connected, not checking presence of elements')
            return

        self.debug('requiring elements %r' % (elementNames, ))
        f = ngettext(
            "Checking the existence of GStreamer element '%s' "
            "on %s worker.",
            "Checking the existence of GStreamer elements '%s' "
            "on %s worker.", len(elementNames))
        msg = messages.Info(T_(f, "', '".join(elementNames), workerName),
                            mid='require-elements')

        self.add_msg(msg)

        def gotMissingElements(elements, workerName):
            self.clear_msg('require-elements')

            if elements:
                self.warning('elements %r do not exist' % (elements, ))
                f = ngettext(
                    "Worker '%s' is missing GStreamer element '%s'.",
                    "Worker '%s' is missing GStreamer elements '%s'.",
                    len(elements))
                message = messages.Error(
                    T_(f, workerName, "', '".join(elements)))
                message.add(
                    T_(
                        N_("\n"
                           "Please install the necessary GStreamer plug-ins that "
                           "provide these elements and restart the worker.")))
                message.add(
                    T_(
                        N_("\n\n"
                           "You will not be able to go forward using this worker."
                           )))
                message.id = 'element' + '-'.join(elementNames)
                documentation.messageAddGStreamerInstall(message)
                self.add_msg(message)
            self.taskFinished(bool(elements))
            return elements

        self.waitForTask('require elements %r' % (elementNames, ))
        d = self.checkElements(workerName, *elementNames)
        d.addCallback(gotMissingElements, workerName)

        return d

    def checkImport(self, workerName, moduleName):
        """Check if the given module can be imported.
        @param workerName:  name of the worker to check on
        @type workerName: string
        @param moduleName:  name of the module to import
        @type moduleName: string
        @returns: a deferred firing None or Failure.
        @rtype: L{twisted.internet.defer.Deferred}
        """
        if not self._adminModel:
            self.debug('No admin connected, not checking presence of elements')
            return

        d = self._adminModel.checkImport(workerName, moduleName)
        return d

    def requireImport(self,
                      workerName,
                      moduleName,
                      projectName=None,
                      projectURL=None):
        """Require that the given module can be imported on the given worker.
        If the module cannot be imported, an error message is
        posted and the next button remains blocked.
        @param workerName:  name of the worker to check on
        @type workerName: string
        @param moduleName:  name of the module to import
        @type moduleName: string
        @param projectName: name of the module to import
        @type projectName: string
        @param projectURL:  URL of the project
        @type projectURL: string
        @returns: a deferred firing None or Failure
        @rtype: L{twisted.internet.defer.Deferred}
        """
        if not self._adminModel:
            self.debug('No admin connected, not checking presence of elements')
            return

        self.debug('requiring module %s' % moduleName)

        def _checkImportErrback(failure):
            self.warning('could not import %s', moduleName)
            message = messages.Error(
                T_(N_("Worker '%s' cannot import module '%s'."), workerName,
                   moduleName))
            if projectName:
                message.add(
                    T_(N_("\n"
                          "This module is part of '%s'."), projectName))
            if projectURL:
                message.add(
                    T_(N_("\n"
                          "The project's homepage is %s"), projectURL))
            message.add(
                T_(
                    N_("\n\n"
                       "You will not be able to go forward using this worker.")
                ))
            message.id = 'module-%s' % moduleName
            documentation.messageAddPythonInstall(message, moduleName)
            self.add_msg(message)
            self.taskFinished(blockNext=True)
            return False

        d = self.checkImport(workerName, moduleName)
        d.addErrback(_checkImportErrback)
        return d

    # FIXME: maybe add id here for return messages ?

    def runInWorker(self, workerName, moduleName, functionName, *args,
                    **kwargs):
        """
        Run the given function and arguments on the selected worker.
        The given function should return a L{messages.Result}.

        @param workerName:   name of the worker to run the function in
        @type  workerName:   string
        @param moduleName:   name of the module where the function is found
        @type  moduleName:   string
        @param functionName: name of the function to run
        @type  functionName: string

        @returns: a deferred firing the Result's value.
        @rtype: L{twisted.internet.defer.Deferred}
        """
        self.debug('runInWorker(moduleName=%r, functionName=%r)' %
                   (moduleName, functionName))
        admin = self._adminModel
        if not admin:
            self.warning('skipping runInWorker, no admin')
            return defer.fail(errors.FlumotionError('no admin'))

        if not workerName:
            self.warning('skipping runInWorker, no worker')
            return defer.fail(errors.FlumotionError('no worker'))

        def callback(result):
            self.debug('runInWorker callbacked a result')
            self.clear_msg(functionName)

            if not isinstance(result, messages.Result):
                msg = messages.Error(T_(
                    N_("Internal error: could not run check code on worker.")),
                                     debug=(
                                         'function %r returned a non-Result %r'
                                         % (functionName, result)))
                self.add_msg(msg)
                self.taskFinished(True)
                raise errors.RemoteRunError(functionName, 'Internal error.')

            for m in result.messages:
                self.debug('showing msg %r' % m)
                self.add_msg(m)

            if result.failed:
                self.debug('... that failed')
                self.taskFinished(True)
                raise errors.RemoteRunFailure(functionName, 'Result failed')
            self.debug('... that succeeded')
            self.taskFinished()
            return result.value

        def errback(failure):
            self.debug('runInWorker errbacked, showing error msg')
            if failure.check(errors.RemoteRunError):
                debug = failure.value
            else:
                debug = "Failure while running %s.%s:\n%s" % (
                    moduleName, functionName, failure.getTraceback())

            msg = messages.Error(T_(
                N_("Internal error: could not run check code on worker.")),
                                 debug=debug)
            self.add_msg(msg)
            self.taskFinished(True)
            raise errors.RemoteRunError(functionName, 'Internal error.')

        self.waitForTask('run in worker: %s.%s(%r, %r)' %
                         (moduleName, functionName, args, kwargs))
        d = admin.workerRun(workerName, moduleName, functionName, *args,
                            **kwargs)
        d.addErrback(errback)
        d.addCallback(callback)
        return d

    def getWizardEntry(self, componentType):
        """Fetches a assistant bundle from a specific kind of component
        @param componentType: the component type to get the assistant entry
          bundle from.
        @type componentType: string
        @returns: a deferred returning either::
          - factory of the component
          - noBundle error: if the component lacks a assistant bundle
        @rtype: L{twisted.internet.defer.Deferred}
        """
        self.waitForTask('get assistant entry %s' % (componentType, ))
        self.clear_msg('assistant-bundle')
        d = self._adminModel.callRemote('getEntryByType', componentType,
                                        'wizard')
        d.addCallback(self._gotEntryPoint)
        return d

    def getWizardScenario(self, scenarioType):
        """
        Fetches a scenario bundle from a specific kind of component.

        @param scenarioType: the scenario type to get the assistant entry
          bundle from.
        @type scenarioType: string
        @returns: a deferred returning either::
          - factory of the component
          - noBundle error: if the component lacks a assistant bundle
        @rtype: L{twisted.internet.defer.Deferred}
        """
        self.waitForTask('get assistant entry %s' % (scenarioType, ))
        self.clear_msg('assistant-bundle')
        d = self._adminModel.callRemote('getScenarioByType', scenarioType,
                                        'wizard')
        d.addCallback(self._gotEntryPoint)
        return d

    def getWizardPlugEntry(self, plugType):
        """Fetches a assistant bundle from a specific kind of plug
        @param plugType: the plug type to get the assistant entry
          bundle from.
        @type plugType: string
        @returns: a deferred returning either::
          - factory of the plug
          - noBundle error: if the plug lacks a assistant bundle
        @rtype: L{twisted.internet.defer.Deferred}
        """
        self.waitForTask('get assistant plug %s' % (plugType, ))
        self.clear_msg('assistant-bundle')
        d = self._adminModel.callRemote('getPlugEntry', plugType, 'wizard')
        d.addCallback(self._gotEntryPoint)
        return d

    def getWizardEntries(self, wizardTypes=None, provides=None, accepts=None):
        """Queries the manager for a list of assistant entries matching the
        query.
        @param wizardTypes: list of component types to fetch, is usually
                            something like ['video-producer'] or
                            ['audio-encoder']
        @type  wizardTypes: list of str
        @param provides:    formats provided, eg ['jpeg', 'speex']
        @type  provides:    list of str
        @param accepts:     formats accepted, eg ['theora']
        @type  accepts:     list of str

        @returns: a deferred firing a list
                  of L{flumotion.common.componentui.WizardEntryState}
        @rtype: L{twisted.internet.defer.Deferred}
        """
        self.debug('querying wizard entries (wizardTypes=%r,provides=%r'
                   ',accepts=%r)' % (wizardTypes, provides, accepts))
        return self._adminModel.getWizardEntries(wizardTypes=wizardTypes,
                                                 provides=provides,
                                                 accepts=accepts)

    def setExistingComponentNames(self, componentNames):
        """Tells the assistant about the existing components available, so
        we can resolve naming conflicts when saving the configuration
        @param componentNames: existing component names
        @type componentNames: list of strings
        """
        self._existingComponentNames = componentNames

    def workerChangedForStep(self, step, workerName):
        """Tell a step that its worker changed.
        @param step: step which worker changed for
        @type step: a L{WorkerWizardStep} subclass
        @param workerName: name of the worker
        @type workerName: string
        """
        if self._stepWorkers.get(step) == workerName:
            return

        self.debug('calling %r.workerChanged' % step)
        step.workerChanged(workerName)
        self._stepWorkers[step] = workerName

    # Private

    def _gotEntryPoint(self, (filename, procname)):
        # The manager always returns / as a path separator, replace them with
        # the separator since the rest of our infrastructure depends on that.
        filename = filename.replace('/', os.path.sep)
        modname = pathToModuleName(filename)
        d = self._adminModel.getBundledFunction(modname, procname)
        self.clear_msg('assistant-bundle')
        self.taskFinished()
        return d
Exemplo n.º 12
0
    function = plug.entries['default'].function
    normalizedClass = function.lower()
    if normalizedType != normalizedClass:
        plugError(plug, 'type %s does not match class %s' % (
            plug.type, function))

    # a plug's socket should be creatable
    try:
        function = reflect.namedAny(plug.socket)
    except AttributeError:
        plugError(plug, 'could not import socket %s' % plug.socket)


    # a plug should be creatable
    for name, entry in plug.entries.items():
        moduleName = common.pathToModuleName(entry.location)
        entryPoint = "%s.%s" % (moduleName, entry.function)
        try:
            function = reflect.namedAny(entryPoint)
        except AttributeError:
            plugError(plug, 'could not import plug %s' % entryPoint)

    def propertyError(plug, p, msg):
        global exitCode
        sys.stderr.write("Property %s on plug %s from %s %s.\n" %(
                p.name, plug.type, plug.filename, msg))
        exitCode += 1

    for p in plug.getProperties():
        if p.name != p.name.lower():
            propertyError(plug, p, "contains capitals")
Exemplo n.º 13
0
    sys.stderr.write("Plug %s from %s %s.\n" % (
            p.type, p.filename, msg))
    exitCode += 1

for plug in registry.getPlugs():
    if plug.type != plug.type.lower():
        plugError(plug, 'contains capitals')
    if plug.type.find('_') > -1:
        plugError(plug, 'contains underscores')
    if not plug.description:
        plugError(plug, 'is missing a description')


    # a plug should be creatable
    for name, entry in plug.entries.items():
        moduleName = common.pathToModuleName(entry.location)
        entryPoint = "%s.%s" % (moduleName, entry.function)
        try:
            function = reflect.namedAny(entryPoint)
        except AttributeError:
            plugError(plug, 'could not import plug %s' % entryPoint)

    def propertyError(plug, p, msg):
        global exitCode
        sys.stderr.write("Property %s on plug %s from %s %s.\n" %(
                p.name, plug.type, plug.filename, msg))
        exitCode += 1

    for p in plug.getProperties():
        if p.name != p.name.lower():
            propertyError(plug, p, "contains capitals")