Example #1
0
    def errbackResult(failure):
        log.debug('check', 'returning failed Result, %r' % failure)
        m = None
        if failure.check(errors.GStreamerGstError):
            source, gerror, debug = failure.value.args
            log.debug('check', 'GStreamer GError: %s (debug: %s)' % (
                gerror.message, debug))
            if gerror.domain == "gst-resource-error-quark":
                if gerror.code == int(gst.RESOURCE_ERROR_NOT_FOUND):
                    # dv1394src was fixed after gst-plugins-good 0.10.2
                    # to distinguish NOT_FOUND and OPEN_READ
                    version = gstreamer.get_plugin_version('1394')
                    if version >= (0, 10, 0, 0) and version <= (0, 10, 2, 0):
                        m = messages.Error(T_(
                            N_("Could not find or open the Firewire device. "
                               "Check the device node and its permissions.")))
                    else:
                        m = messages.Error(T_(
                            N_("No Firewire device found.")))
                elif gerror.code == int(gst.RESOURCE_ERROR_OPEN_READ):
                    m = messages.Error(T_(
                        N_("Could not open Firewire device for reading. "
                           "Check permissions on the device.")))

            if not m:
                m = check.handleGStreamerDeviceError(failure, 'Firewire',
                    mid=mid)

        if not m:
            m = messages.Error(T_(N_("Could not probe Firewire device.")),
                debug=check.debugFailure(failure))

        m.id = mid
        result.add(m)
        return result
Example #2
0
    def check_properties(self, props, addMessage):
        props = self.config['properties']
        rotateType = props.get('rotate-type', 'none')

        if not rotateType in ['none', 'size', 'time']:
            msg = messages.Error(T_(
                N_("The configuration property 'rotate-type' should be set to "
                   "'size', time', or 'none', not '%s'. "
                   "Please fix the configuration."), rotateType),
                                 mid='rotate-type')
            addMessage(msg)
            raise errors.ConfigError(msg)

        if rotateType in ['size', 'time']:
            if rotateType not in props.keys():
                msg = messages.Error(T_(
                    N_("The configuration property '%s' should be set. "
                       "Please fix the configuration."), rotateType),
                                     mid='rotate-type')
                addMessage(msg)
                raise errors.ConfigError(msg)

            if props[rotateType] == 0:
                msg = messages.Error(T_(N_("Configuration error: " \
                    "'rotate-type' %s value cannot be set to 0."),
                    rotateType), mid='rotate-type')
                addMessage(msg)
                raise errors.ConfigError(msg)
Example #3
0
def checkPlugin(pluginName, packageName, minimumVersion=None,
                featureName=None, featureCheck=None):
    """
    Check if the given plug-in is available.
    Return a result with an error if it is not, or not new enough.

    @param pluginName: name of the plugin to check
    @param packageName: name of the package to tell the user to install
    if the check fails
    @param minimumVersion: minimum version of the plugin, as a tuple.
    Optional.
    @param featureName: name of a specific feature to check for in the
    plugin. Optional. Overrides the minimum version check, if given.
    @param featureCheck: function to call on the found feature, which
    should return a boolean representing whether the feature is good or
    not. Optional, and only makes sense if you specify featureName.
    @rtype: L{messages.Result}
    """
    result = messages.Result()
    version = gstreamer.get_plugin_version(pluginName)

    if not version:
        m = messages.Error(T_(
            N_("This host is missing the '%s' GStreamer plug-in.\n"),
                pluginName))
        m.add(T_(N_(
            "Please install '%s'.\n"), packageName))
        documentation.messageAddGStreamerInstall(m)
        result.add(m)
    elif featureName:
        r = gst.registry_get_default()
        features = r.get_feature_list_by_plugin(pluginName)
        byname = dict([(f.get_name(), f) for f in features])
        if (featureName not in byname
            or (featureCheck and not featureCheck(byname[featureName]))):
            m = messages.Error(T_(
                N_("Your '%s' GStreamer plug-in is too old.\n"), pluginName),
                mid = 'plugin-%s-check' % pluginName)
            m.add(T_(N_(
                "Please upgrade '%s' to version %s or higher."),
                packageName, ".".join([str(x) for x in minimumVersion])))
            documentation.messageAddGStreamerInstall(m)
            result.add(m)
    elif version < minimumVersion:
        m = messages.Error(T_(
            N_("Version %s of the '%s' GStreamer plug-in is too old.\n"),
               ".".join([str(x) for x in version]), pluginName),
            mid = 'plugin-%s-check' % pluginName)
        m.add(T_(N_(
            "Please upgrade '%s' to version %s."), packageName,
               ".".join([str(x) for x in minimumVersion])))
        documentation.messageAddGStreamerInstall(m)
        result.add(m)

    result.succeed(None)
    return defer.succeed(result)
