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 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 _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 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 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 scheduleRecordings(self, icalFile): self.uiState.set('has-schedule', True) self.debug('Parsing iCalendar file %s' % icalFile) from flumotion.component.base import scheduler try: self.icalScheduler = scheduler.ICalScheduler(icalFile) self.icalScheduler.subscribe(self.eventInstanceStarted, self.eventInstanceEnded) # FIXME: this should be handled through the subscription # handlers; for that, we should subscribe before the calendar # gets added cal = self.icalScheduler.getCalendar() eventInstances = cal.getActiveEventInstances() if eventInstances: instance = eventInstances[0] content = instance.event.content self.info('Event %s is in progress, start recording' % content) self._startFilenameTemplate = content self._startTime = instance.start self._recordAtStart = True else: self.info('No events in progress') self._recordAtStart = False self._updateNextPoints() except (ValueError, IndexError, KeyError), e: m = messages.Warning(T_( N_("Error parsing ical file %s, so not scheduling any" " events." % icalFile)), debug=log.getExceptionMessage(e), mid="error-parsing-ical") self.addMessage(m)
def __init__(self, name, component, sourcePad, pipeline, width, height, is_square, add_borders=False, width_correction=8, height_correction=0): """ @param element: the video source element on which the post processing effect will be added @param pipeline: the pipeline of the element """ feedcomponent.PostProcEffect.__init__( self, name, sourcePad, VideoscaleBin(width, height, is_square, add_borders, width_correction, height_correction), pipeline) self.pipeline = pipeline self.component = component vt = gstreamer.get_plugin_version('videoscale') if not vt: raise errors.MissingElementError('videoscale') # 'add-borders' property was added in gst-plugins-base 0.10.29, # and it's requiered to respect DAR by adding black borders if not vt > (0, 10, 29, 0): self.component.addMessage( messages.Warning( T_( N_("The videoscale element correctly " "works with GStreamer base newer than 0.10.29.1." "You should update your version of GStreamer."))))
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 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 _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 configure_pipeline(self, pipeline, properties): self.fixRenamedProperties(properties, [ ('freq', 'frequency'), ]) element = self.get_element('source') if 'frequency' in properties: element.set_property('freq', properties['frequency']) self.uiState.set('frequency', properties['frequency']) 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) self.uiState.set('samplerate', self.samplerate) self.uiState.set('wave', int(element.get_property('wave'))) level = pipeline.get_by_name('level') vol = volume.Volume('volume', level, pipeline) self.addEffect(vol)
def testSerializeWithWarning(self): wresult = messages.Result() wresult.add(messages.Warning(T_(N_("Warning")))) wresult.succeed("I did it") mresult = jelly.unjelly(jelly.jelly(wresult)) self.failIf(mresult.failed) self.assertEquals(mresult.value, "I did it") m = mresult.messages[0] self.assertEquals(m.level, messages.WARNING) text = self.translator.translate( m, lang=["nl_NL", ]) self.assertEquals(text, "Waarschuwing")
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 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 _onMarkerStart(self, data): tmpl = self._defaultFilenameTemplate if self._markerPrefix: try: tmpl = '%s%s' % (self._markerPrefix % data, self._defaultFilenameTemplate) except TypeError, err: m = messages.Warning(T_( N_('Failed expanding filename prefix: ' '%r <-- %r.'), self._markerPrefix, data), mid='expand-marker-prefix') self.addMessage(m) self.warning('Failed expanding filename prefix: ' '%r <-- %r; %r' % (self._markerPrefix, data, err))
def configure_pipeline(self, pipeline, properties): element = pipeline.get_by_name('encoder') for p in ('qmin', 'qmax', 'threshold', 'keyframe'): if p in properties: element.set_property(p, properties[p]) jpegVersion = gstreamer.get_plugin_version('jpeg') if jpegVersion < (0, 10, 11, 1): m = messages.Warning( T_(N_("The 'smoke' encoder has a bug in versions previous " "to 0.10.11. It will not work unless it is updated.")), mid="smokeenc-bug") self.addMessage(m)
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 checkFileFinished(result): validFile, properties = result if not validFile: message = messages.Warning(T_(N_( "'%s' is not a valid file, " "or is not readable on worker '%s'.") % (location, self.worker))) message.id = 'looper-'+id+'-check' self.wizard.add_msg(message) else: self._updateFileProperties(properties) self.wizard.clear_msg('looper-'+id+'-check') self._blockNext[id] = False self.wizard.taskFinished() self._verify()
def errback(failure): msg = None if failure.check(errors.NoMethodError): msg = "Remote method '%s' does not exist." % methodName msg += "\n" + failure.value else: msg = log.getFailureMessage(failure) # FIXME: we probably need a nicer way of getting component # messages shown from the admin model, but this allows us to # make sure every type of admin has these messages self.warning(msg) m = messages.Warning(T_(N_("Internal error in component.")), debug=msg) componentState.observe_append('messages', m) return failure
def _getStats(self, fd): sink = self.get_element('fdsink') stats = sink.emit('get-stats', fd) if len(stats) <= 6: self.warning("The current version of multifdsink doesn't " "include the timestamp of the first and last " "buffers sent: the indexing will be disabled.") m = messages.Warning( T_( N_("Versions up to and including %s of the '%s' " "GStreamer plug-in can't be used to write index " "files.\n"), '0.10.30', 'multifdsink')) self.addMessage(m) self.writeIndex = False return None return stats
def importError(error): self.info('could not import cairo') message = messages.Warning( T_(N_("Worker '%s' cannot import module '%s'."), self.worker, 'cairo')) message.add(T_(N_("\nThis module is part of '%s'."), 'Pycairo')) message.add( T_(N_("\nThe project's homepage is %s"), 'http://www.cairographics.org/pycairo/')) message.add( T_(N_("\n\nClick \"Forward\" to proceed without overlay."))) message.id = 'module-cairo' documentation.messageAddPythonInstall(message, 'cairo') self.wizard.add_msg(message) self.wizard.taskFinished() self._setSensitive(False)
def checkPathFinished(pathExists): if not pathExists: message = messages.Warning( T_( N_("Directory '%s' does not exist, " "or is not readable on worker '%s'.") % (directory, worker))) message.id = 'log-path-check' self.wizard.add_msg(message) self.wizard.taskFinished(True) return False else: self.wizard.clear_msg('log-path-check') self.wizard.taskFinished(False) return True self.wizard.taskFinished()
def checkPathFinished(pathExists): if not pathExists: message = messages.Warning(T_(N_( "Directory '%s' does not exist, " "or is not readable on worker '%s'.") % (self.model.properties.path, self.worker))) message.id = 'ondemand-path-check' self.wizard.add_msg(message) self.wizard.taskFinished(True) return False else: self.wizard.clear_msg('ondemand-path-check') self._blockNext['path'] = False self.wizard.taskFinished(False) return True self.wizard.taskFinished()
def chooseDecoder(missing): if 'ffdec_dvvideo' in missing and 'dvdec' not in missing: msg = messages.Warning(T_( N_("GStreamer's dv decoder element (dvdec) will be used " "instead of FFmpeg's which is better in terms of " "performance.\nIf the configuration doesn't work " "properly, consider installing the ffmpeg plugins for " "gstreamer.")), mid='firewire-warning') self.wizard.add_msg(msg) self.model.properties.decoder = 'dvdec' elif 'dvdec' in missing: msg = messages.Error(T_( N_("None of the dv decoder elements was found in your " "system, consider installing the ffmpeg plugins for " "gstreamer to continue.")), mid='firewire-error') self.wizard.add_msg(msg) self.wizard.blockNext(True)
def _getRRDPaths(self): """Create the RRD file using the CACTI standard configuration if it doesn't exist""" paths = [] rrds = ( (self._clientsPath, 'clients', 'GAUGE'), (self._bytesPath, 'bytes', 'DERIVE'), ) for path, name, counterType in rrds: if not os.path.exists(path): try: DAY = 60 * 60 * 24 count = [ 8 * DAY // self._stepSize, 56 * DAY // (self._stepSize * 6), 250 * DAY // (self._stepSize * 24), 3000 * DAY // (self._stepSize * 288), ] rrdtool.create(path, '-s %d' % self._stepSize, 'DS:%s:%s:600:0:U' % (name, counterType), 'RRA:AVERAGE:0.5:1:%d' % count[0], 'RRA:AVERAGE:0.5:6:%d' % count[1], 'RRA:AVERAGE:0.5:24:%d' % count[2], 'RRA:AVERAGE:0.5:288:%d' % count[3], 'RRA:MAX:0.5:1:%d' % count[0], 'RRA:MAX:0.5:6:%d' % count[1], 'RRA:MAX:0.5:24:%d' % count[2], 'RRA:MAX:0.5:288:%d' % count[3]) paths.append(path) self.info("Created RRD file: '%s'", path) except Exception, e: self.warning("Error creating RRD file '%s': %s", path, log.getExceptionMessage(e)) m = messages.Warning(T_(N_( "Could not create RRD file '%s'.\n"), path), debug=log.getExceptionMessage(e), mid='rrd-create-error-%s' % path) self._component.addMessage(m) else: paths.append(path) self.info("Using existing RRD file: '%s'", path)
def errbackNotFoundResult(failure, result, mid, device): """ I am an errback to add to a do_element_check deferred to check for RESOURCE_ERROR_NOT_FOUND, and add a message to the result. @param mid: the id to set on the message """ failure.trap(errors.GStreamerGstError) source, gerror, debug = failure.value.args if gerror.domain == "gst-resource-error-quark" and \ gerror.code == int(gst.RESOURCE_ERROR_NOT_FOUND): m = messages.Warning(T_( N_("No device found on %s."), device), mid=mid) result.add(m) return result # let failure fall through otherwise return failure
def _setup_pipeline(self): self.debug('setup_pipeline()') assert self.bus_signal_id == None self.pipeline.set_name('pipeline-' + self.getName()) bus = self.pipeline.get_bus() bus.add_signal_watch() self.bus_signal_id = bus.connect('message', self.bus_message_received_cb) sig_id = self.pipeline.connect('deep-notify', gstreamer.verbose_deep_notify_cb, self) self.pipeline_signals.append(sig_id) # set to ready so that multifdsinks can always receive fds, even # if the pipeline has a delayed start due to clock slaving self.pipeline.set_state(gst.STATE_READY) # start checking feeders, if we have a sufficiently recent multifdsink if self._get_stats_supported: self._feeder_probe_cl = reactor.callLater( self.FEEDER_STATS_UPDATE_FREQUENCY, self._feeder_probe_calllater) else: self.warning("Feeder statistics unavailable, your " "gst-plugins-base is too old") m = messages.Warning(T_(N_( "Your gst-plugins-base is too old, so " "feeder statistics will be unavailable.")), mid='multifdsink') m.add(T_(N_( "Please upgrade '%s' to version %s."), 'gst-plugins-base', '0.10.11')) self.addMessage(m) for eater in self.eaters.values(): self.install_eater_event_probes(eater) pad = self.get_element(eater.elementName).get_pad('src') self._pad_monitors.attach(pad, eater.elementName, padmonitor.EaterPadMonitor, self.reconnectEater, eater.eaterAlias) eater.setPadMonitor(self._pad_monitors[eater.elementName])
def checkTheora(): """ Check for a recent enough Theora encoder. """ result = messages.Result() version = gstreamer.get_plugin_version('theora') if version >= (0, 10, 0, 0) and version < (0, 10, 3, 0): m = messages.Warning(T_( N_("Version %s of the '%s' GStreamer plug-in contains a bug.\n"), string.join([str(x) for x in version], '.'), 'theora'), mid='theora-check') m.add(T_(N_( "Synchronization between audio and video may not be correct.\n"))) m.add(T_(N_( "Please upgrade '%s' to version %s."), 'gst-plugins-base', '0.10.3')) result.add(m) result.succeed(None) return defer.succeed(result)
def feedToFD(self, feedName, fd, cleanup, eaterId=None): """ @param feedName: name of the feed to feed to the given fd. @type feedName: str @param fd: the file descriptor to feed to @type fd: int @param cleanup: the function to call when the FD is no longer feeding @type cleanup: callable """ self.debug('FeedToFD(%s, %d)', feedName, fd) # We must have a pipeline in READY or above to do this. Do a # non-blocking (zero timeout) get_state. if (not self.pipeline or self.pipeline.get_state(0)[1] == gst.STATE_NULL): self.warning( 'told to feed %s to fd %d, but pipeline not ' 'running yet', feedName, fd) cleanup(fd) # can happen if we are restarting but the other component is # happy; assume other side will reconnect later return if feedName not in self.feeders: msg = "Cannot find feeder named '%s'" % feedName mid = "feedToFD-%s" % feedName m = messages.Warning(T_(N_("Internal Flumotion error.")), debug=msg, mid=mid, priority=40) self.state.append('messages', m) self.warning(msg) cleanup(fd) return False feeder = self.feeders[feedName] element = self.get_element(feeder.elementName) assert element clientId = eaterId or ('client-%d' % fd) element.emit('add', fd) feeder.clientConnected(clientId, fd, cleanup)
def checkElements(elements): if elements: f = ngettext("Worker '%s' is missing GStreamer element '%s'.", "Worker '%s' is missing GStreamer elements '%s'.", len(elements)) message = messages.Warning( T_(f, self.worker, "', '".join(elements)), mid='overlay') message.add( T_( N_("\n\nClick \"Forward\" to proceed without overlay."))) self.wizard.add_msg(message) self.wizard.taskFinished() self._setSensitive(False) return else: self.wizard.clear_msg('overlay') # now check import d = self.wizard.checkImport(self.worker, 'cairo') d.addCallback(checkImport) d.addErrback(importError)