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)
def configure_pipeline(self, pipeline, properties): def notify_pattern(obj, pspec): self.uiState.set('pattern', int(obj.get_property('pattern'))) source = self.get_element('source') source.connect('notify::pattern', notify_pattern) if 'pattern' in properties: source.set_property('pattern', properties['pattern']) if 'drop-probability' in properties: vt = gstreamer.get_plugin_version('coreelements') if not vt: raise errors.MissingElementError('identity') if not vt > (0, 10, 12, 0): self.addMessage( messages.Warning( T_( N_("The 'drop-probability' property is specified, but " "it only works with GStreamer core newer than 0.10.12." " You should update your version of GStreamer.") ))) else: drop_probability = properties['drop-probability'] if drop_probability < 0.0 or drop_probability > 1.0: self.addMessage( messages.Warning( T_( N_("The 'drop-probability' property can only be " "between 0.0 and 1.0.")))) else: identity = self.get_element('identity') identity.set_property('drop-probability', drop_probability)
def _bus_message_received_cb(self, bus, message): """ @param bus: the message bus sending the message @param message: the message received """ if message.structure.get_name() == "ieee1394-bus-reset": # we have a firewire bus reset s = message.structure # current-device-change is only in gst-plugins-good >= 0.10.3 if 'current-device-change' in s.keys(): if s['current-device-change'] != 0: # we actually have a connect or disconnect of the camera # so first remove all the previous messages warning about a # firewire-bus-reset for m in self.state.get('messages'): if m.id.startswith('firewire-bus-reset'): self.state.remove('messages', m) if s['current-device-change'] == 1: # connected m = messages.Info(T_(N_( "The camera has now been reconnected.")), mid="firewire-bus-reset-%d" % s['nodecount'], priority=40) self.state.append('messages', m) elif s['current-device-change'] == -1: # disconnected m = messages.Warning(T_(N_( "The camera has been disconnected.")), mid="firewire-bus-reset-%d" % s['nodecount'], priority=40) self.state.append('messages', m)
def _set_source_image(self, width, height): imgBuf, imagesOverflowed, textOverflowed = \ genimg.generateOverlay( text=self.text, font=self.font, showFlumotion=self.showFlumotion, showCC=self.showCC, showXiph=self.showXiph, width=width, height=height) if textOverflowed: m = messages.Warning(T_( N_("Overlayed text '%s' too wide for the video image."), self.text), mid="text-too-wide") self.addMessage(m) if imagesOverflowed: m = messages.Warning(T_( N_("Overlayed logotypes too wide for the video image.")), mid="image-too-wide") self.addMessage(m) if self.source.get_factory().get_name() == 'appsrc': self.imgBuf = imgBuf else: self.source.imgBuf = imgBuf
def checkTicket347(): """ Check for a recent enough PyGTK to not leak python integers in message processing (mostly affects soundcard, firewire) """ result = messages.Result() import pygtk pygtk.require('2.0') import gobject # Really, we want to check for pygobject_version, but that doesn't exist in # all versions of pygtk, and this check is sufficient. (major, minor, nano) = gobject.pygtk_version if (major, minor, nano) < (2, 8, 6): m = messages.Warning(T_( N_("Version %d.%d.%d of the PyGTK library contains " "a memory leak.\n"), major, minor, nano), mid='ticket-347') m.add( T_( N_("The Soundcard and Firewire sources may leak a lot of " "memory as a result, and would need to be restarted " "frequently.\n"))) m.add( T_(N_("Please upgrade '%s' to version %s or later."), 'pygtk', '2.8.6')) result.add(m) result.succeed(None) return defer.succeed(result)
def get_pipeline_string(self, properties): dp = "" if 'drop-probability' in properties: vt = gstreamer.get_plugin_version('coreelements') if not vt: raise errors.MissingElementError('identity') if not vt > (0, 10, 12, 0): self.addMessage( messages.Warning( T_( N_("The 'drop-probability' property is specified, but " "it only works with GStreamer core newer than 0.10.12." " You should update your version of GStreamer.") ))) else: drop_probability = properties['drop-probability'] if drop_probability < 0.0 or drop_probability > 1.0: self.addMessage( messages.Warning( T_( N_("The 'drop-probability' property can only be " "between 0.0 and 1.0.")))) else: dp = " drop-probability=%f" % drop_probability return 'identity silent=true %s' % dp
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
def start(self, component): self._sid = None self.sched = None try: def eventStarted(eventInstance): self.debug("event started %r", eventInstance.event.uid) component.switch_to("backup") def eventEnded(eventInstance): self.debug("event ended %r", eventInstance.event.uid) component.switch_to("master") # if an event starts, semantics are to switch to backup # if an event ends, semantics are to switch to master filename = self.args['properties']['ical-schedule'] self.sched = scheduler.ICalScheduler(open(filename, 'r')) self._sid = self.sched.subscribe(eventStarted, eventEnded) if self.sched.getCalendar().getActiveEventInstances(): component.idealFeed = "backup" except ValueError: fmt = N_("Error parsing ical file %s, so not scheduling " "any events.") component.addWarning("error-parsing-ical", fmt, filename) except ImportError, e: fmt = N_("An ical file has been specified for scheduling, " "but the necessary modules are not installed.") component.addWarning("error-parsing-ical", fmt, debug=e.message)
def fixRenamedProperties(self, properties, list): """ Fix properties that have been renamed from a previous version, and add a warning for them. @param properties: properties; will be modified as a result. @type properties: dict @param list: list of (old, new) tuples of property names. @type list: list of tuple of (str, str) """ found = [] for old, new in list: if old in properties: found.append((old, new)) if found: m = messages.Warning(T_( N_("Your configuration uses deprecated properties. " "Please update your configuration and correct them.\n")), mid="deprecated") for old, new in found: m.add(T_(N_("Please rename '%s' to '%s'.\n"), old, new)) self.debug("Setting new property '%s' to %r", new, properties[old]) properties[new] = properties[old] del properties[old] self.addMessage(m)
def _formatClientCount(value): if isinstance(value, (int, long)): template = gettext.ngettext(N_("%d client"), N_("%d clients"), value) else: template = gettext.ngettext(N_("%.2f client"), N_("%.2f clients"), value) return template % value
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
def messageAddPythonInstall(message, moduleName): """ Add text and link on how to install the given python module to the given message. """ message.add(T_(N_("Please install the '%s' python module."), moduleName)) message.description = T_(N_("Learn how to install Python modules.")) message.section = 'appendix-installing-dependencies' message.anchor = 'section-installing-python-modules'
def formatTime(seconds, fractional=0): """ Nicely format time in a human-readable format, like 5 days 3 weeks HH:MM If fractional is zero, no seconds will be shown. If it is greater than 0, we will show seconds and fractions of seconds. As a side consequence, there is no way to show seconds without fractions) @param seconds: the time in seconds to format. @type seconds: int or float @param fractional: how many digits to show for the fractional part of seconds. @type fractional: int @rtype: string @returns: a nicely formatted time string. """ chunks = [] if seconds < 0: chunks.append(('-')) seconds = -seconds week = 60 * 60 * 24 * 7 weeks = seconds / week seconds %= week day = 60 * 60 * 24 days = seconds / day seconds %= day hour = 60 * 60 hours = seconds / hour seconds %= hour minute = 60 minutes = seconds / minute seconds %= minute if weeks >= 1: chunks.append(gettext.dngettext( configure.PACKAGE, N_('%d week'), N_('%d weeks'), weeks) % weeks) if days >= 1: chunks.append(gettext.dngettext( configure.PACKAGE, N_('%d day'), N_('%d days'), days) % days) chunk = _('%02d:%02d') % (hours, minutes) if fractional > 0: chunk += ':%0*.*f' % (fractional + 3, fractional, seconds) chunks.append(chunk) return " ".join(chunks)
def do_check(self): if gstreamer.get_plugin_version('multipart') <= (0, 10, 16, 0): m = messages.Warning( T_(N_("Versions up to and including %s of the '%s' " "GStreamer plug-in are not suitable for streaming.\n"), '0.10.16', 'multipart')) m.add(T_(N_("The stream served by the streamer component " "will probably be unplayable.\n"))) m.add(T_(N_("The issue will be addressed in version %s of '%s'."), '0.10.17', 'gst-plugins-good')) self.addMessage(m)
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
def _hasImport(self): """Check rrdtool availability""" if not rrdtool: m = messages.Warning(T_(N_("Cannot import module '%s'.\n"), 'rrdtool'), mid='rrdtool-import-error') m.add(T_(N_("The RRD plug for this component is disabled."))) self._component.addMessage(m) return False return True
def _gotEntries(self, entries, type, combo, default_type): data = [] default = None for entry in entries: if entry.componentType == default_type: default = entry continue data.append((N_(entry.description), entry.componentType)) assert default data.insert(0, (N_(default.description), default.componentType)) combo.prefill(data) combo.set_sensitive(True)
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 ?")
def check_schroenc_bug(result, component): if gstreamer.get_plugin_version('schro') == (1, 0, 7, 0): m = messages.Warning( T_(N_("Version %s of the '%s' GStreamer plug-in " "contains a bug.\n"), '1.0.7', 'schroenc')) m.add(T_(N_("The downstream components might stay hungry.\n"))) m.add(T_(N_("The bug has been fixed during the transition of " "'%s' to the '%s' plug-ins set. " "Please upgrade '%s' to version %s, " "which contains the fixed plug-in."), 'schroenc', 'gst-plugins-bad', 'schroenc', '0.10.14')) component.addMessage(m) return result
def importError(failure): failure.trap(ImportError) self.info('could not import twisted-web') message = messages.Warning(T_(N_( "Worker '%s' cannot import module '%s'."), self.worker, 'twisted.web')) message.add(T_(N_("\nThis module is part of the '%s'."), 'Twisted Project')) message.add(T_(N_("\nThe project's homepage is %s"), 'http://www.twistedmatrix.com/')) message.id = 'module-twisted-web' self.wizard.add_msg(message) self.wizard.taskFinished(True) return False
def check_properties(self, props, addMessage): streamer.Streamer.check_properties(self, props, addMessage) # tcp is where multifdsink is version = gstreamer.get_plugin_version('tcp') if version < (0, 10, 9, 1): m = messages.Error( T_( N_("Version %s of the '%s' GStreamer plug-in is too old.\n" ), ".".join(map(str, version)), 'multifdsink')) m.add( T_(N_("Please upgrade '%s' to version %s."), 'gst-plugins-base', '0.10.10')) addMessage(m)
def warnDeprecatedProperties(self, list): """ Add a warning messages for deprecated properties. @param list: list of property names. @type list: list of str """ msg = ("Your configuration uses deprecated properties. " "Please update your configuration and correct them.\n") m = messages.Warning(T_(N_(msg)), mid="deprecated") for prop in list: m.add(T_(N_("Please remove '%s' property.\n"), prop)) self.addMessage(m) self.warning(msg)
def messageAddGStreamerInstall(message): """ Add text and link on how to install the given python module to the given message. """ message.description = T_(N_('Learn how to install GStreamer elements.')) message.section = 'section-installing-gstreamer-plugins'
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
def _updateDevices(self): self.wizard.waitForTask('soundcard checks') self.wizard.clear_msg('soundcard-check') msg = Info(T_( N_("Looking for the sound devices present on the system. " "This can take a while...")), mid='soundcard-check') self.wizard.add_msg(msg) def checkFailed(failure): failure.trap(RemoteRunFailure) self.wizard.taskFinished(blockNext=True) self._blockCombos() def gotSoundDevices(devices): self.wizard.clear_msg('soundcard-check') self.wizard.taskFinished(False) self.device.set_sensitive(True) self.device.prefill(devices) sourceElement = self.source_element.get_selected() d = self.runInWorker('flumotion.worker.checks.audio', 'getAudioDevices', sourceElement, mid='soundcard-check') d.addCallback(gotSoundDevices) d.addErrback(checkFailed) return d
def switch_to(self, feed): """ @param feed: a logical feed """ if feed not in self.logicalFeeds: self.warning("unknown logical feed: %s", feed) return None self.debug('scheduling switch to feed %s', feed) self.idealFeed = feed # here we should bump this feed above others in feedsByPriority self.feedsByPriority = [feed] for name, aliases in self.get_logical_feeds(): if name != feed: self.feedsByPriority.append(name) if not self.pipeline: return if self.is_active(feed): self.do_switch() else: fmt = N_("Tried to switch to %s, but feed is unavailable. " "Will retry when the feed is back.") self.addWarning("temporary-switch-problem", fmt, feed)
def _updateInputtrack(self): device = self.device.get_selected() sourceElement = self.source_element.get_selected() if not device: return self.wizard.waitForTask('soundcard checks') msg = Info(T_(N_("Probing the sound card. This can take a while...")), mid='soundcard-check') self.wizard.add_msg(msg) def checkFailed(failure): failure.trap(RemoteRunFailure) self._blockCombos() self.wizard.taskFinished(True) def soundcardCheckComplete((deviceName, tracks, caps)): self.wizard.clear_msg('soundcard-check') self.wizard.taskFinished(False) self._caps = caps self.input_track.prefill(tracks) self.input_track.set_sensitive(bool(tracks)) d = self.runInWorker('flumotion.worker.checks.audio', 'checkMixerTracks', sourceElement, device, mid='soundcard-check') d.addCallback(soundcardCheckComplete) d.addErrback(checkFailed) return d
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 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)
def messageAddFixBadPermissions(message): """ Add link on how to change device permissions on Linux. """ message.description = T_(N_("Learn how to change device permissions.")) message.section = 'section-flumotion-troubleshoot' message.anchor = 'section-not-open'