Example #4
0
            def haveResult(res):
                if not termtimeout.active():
                    self.info("Discarding error %s", res)
                    res = messages.Result()
                    res.add(
                        messages.Error(T_(N_("Check timed out.")),
                                       debug=("Timed out running %s." %
                                              methodName)))
                else:

                    def expire():
                        if (job, expireDC) in self.jobPool:
                            self.debug('stopping idle check job process %s',
                                       job.avatarId)
                            self.jobPool.remove((job, expireDC))
                            job.mindCallRemote('stop')

                    expireDC = reactor.callLater(self._timeout, expire)
                    self.jobPool.append((job, expireDC))

                if termtimeout.active():
                    termtimeout.cancel()
                if killtimeout.active():
                    killtimeout.cancel()
                return res
Example #5
0
    def make_message_for_gstreamer_error(self, gerror, debug):
        """Make a flumotion error message to show to the user.

        This method may be overridden by components that have special
        knowledge about potential errors. If the component does not know
        about the error, it can chain up to this implementation, which
        will make a generic message.

        @param gerror: The GError from the error message posted on the
                       GStreamer message bus.
        @type  gerror: L{gst.GError}
        @param  debug: A string with debugging information.
        @type   debug: str

        @returns: A L{flumotion.common.messages.Message} to show to the
                 user.
        """
        # generate a unique id
        mid = "%s-%s-%d" % (self.name, gerror.domain, gerror.code)
        m = messages.Error(T_(N_("Internal GStreamer error.")),
                           debug="%s\n%s: %d\n%s" %
                           (gerror.message, gerror.domain, gerror.code, debug),
                           mid=mid,
                           priority=40)
        return m
Example #6
0
    def errbackAlsaBugResult(failure, result, mid, device):
        # alsasrc in gst-plugins-base <= 0.10.14 was accidentally reporting
        # GST_RESOURCE_ERROR_WRITE when it could not be opened for reading.
        if not failure.check(errors.GStreamerGstError):
            return failure
        if source_factory != 'alsasrc':
            return failure
        version = gstreamer.get_plugin_version('alsasrc')
        if version > (0, 10, 14):
            return failure

        source, gerror, debug = failure.value.args
        log.debug(
            'check', 'GStreamer GError: %s (domain %s, code %d, debug %s)' %
            (gerror.message, gerror.domain, gerror.code, debug))

        if gerror.domain == "gst-resource-error-quark":
            if gerror.code == int(gst.RESOURCE_ERROR_OPEN_WRITE):
                m = messages.Error(
                    T_(
                        N_("Could not open device '%s' for reading.  "
                           "Check permissions on the device."), device))
                result.add(m)
                return result

        return failure
Example #7
0
        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
Example #8
0
        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
Example #9
0
    def check_properties(self, props, addMessage):
        deintMode = props.get('deinterlace-mode', 'auto')
        deintMethod = props.get('deinterlace-method', 'ffmpeg')

        if deintMode not in deinterlace.DEINTERLACE_MODE:
            msg = messages.Error(T_(N_("Configuration error: '%s' " \
                "is not a valid deinterlace mode." % deintMode)))
            addMessage(msg)
            raise errors.ConfigError(msg)

        if deintMethod not in deinterlace.DEINTERLACE_METHOD:
            msg = messages.Error(T_(N_("Configuration error: '%s' " \
                "is not a valid deinterlace method." % deintMethod)))
            self.debug("'%s' is not a valid deinterlace method", deintMethod)
            addMessage(msg)
            raise errors.ConfigError(msg)
Example #10
0
 def buffer_probe_cb(self, pad, buffer, depay, eaterAlias):
     pad = depay.get_pad("src")
     caps = pad.get_negotiated_caps()
     if not caps:
         return False
     srcpad_to_link = self.get_eater_srcpad(eaterAlias)
     muxer = self.pipeline.get_by_name("muxer")
     self.debug("Trying to get compatible pad for pad %r with caps %s",
                srcpad_to_link, caps)
     linkpad = self.get_link_pad(muxer, srcpad_to_link, caps)
     if not linkpad:
         m = messages.Error(
             T_(N_("The incoming data is not compatible with this muxer.")),
             debug="Caps %s not compatible with this muxer." %
             (caps.to_string()))
         self.addMessage(m)
         # this is the streaming thread, cannot set state here
         # so we do it in the mainloop
         reactor.callLater(0, self.pipeline.set_state, gst.STATE_NULL)
         return True
     self.debug("Got link pad %r", linkpad)
     srcpad_to_link.link(linkpad)
     depay.get_pad("src").remove_buffer_probe(self._probes[eaterAlias])
     if srcpad_to_link.is_blocked():
         self.is_blocked_cb(srcpad_to_link, True)
     else:
         srcpad_to_link.set_blocked_async(True, self.is_blocked_cb)
     return True
Example #11
0
 def missingModule(moduleName):
     m = messages.Error(T_(N_(
         "To use the iCalendar bouncer you need to have "
         "the '%s' module installed.\n"), moduleName),
                        mid='error-python-%s' % moduleName)
     documentation.messageAddPythonInstall(m, moduleName)
     component.addMessage(m)
Example #12
0
 def missingModule(moduleName):
     m = messages.Error(T_(
         N_("An iCal file has been specified for scheduling, "
            "but the '%s' module is not installed.\n"), moduleName),
                        mid='error-python-%s' % moduleName)
     documentation.messageAddPythonInstall(m, moduleName)
     self.debug(m)
     self.addMessage(m)
Example #13
0
 def check_algorithms(self, algorithms):
     if not algorithms:
         m = messages.Error(T_(
             N_("The multibouncer requires at least one bouncer "
                "algorithm plug to be present")),
                            mid='no-algorithm')
         self.addMessage(m)
         raise errors.ComponentSetupHandledError()
Example #14
0
 def check_properties(self, properties, addMessage):
     media_type = properties.get("media-type")
     if media_type not in ["audio", "video"]:
         msg = 'Property media-type can only be "audio" or "video"'
         m = messages.Error(T_(N_(msg)), mid="error-decoder-media-type")
         addMessage(m)
     else:
         self._media_type = media_type
Example #15
0
 def make_message_for_gstreamer_error(self, gerror, debug):
     if gerror.domain == 'gst-resource-error-quark':
         return messages.Error(T_(N_(
             "Could not open file '%s' for reading."), self.filelocation),
             debug='%s\n%s' % (gerror.message, debug),
             mid=gerror.domain, priority=40)
     base = feedcomponent.ParseLaunchComponent
     return base.make_message_for_gstreamer_error(self, gerror, debug)
Example #16
0
            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)
Example #17
0
 def check_gnl(element):
     exists = gstreamer.element_factory_exists(element)
     if not exists:
         m = messages.Error(
             T_(
                 N_("%s is missing. Make sure your gnonlin "
                    "installation is complete."), element))
         documentation.messageAddGStreamerInstall(m)
         self.debug(m)
         self.addMessage(m)
Example #18
0
    def check_properties(self, props, addMessage):
        props = self.config['properties']
        speed = props.get('speed', 3)

        if speed > 3:
            msg = messages.Error(T_(N_(
                "The configuration property 'speed' can only take "
                "values from 0 to 3")), mid='speed')
            addMessage(msg)
            raise errors.ConfigError(msg)
Example #19
0
    def do_setup(self):
        root = self._get_root()
        self._site = self.siteClass(resource=root)
        if self.type == 'slave':
            # Streamer is slaved to a porter.

            # We have two things we want to do in parallel:
            #  - ParseLaunchComponent.do_start()
            #  - log in to the porter, then register our mountpoint with
            #    the porter.
            # So, we return a DeferredList with a deferred for each of
            # these tasks. The second one's a bit tricky: we pass a dummy
            # deferred to our PorterClientFactory that gets fired once
            # we've done all of the tasks the first time (it's an
            # automatically-reconnecting client factory, and we only fire
            # this deferred the first time)

            self._porterDeferred = d = defer.Deferred()
            mountpoints = [self.mountPoint]
            if self.multi_files:
                self._pbclient = porterclient.HTTPPorterClientFactory(
                    self._site, [], d, prefixes=mountpoints)
            else:
                self._pbclient = porterclient.HTTPPorterClientFactory(
                    self._site, mountpoints, d)

            creds = credentials.UsernamePassword(self._porterUsername,
                                                 self._porterPassword)
            self._pbclient.startLogin(creds, self._pbclient.medium)

            self.info("Starting porter login at \"%s\"", self._porterPath)
            # This will eventually cause d to fire
            reactor.connectWith(fdserver.FDConnector,
                                self._porterPath,
                                self._pbclient,
                                10,
                                checkPID=False)
        else:
            # Streamer is standalone.
            try:
                iface = self.iface or ""
                self.info('Listening on port %d, interface=%r', self.port,
                          iface)
                self._tport = reactor.listenTCP(self.port,
                                                self._site,
                                                interface=iface)
            except error.CannotListenError:
                t = 'Port %d is not available.' % self.port
                self.warning(t)
                m = messages.Error(
                    T_(N_("Network error: TCP port %d is not available."),
                       self.port))
                self.addMessage(m)
                self.setMood(moods.sad)
                return defer.fail(errors.ComponentSetupHandledError(t))
Example #20
0
    def _checkMountPoint(self,
                         port=None,
                         worker=None,
                         mount_point=None,
                         need_fix=False):
        """
        Checks whether the provided mount point is available with the
        current configuration (port, worker). It can provide a valid
        mountpoint if it is required with need_fix=True.

        @param port : The port the streamer is going to be listening.
        @type  port : int
        @param worker : The worker the streamer will be running.
        @type  worker : str
        @param mount_point : The desired mount point.
        @type  mount_point : str
        @param need_fix : Whether the method should search for a valid
                          mount_point if the provided one is not.
        @type  need_fix : bool

        @returns : True if the mount_point can be used, False if it is in use.
        @rtype   : bool
        """
        self.wizard.clear_msg('http-streamer-mountpoint')

        port = port or self.model.port
        worker = worker or self.model.worker
        mount_point = mount_point or self.model.properties.mount_point

        self.wizard.waitForTask('http-streamer-mountpoint')

        if self.wizard.addMountPoint(worker, port, mount_point,
                                     self.getConsumerType()):
            self.wizard.taskFinished()
            return True
        else:
            if need_fix:
                while not self.wizard.addMountPoint(worker, port, mount_point,
                                                    self.getConsumerType()):
                    mount_point = self._suggestMountPoint(mount_point)

                self.model.properties.mount_point = mount_point
                self._proxy1.update('mount_point')
                self.wizard.taskFinished()
                return True

            message = messages.Error(
                T_(
                    N_("The mount point %s is already being used for worker %s and "
                       "port %s. Please correct this to be able to go forward."
                       ), mount_point, worker, port))
            message.id = 'http-streamer-mountpoint'
            self.wizard.add_msg(message)
            self.wizard.taskFinished(True)
            return False
Example #21
0
 def checkConfig(result):
     props = self.config['properties']
     eaterName = props.get('eater-with-stream-markers', None)
     if eaterName != 'video-master' and eaterName != 'video-backup':
         warnStr = N_("The value provided for the " \
             "eater-with-stream-markers property " \
             "must be one of video-backup, video-master.")
         self.warning(warnStr)
         self.addMessage(messages.Error(T_(N_(warnStr)),
             mid="eater-with-stream-markers-wrong"))
     return result
Example #22
0
 def check_limit(prop_name, lower_limit, upper_limit):
     val = props.get(prop_name, None)
     if val is None:
         return
     if val < lower_limit or val > upper_limit:
         msg = messages.Error(T_(N_(
             "The configuration property '%s' can only take "
             "values from %d to %d"),
             prop_name, lower_limit, upper_limit), mid='config')
         addMessage(msg)
         raise errors.ConfigError(msg)
Example #23
0
    def _client_error_cb(self):
        self.file.close()
        self.file = None

        self.setMood(moods.sad)
        messageId = "error-writing-%s" % self.location
        m = messages.Error(T_(N_("Error writing to file '%s'."),
                              self.location),
                           mid=messageId,
                           priority=40)
        self.addMessage(m)
 def testSerialize(self):
     text = N_("Something is really wrong.")
     self.cmsg = messages.Error(T_(text))
     self.mmsg = jelly.unjelly(jelly.jelly(self.cmsg))
     t = self.mmsg.translatables[0]
     self.assertEquals(t.format, "Something is really wrong.")
     self.assertEquals(self.mmsg.level, messages.ERROR)
     self.amsg = jelly.unjelly(jelly.jelly(self.mmsg))
     t = self.amsg.translatables[0]
     self.assertEquals(t.format, "Something is really wrong.")
     self.assertEquals(self.amsg.level, messages.ERROR)
Example #25
0
    def testTranslateMessage(self):
        cmsg = messages.Error(T_(N_("Something is really wrong. ")))
        t = T_(N_("But does %s know what ?"), "Andy")
        cmsg.add(t)
        mmsg = jelly.unjelly(jelly.jelly(cmsg))

        translator = Translator()
        localedir = os.path.join(configure.localedatadir, 'locale')
        translator.addLocaleDir(configure.PACKAGE, localedir)

        text = translator.translate(mmsg, lang=["nl_NL"])
        self.assertEquals(text, "Er is iets echt mis. Maar weet Andy wat ?")
Example #26
0
 def create_pipeline(self):
     try:
         unparsed = self.get_pipeline_string(self.config['properties'])
     except errors.MissingElementError, e:
         self.warning('Missing %s element' % e.args[0])
         m = messages.Error(
             T_(
                 N_("The worker does not have the '%s' element installed.\n"
                    "Please install the necessary plug-in and restart "
                    "the component.\n"), e.args[0]))
         self.addMessage(m)
         raise errors.ComponentSetupHandledError(e)
Example #27
0
class IcalBouncerAlgorithm(base.BouncerAlgorithm):

    logCategory = 'icalbouncer'
    events = []
    maxKeyCardDuration = timedelta(days=1)

    def get_namespace(self):
        return 'icalbouncer'

    def start(self, component):
        self.props = self.args['properties']
        self.iCalScheduler = None
        self.subscriptionToken = None
        self.check_properties(component)
        self.setup(component)

    def check_properties(self, component):

        def missingModule(moduleName):
            m = messages.Error(T_(N_(
                "To use the iCalendar bouncer you need to have "
                "the '%s' module installed.\n"), moduleName),
                               mid='error-python-%s' % moduleName)
            documentation.messageAddPythonInstall(m, moduleName)
            component.addMessage(m)

        if not eventcalendar.HAS_ICALENDAR:
            missingModule('icalendar')
        if not eventcalendar.HAS_DATEUTIL:
            missingModule('dateutil')

    def setup(self, component):
        self._icsfile = self.props['file']

        try:
            handle = open(self._icsfile, 'r')
        except IOError, e:
            m = messages.Error(T_(N_(
                "Failed to open iCalendar file '%s'. "
                "Check permissions on that file."), self._icsfile),
                               mid='error-icalbouncer-file')
            component.addMessage(m)
            raise errors.ComponentSetupHandledError()

        try:
            self.iCalScheduler = scheduler.ICalScheduler(handle)
        except (ValueError, IndexError, KeyError), e:
            m = messages.Error(T_(N_(
                "Error parsing ical file '%s'."), self._icsfile),
                               debug=log.getExceptionMessage(e),
                               mid="error-icalbouncer-file")
            component.addMessage(m)
            raise errors.ComponentSetupHandledError()
    def testSerializeWithError(self):
        wresult = messages.Result()
        wresult.add(messages.Error(T_(N_("uh oh"))))

        mresult = jelly.unjelly(jelly.jelly(wresult))
        self.failUnless(mresult.failed)
        self.assertEquals(mresult.value, None)
        m = mresult.messages[0]
        self.assertEquals(m.level, messages.ERROR)
        text = self.translator.translate(
            m, lang=["nl_NL", ])
        self.assertEquals(text, "o jeetje")
Example #29
0
    def setup(self, component):
        self._icsfile = self.props['file']

        try:
            handle = open(self._icsfile, 'r')
        except IOError, e:
            m = messages.Error(T_(N_(
                "Failed to open iCalendar file '%s'. "
                "Check permissions on that file."), self._icsfile),
                               mid='error-icalbouncer-file')
            component.addMessage(m)
            raise errors.ComponentSetupHandledError()
Example #30
0
        def got_error(failure):
            txt = log.getFailureMessage(failure)
            self.debug('got_error: %s', txt)
            if not failure.check(errors.ComponentSetupHandledError):
                self.warning('Setup failed: %s', txt)
                m = messages.Error(T_(N_("Could not setup component.")),
                                   debug=txt,
                                   mid="component-setup-%s" % self.name)
                # will call setMood(moods.sad)
                self.addMessage(m)

            # swallow
            return None