示例#1
0
def do_element_check(pipeline_str, element_name, check_proc, state=None,
    set_state_deferred=False):
    """
    Parse the given pipeline and set it to the given state.
    When the bin reaches that state, perform the given check function on the
    element with the given name.

    @param pipeline_str: description of the pipeline used to test
    @param element_name: name of the element being checked
    @param check_proc: a function to call with the GstElement as argument.
    @param state: an unused keyword parameter that will be removed when
    support for GStreamer 0.8 is dropped.
    @param set_state_deferred: a flag to say whether the set_state is run in
    a deferToThread
    @type set_state_deferred: bool
    @returns: a deferred that will fire with the result of check_proc, or
              fail.
    @rtype: L{twisted.internet.defer.Deferred}
    """

    def run_check(pipeline, resolution):
        element = pipeline.get_by_name(element_name)
        try:
            retval = check_proc(element)
            resolution.callback(retval)
        except check.CheckProcError, e:
            log.debug('check', 'CheckProcError when running %r: %r',
                      check_proc, e.data)
            resolution.errback(errors.RemoteRunError(e.data))
        except Exception, e:
            log.debug('check', 'Unhandled exception while running %r: %r',
                      check_proc, e)
            resolution.errback(errors.RemoteRunError(
                log.getExceptionMessage(e)))
示例#2
0
 def _logStatsLine(self):
     """
     Statistic fields names:
         CRR: Cache Read Ratio
         CMC: Cache Miss Count
         CHC: Cache Hit Count
         THC: Temp Hit Count
         COC: Cache Outdate Count
         CCC: Cache Cleanup Count
         CCU: Cache Current Usage
         CUR: Cache Usage Ratio
         PTC: coPy Total Count
         PCC: coPy Current Count
         PAC: coPy cAncellation Count
         MCS: Mean Copy Size
         MCR: Mean Copy Ratio
     """
     log.debug("stats-local-cache",
               "CRR: %.4f; CMC: %d; CHC: %d; THC: %d; COC: %d; "
               "CCC: %d; CCU: %d; CUR: %.5f; "
               "PTC: %d; PCC: %d; PAC: %d; MCS: %d; MCR: %.4f",
               self.cacheReadRatio, self.cacheMissCount,
               self.cacheHitCount, self.tempHitCount,
               self.cacheOutdateCount, self.cleanupCount,
               self._cacheUsage, self._cacheUsageRatio,
               self.totalCopyCount, self.currentCopyCount,
               self.cancelledCopyCount, self.meanBytesCopied,
               self.meanCopyRatio)
示例#3
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
示例#4
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
示例#5
0
    def testInit(self):
        r = registry.getRegistry()
        components = [c.getType() for c in r.getComponents()]
        for type in components:
            # skip test components - see test_config.py
            if type.startswith('test-'):
                continue

            log.debug('test', 'testing component type %s' % type)
            defs = r.getComponent(type)
            try:
                entry = defs.getEntryByType('component')
            except KeyError, e:
                self.fail(
                    'KeyError while trying to get component entry for %s' %
                        type)
            moduleName = defs.getSource()
            methodName = entry.getFunction()
            # call __init__ without the config arg; this will load
            # modules, get the entry point, then fail with too-few
            # arguments. would be nice to __init__ with the right
            # config, but that is component-specific...
            self.assertRaises(TypeError,
                              reflectcall.reflectCall,
                              moduleName, methodName)
示例#6
0
 def _logStatsLine(self):
     """
     Statistic fields names:
         CRR: Cache Read Ratio
         CMC: Cache Miss Count
         CHC: Cache Hit Count
         THC: Temp Hit Count
         COC: Cache Outdate Count
         CCC: Cache Cleanup Count
         CCU: Cache Current Usage
         CUR: Cache Usage Ratio
         PTC: coPy Total Count
         PCC: coPy Current Count
         PAC: coPy cAncellation Count
         MCS: Mean Copy Size
         MCR: Mean Copy Ratio
     """
     log.debug(
         "stats-local-cache",
         "CRR: %.4f; CMC: %d; CHC: %d; THC: %d; COC: %d; "
         "CCC: %d; CCU: %d; CUR: %.5f; "
         "PTC: %d; PCC: %d; PAC: %d; MCS: %d; MCR: %.4f",
         self.cacheReadRatio, self.cacheMissCount, self.cacheHitCount,
         self.tempHitCount, self.cacheOutdateCount, self.cleanupCount,
         self._cacheUsage, self._cacheUsageRatio, self.totalCopyCount,
         self.currentCopyCount, self.cancelledCopyCount,
         self.meanBytesCopied, self.meanCopyRatio)
示例#7
0
    def clearJobState(self, shutdownRequested):
        """
        Remove the job state.
        """
        # Clear messages proxied from job
        for m in self._jobState.get('messages'):
            self.remove('messages', m)

        self.set('lastKnownPid', self._jobState.get('pid'))

        self._jobState.removeListener(self)
        self._jobState = None

        # Clearing a job state means that a component logged out. If the
        # component logs out due to an explicit manager request, go to
        # sleeping. Otherwise if the component is sad, leave the mood as
        # it is, or otherwise go to lost, because it got disconnected
        # for an unknown reason (probably network related).
        if shutdownRequested:
            log.debug('componentstate', "Shutdown was requested, %s"
                      " now sleeping", self.get('name'))
            self.setMood(moods.sleeping.value)
        elif self.get('mood') != moods.sad.value:
            log.debug('componentstate', "Shutdown was NOT requested,"
                      " %s now lost, last know pid is: %r",
                      self.get('name'), self.get('lastKnownPid'))
            self.setMood(moods.lost.value)
示例#8
0
    def testInit(self):
        r = registry.getRegistry()
        components = [c.getType() for c in r.getComponents()]
        for type in components:
            # skip test components - see test_config.py
            if type.startswith('test-'):
                continue

            log.debug('test', 'testing component type %s' % type)
            defs = r.getComponent(type)
            try:
                entry = defs.getEntryByType('component')
            except KeyError, e:
                self.fail(
                    'KeyError while trying to get component entry for %s' %
                        type)
            moduleName = defs.getSource()
            methodName = entry.getFunction()
            # call __init__ without the config arg; this will load
            # modules, get the entry point, then fail with too-few
            # arguments. would be nice to __init__ with the right
            # config, but that is component-specific...
            self.assertRaises(TypeError,
                              reflectcall.reflectCall,
                              moduleName, methodName)
示例#9
0
文件: check.py 项目: mithro/flumotion
def callbackResult(value, result):
    """
    I am a callback to add to a do_element_check deferred.
    """
    log.debug('check', 'returning succeeded Result, value %r' % (value, ))
    result.succeed(value)
    return result
示例#10
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
示例#11
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
示例#12
0
def do_element_check(pipeline_str, element_name, check_proc, state=None,
    set_state_deferred=False):
    """
    Parse the given pipeline and set it to the given state.
    When the bin reaches that state, perform the given check function on the
    element with the given name.

    @param pipeline_str: description of the pipeline used to test
    @param element_name: name of the element being checked
    @param check_proc: a function to call with the GstElement as argument.
    @param state: an unused keyword parameter that will be removed when
    support for GStreamer 0.8 is dropped.
    @param set_state_deferred: a flag to say whether the set_state is run in
    a deferToThread
    @type set_state_deferred: bool
    @returns: a deferred that will fire with the result of check_proc, or
              fail.
    @rtype: L{twisted.internet.defer.Deferred}
    """

    def run_check(pipeline, resolution):
        element = pipeline.get_by_name(element_name)
        try:
            retval = check_proc(element)
            resolution.callback(retval)
        except check.CheckProcError, e:
            log.debug('check', 'CheckProcError when running %r: %r',
                      check_proc, e.data)
            resolution.errback(errors.RemoteRunError(e.data))
        except Exception, e:
            log.debug('check', 'Unhandled exception while running %r: %r',
                      check_proc, e)
            resolution.errback(errors.RemoteRunError(
                log.getExceptionMessage(e)))
示例#13
0
    def clearJobState(self, shutdownRequested):
        """
        Remove the job state.
        """
        # Clear messages proxied from job
        for m in self._jobState.get('messages'):
            self.remove('messages', m)

        self.set('lastKnownPid', self._jobState.get('pid'))

        self._jobState.removeListener(self)
        self._jobState = None

        # Clearing a job state means that a component logged out. If the
        # component logs out due to an explicit manager request, go to
        # sleeping. Otherwise if the component is sad, leave the mood as
        # it is, or otherwise go to lost, because it got disconnected
        # for an unknown reason (probably network related).
        if shutdownRequested:
            log.debug('componentstate', "Shutdown was requested, %s"
                      " now sleeping", self.get('name'))
            self.setMood(moods.sleeping.value)
        elif self.get('mood') != moods.sad.value:
            log.debug(
                'componentstate', "Shutdown was NOT requested,"
                " %s now lost, last know pid is: %r", self.get('name'),
                self.get('lastKnownPid'))
            self.setMood(moods.lost.value)
示例#14
0
文件: message.py 项目: flyapen/UgFlu
    def _after_textview__event(self, textview, event):
        if event.type != gtk.gdk.BUTTON_RELEASE:
            return False
        if event.button != 1:
            return False

        textbuffer = textview.get_buffer()
        # we shouldn't follow a link if the user has selected something
        bounds = textbuffer.get_selection_bounds()
        if bounds:
            [start, end] = bounds
            if start.get_offset() != end.get_offset():
                return False

        x, y = textview.window_to_buffer_coords(gtk.TEXT_WINDOW_WIDGET,
            int(event.x), int(event.y))
        iter = textview.get_iter_at_location(x, y)

        for tag in iter.get_tags():
            link = tag.get_data('link')
            if link:
                import webbrowser
                log.debug('messageview', 'opening %s' % link)
                webbrowser.open(link)
                break

        return False
示例#15
0
    def _after_textview__event(self, textview, event):
        if event.type != gtk.gdk.BUTTON_RELEASE:
            return False
        if event.button != 1:
            return False

        textbuffer = textview.get_buffer()
        # we shouldn't follow a link if the user has selected something
        bounds = textbuffer.get_selection_bounds()
        if bounds:
            [start, end] = bounds
            if start.get_offset() != end.get_offset():
                return False

        x, y = textview.window_to_buffer_coords(gtk.TEXT_WINDOW_WIDGET,
                                                int(event.x), int(event.y))
        iter = textview.get_iter_at_location(x, y)

        for tag in iter.get_tags():
            link = tag.get_data('link')
            if link:
                import webbrowser
                log.debug('messageview', 'opening %s' % link)
                webbrowser.open(link)
                break

        return False
示例#16
0
 def cacheFiles(self):
     """
     Fetches the files contained on the directory for posterior usage of
     them. This should be called on the worker side to work or the files
     wouldn't be the expected ones.
     """
     import gnomevfs
     log.debug('vfsgnome', 'getting files for %s' % (self.path, ))
     retval = []
     try:
         fileInfos = gnomevfs.open_directory(self.path)
     except gnomevfs.AccessDeniedError:
         raise AccessDeniedError
     if self.path != '/':
         retval.append(
             GnomeVFSDirectory(os.path.dirname(self.path), name='..'))
     for fileInfo in fileInfos:
         filename = fileInfo.name
         if filename.startswith('.'):
             continue
         if fileInfo.type == gnomevfs.FILE_TYPE_DIRECTORY:
             obj = GnomeVFSDirectory(os.path.join(self.path, fileInfo.name))
         else:
             obj = GnomeVFSFile(self.path, fileInfo)
         retval.append(obj)
     log.log('vfsgnome', 'returning %r' % (retval, ))
     self._cachedFiles = retval
示例#17
0
def main(args):
    parser = _createParser()

    log.debug('manager', 'Parsing arguments (%r)' % ', '.join(args))
    options, args = parser.parse_args(args)

    # Force options down configure's throat
    for d in ['logdir', 'rundir']:
        o = getattr(options, d, None)
        if o:
            log.debug('manager', 'Setting configure.%s to %s' % (d, o))
            setattr(configure, d, o)

    # parse planet config file
    if len(args) <= 1:
        log.warning('manager', 'Please specify a planet configuration file')
        sys.stderr.write("Please specify a planet configuration file.\n")
        return 1

    planetFile = args[1]
    try:
        cfg = config.ManagerConfigParser(planetFile)
    except IOError, e:
        sys.stderr.write("ERROR: Could not read configuration from '%s':\n" %
            planetFile)
        sys.stderr.write("ERROR: %s\n" % e.strerror)
        return 1
示例#18
0
def callbackResult(value, result):
    """
    I am a callback to add to a do_element_check deferred.
    """
    log.debug('check', 'returning succeeded Result, value %r' % (value, ))
    result.succeed(value)
    return result
示例#19
0
    def startSSL(self, host, port, pemFile, configDir):
        """
        Listen as the given host and on the given port using SSL.
        Use the given .pem file, or look for it in the config directory.

        @param pemFile:   File containing the SSL certificate.
                          If it's a full path, respects the full path.
                          If not, looks in configDir for this file.
        @param configDir: directory where .pem file is stored
        @returns: {twisted.internet.interfaces.IListeningPort} on which
        we are listening; call .stopListening() to stop.
        """
        from flumotion.common import common
        common.assertSSLAvailable()

        # if no path in pemFile, then look for it in the config directory
        if not os.path.split(pemFile)[0]:
            pemFile = os.path.join(configDir, pemFile)
        if not os.path.exists(pemFile):
            self.error(".pem file %s does not exist.\n" \
                "For more information, see \n" \
                "http://www.flumotion.net/doc/flumotion/manual/html/" \
                "chapter-security.html" % pemFile)
        log.debug('manager', 'Using PEM certificate file %s' % pemFile)
        ctxFactory = _ServerContextFactory(pemFile)

        self.info('Starting on port %d using SSL' % port)
        if not host == "":
            self.info('Listening as host %s' % host)
        self._servable.setConnectionInfo(host, port, True)
        return reactor.listenSSL(port,
                                 self._servable.getFactory(),
                                 ctxFactory,
                                 interface=host)
示例#20
0
    def probeDevice(element):
        caps = element.get_pad("src").get_caps()
        log.debug('check', 'caps: %s' % caps.to_string())

        sizes = {}  # (width, height) => [{'framerate': (framerate_num,

        #                                    framerate_denom),
        #                      'mime': str,
        #                      'fourcc': fourcc}]

        def forAllStructValues(struct, key, proc):
            vals = struct[key]
            if isinstance(vals, list):
                for val in vals:
                    proc(struct, val)
            elif isinstance(vals, gst.IntRange):
                val = vals.low
                while val < vals.high:
                    proc(struct, val)
                    val *= 2
                proc(struct, vals.high)
            elif isinstance(vals, gst.DoubleRange):
                # hack :)
                proc(struct, vals.high)
            elif isinstance(vals, gst.FractionRange):
                # hack :)
                val = vals.low
                while float(val) < float(vals.high):
                    proc(struct, val)
                    val.num += 5
                proc(struct, vals.high)
            else:
                # scalar
                proc(struct, vals)

        def addRatesForWidth(struct, width):
            def addRatesForHeight(struct, height):
                def addRate(struct, rate):
                    if not rate.num:
                        return
                    if (width, height) not in sizes:
                        sizes[(width, height)] = []
                    d = {
                        'framerate': (rate.num, rate.denom),
                        'mime': struct.get_name()
                    }
                    if 'yuv' in d['mime']:
                        d['format'] = struct['format'].fourcc
                    sizes[(width, height)].append(d)

                forAllStructValues(struct, 'framerate', addRate)

            forAllStructValues(struct, 'height', addRatesForHeight)

        for struct in caps:
            if 'yuv' not in struct.get_name():
                continue
            forAllStructValues(struct, 'width', addRatesForWidth)

        return (element.get_factory().get_name(), sizes)
示例#21
0
def setupPackagePath():
    """
    set up all project paths specified in the FLU_PROJECT_PATH environment
    variable.

    This should be called by every Flumotion binary before starting/importing
    any other flumotion code.
    """
    import os
    from flumotion.common import package, log
    from flumotion.configure import configure

    registryPaths = [
        configure.pythondir,
    ]
    if 'FLU_PROJECT_PATH' in os.environ:
        paths = os.environ['FLU_PROJECT_PATH']
        registryPaths += paths.split(':')

    log.debug('setup', 'registry paths: %s' % ", ".join(registryPaths))
    for path in registryPaths:
        log.debug('setup', 'registering package path: %s' % path)
        # we register with the path as part of the key, since
        # these aren't meant to be replaced
        package.getPackager().registerPackagePath(path,
                                                  "FLU_PROJECT_PATH_" + path)
示例#22
0
    def startSSL(self, host, port, pemFile, configDir):
        """
        Listen as the given host and on the given port using SSL.
        Use the given .pem file, or look for it in the config directory.

        @param pemFile:   File containing the SSL certificate.
                          If it's a full path, respects the full path.
                          If not, looks in configDir for this file.
        @param configDir: directory where .pem file is stored
        @returns: {twisted.internet.interfaces.IListeningPort} on which
        we are listening; call .stopListening() to stop.
        """
        from flumotion.common import common
        common.assertSSLAvailable()

        # if no path in pemFile, then look for it in the config directory
        if not os.path.split(pemFile)[0]:
            pemFile = os.path.join(configDir, pemFile)
        if not os.path.exists(pemFile):
            self.error(".pem file %s does not exist.\n" \
                "For more information, see \n" \
                "http://www.flumotion.net/doc/flumotion/manual/html/" \
                "chapter-security.html" % pemFile)
        log.debug('manager', 'Using PEM certificate file %s' % pemFile)
        ctxFactory = _ServerContextFactory(pemFile)

        self.info('Starting on port %d using SSL' % port)
        if not host == "":
            self.info('Listening as host %s' % host)
        self._servable.setConnectionInfo(host, port, True)
        return reactor.listenSSL(port, self._servable.getFactory(),
                                 ctxFactory, interface=host)
示例#23
0
def main(args):
    parser = _createParser()

    log.debug("manager", "Parsing arguments (%r)" % ", ".join(args))
    options, args = parser.parse_args(args)

    # Force options down configure's throat
    for d in ["logdir", "rundir"]:
        o = getattr(options, d, None)
        if o:
            log.debug("manager", "Setting configure.%s to %s" % (d, o))
            setattr(configure, d, o)

    # parse planet config file
    if len(args) <= 1:
        log.warning("manager", "Please specify a planet configuration file")
        sys.stderr.write("Please specify a planet configuration file.\n")
        return 1

    planetFile = args[1]
    try:
        cfg = config.ManagerConfigParser(planetFile)
    except IOError, e:
        sys.stderr.write("ERROR: Could not read configuration from '%s':\n" % planetFile)
        sys.stderr.write("ERROR: %s\n" % e.strerror)
        return 1
示例#24
0
 def scanningComplete():
     log.debug('check', 'Scanning complete')
     result = messages.Result()
     log.debug('check', 'Channels: %r ts: %r',
               scanner.channels, scanner.transport_streams)
     result.succeed((scanner.channels, scanner.transport_streams))
     d.callback(result)
示例#25
0
文件: vfsgnome.py 项目: flyapen/UgFlu
 def cacheFiles(self):
     """
     Fetches the files contained on the directory for posterior usage of
     them. This should be called on the worker side to work or the files
     wouldn't be the expected ones.
     """
     import gnomevfs
     log.debug('vfsgnome', 'getting files for %s' % (self.path, ))
     retval = []
     try:
         fileInfos = gnomevfs.open_directory(self.path)
     except gnomevfs.AccessDeniedError:
         raise AccessDeniedError
     if self.path != '/':
         retval.append(GnomeVFSDirectory(os.path.dirname(self.path),
                                         name='..'))
     for fileInfo in fileInfos:
         filename = fileInfo.name
         if filename.startswith('.'):
             continue
         if fileInfo.type == gnomevfs.FILE_TYPE_DIRECTORY:
             obj = GnomeVFSDirectory(os.path.join(self.path,
                                                  fileInfo.name))
         else:
             obj = GnomeVFSFile(self.path, fileInfo)
         retval.append(obj)
     log.log('vfsgnome', 'returning %r' % (retval, ))
     self._cachedFiles = retval
示例#26
0
    def validate(self):
        super(Producer, self).validate()

        if self.eaters:
            raise ComponentValidationError("producer component %s can not have any eaters" % (self.name,))

        if not self.feeders:
            log.debug("component-validation", "producer component %s doesn't have any feeder" % (self.name,))
示例#27
0
    def validate(self):
        super(Muxer, self).validate()

        if not self.eaters:
            raise ComponentValidationError("muxer component %s must have at least one eater" % (self.name,))

        if not self.feeders:
            log.debug("component-validation", "muxer component %s doesn't have any feeder" % (self.name,))
示例#28
0
 def run_check(pipeline, resolution):
     element = pipeline.get_by_name(element_name)
     try:
         retval = check_proc(element)
         resolution.callback(retval)
     except check.CheckProcError, e:
         log.debug("check", "CheckProcError when running %r: %r", check_proc, e.data)
         resolution.errback(errors.RemoteRunError(e.data))
示例#29
0
 def errback(failure):
     log.debug('launch', log.getFailureMessage(failure))
     print "Error occurred: %s" % failure.getErrorMessage()
     failure.printDetailedTraceback()
     reactor.failure = True
     if reactor.running:
         print "Stopping reactor."
         reactor.stop()
示例#30
0
 def run_check(pipeline, resolution):
     element = pipeline.get_by_name(element_name)
     try:
         retval = check_proc(element)
         resolution.callback(retval)
     except check.CheckProcError, e:
         log.debug('check', 'CheckProcError when running %r: %r',
                   check_proc, e.data)
         resolution.errback(errors.RemoteRunError(e.data))
示例#31
0
 def tryV4L1(_):
     log.debug('webcam', 'trying v4l1')
     pipeline = 'v4lsrc name=source device=%s ! fakesink' % (device, )
     d = do_element_check(pipeline,
                          'source',
                          probeDevice,
                          state=gst.STATE_PAUSED,
                          set_state_deferred=True)
     return d
示例#32
0
文件: test_pb.py 项目: flyapen/UgFlu
 def WrongPasswordErrback(failure):
     self.failUnless(isinstance(factory.keycard,
                                keycards.KeycardUACPCC))
     # This is a CopiedFailure
     self.assert_(failure.check(
         "flumotion.common.errors.NotAuthenticatedError"))
     log.debug("trial", "got failure %r" % failure)
     c.disconnect()
     return True
示例#33
0
 def WrongPasswordErrback(failure):
     self.failUnless(isinstance(factory.keycard,
                                keycards.KeycardUACPCC))
     # This is a CopiedFailure
     self.assert_(
         failure.check("flumotion.common.errors.NotAuthenticatedError"))
     log.debug("trial", "got failure %r" % failure)
     c.disconnect()
     return True
示例#34
0
def getInitialTuning(adapterType, initialTuningFile):
    """
    Provide initial tuning parameters.
    Returns a dict with tuning parameters.
    """
    result = messages.Result()
    ret = []
    if not os.path.exists(initialTuningFile):
        result.succeed(ret)
        return result

    for line in open(initialTuningFile, "r"):
        log.debug('check', 'line in file: %s' % line)

        if not line:
            break
        if line[0] == '#':
            continue
        params = line[:-1].split(" ")

        if params[0] == "T" and adapterType == "DVB-T":
            if len(params) < 9:
                continue
            d = {"frequency": int(params[1]),
                 "bandwidth": int(params[2][0]),
                 "code-rate-hp": params[3],
                 "code-rate-lp": params[4],
                 "constellation": params[5],
                 "transmission-mode": params[6],
                 "guard-interval": int(params[7].split("/")[1]),
                 "hierarchy": params[8]}
            ret.append(d)
        elif params[0] == "S" and adapterType == "DVB-S":
            if len(params) != 5:
                continue
            d = {"frequency": int(params[1]),
                 "symbol-rate": int(params[3])/1000,
                 "inner-fec": params[4],
                 }
            if params[2] == "V":
                d["polarization"] = "vertical"
            else:
                d["polarization"] = "horizontal"
            ret.append(d)
        elif params[0] == "C" and adapterType == "DVB-C":
            if len(params) != 5:
                continue
            d = {"frequency": int(params[1]),
                 "symbol-rate": int(params[2])/1000,
                 "inner-fec": params[3],
                 "modulation": params[4],
                 }
            ret.append(d)

    result.succeed(ret)
    return result
示例#35
0
    def probeDevice(element):
        caps = element.get_pad("src").get_caps()
        log.debug('check', 'caps: %s' % caps.to_string())

        sizes = {} # (width, height) => [{'framerate': (framerate_num,
                   #                                    framerate_denom),
                   #                      'mime': str,
                   #                      'fourcc': fourcc}]

        def forAllStructValues(struct, key, proc):
            vals = struct[key]
            if isinstance(vals, list):
                for val in vals:
                    proc(struct, val)
            elif isinstance(vals, gst.IntRange):
                val = vals.low
                while val < vals.high:
                    proc(struct, val)
                    val *= 2
                proc(struct, vals.high)
            elif isinstance(vals, gst.DoubleRange):
                # hack :)
                proc(struct, vals.high)
            elif isinstance(vals, gst.FractionRange):
                # hack :)
                val = vals.low
                while float(val) < float(vals.high):
                    proc(struct, val)
                    val.num += 5
                proc(struct, vals.high)
            else:
                # scalar
                proc(struct, vals)

        def addRatesForWidth(struct, width):

            def addRatesForHeight(struct, height):

                def addRate(struct, rate):
                    if not rate.num:
                        return
                    if (width, height) not in sizes:
                        sizes[(width, height)] = []
                    d = {'framerate': (rate.num, rate.denom),
                         'mime': struct.get_name()}
                    if 'yuv' in d['mime']:
                        d['format'] = struct['format'].fourcc
                    sizes[(width, height)].append(d)
                forAllStructValues(struct, 'framerate', addRate)
            forAllStructValues(struct, 'height', addRatesForHeight)
        for struct in caps:
            if 'yuv' not in struct.get_name():
                continue
            forAllStructValues(struct, 'width', addRatesForWidth)

        return (element.get_factory().get_name(), sizes)
 def pagePart(self, data):
     self.buffer += data
     log.debug('stream-downloader', 'Got bytes %r, limit is %r' %\
              (len(self.buffer), self.limit))
     if len(self.buffer) >= self.limit:
         self.finished = True
         log.debug('stream-downloader',\
             'Calling callback of StreamDownloader')
         self.deferred.addCallback(self.connector.transport.loseConnection)
         self.deferred.callback(self)
示例#37
0
 def WrongPasswordErrback(failure):
     # make sure we really used an SHA256 challenge/response keycard
     self.failUnless(isinstance(factory.keycard,
                                keycards.KeycardUASPCC))
     # This is a CopiedFailure
     self.assert_(
         failure.check("flumotion.common.errors.NotAuthenticatedError"))
     log.debug("trial", "got failure %r" % failure)
     c.disconnect()
     return True
示例#38
0
文件: base.py 项目: flyapen/UgFlu
    def makeAvatar(klass, heaven, avatarId, remoteIdentity, mind):
        log.debug('manager-avatar', 'making avatar with avatarId %s',
                  avatarId)

        def have_args(args):
            log.debug('manager-avatar', 'instantiating with args=%r', args)
            return klass(*args)
        d = klass.makeAvatarInitArgs(heaven, avatarId, remoteIdentity, mind)
        d.addCallback(have_args)
        return d
示例#39
0
def _getPidPath(type, name=None):
    """
    Get the full path to the pid file for the given process type and name.
    """
    path = os.path.join(configure.rundir, '%s.pid' % type)
    if name:
        path = os.path.join(configure.rundir, '%s.%s.pid' % (type, name))
    log.debug('common',
              'getPidPath for type %s, name %r: %s' % (type, name, path))
    return path
 def pagePart(self, data):
     self.buffer += data
     log.debug('stream-downloader', 'Got bytes %r, limit is %r' %\
              (len(self.buffer), self.limit))
     if len(self.buffer) >= self.limit:
         self.finished = True
         log.debug('stream-downloader',\
             'Calling callback of StreamDownloader')
         self.deferred.addCallback(self.connector.transport.loseConnection)
         self.deferred.callback(self)
示例#41
0
文件: test_pb.py 项目: flyapen/UgFlu
 def WrongPasswordErrback(failure):
     # make sure we really used an SHA256 challenge/response keycard
     self.failUnless(isinstance(factory.keycard,
                                keycards.KeycardUASPCC))
     # This is a CopiedFailure
     self.assert_(failure.check(
         "flumotion.common.errors.NotAuthenticatedError"))
     log.debug("trial", "got failure %r" % failure)
     c.disconnect()
     return True
示例#42
0
文件: process.py 项目: flyapen/UgFlu
def _getPidPath(type, name=None):
    """
    Get the full path to the pid file for the given process type and name.
    """
    path = os.path.join(configure.rundir, '%s.pid' % type)
    if name:
        path = os.path.join(configure.rundir, '%s.%s.pid' % (type, name))
    log.debug('common', 'getPidPath for type %s, name %r: %s' % (
        type, name, path))
    return path
示例#43
0
    def makeAvatar(klass, heaven, avatarId, remoteIdentity, mind):
        log.debug('manager-avatar', 'making avatar with avatarId %s', avatarId)

        def have_args(args):
            log.debug('manager-avatar', 'instantiating with args=%r', args)
            return klass(*args)

        d = klass.makeAvatarInitArgs(heaven, avatarId, remoteIdentity, mind)
        d.addCallback(have_args)
        return d
示例#44
0
    def check_for_lock(self):
        if not self.locked:
            log.debug('check', 'Don\'t have lock!')
            self.pipeline.set_state(gst.STATE_READY)
            # block until state change completed
            self.pipeline.get_state()
            log.debug('check', 'Pipeline now ready')
            self.scanned = False

            self.scanning_complete_cb()
            return False
        def loadConfigAndOneWorker(workerAvatar):
            log.debug("unittest", "loadConfigAndOneWorker")
            self.failUnlessEqual(len(self._workers), 1)
            self.failUnlessEqual(len(self._components), 0)

            # load configuration
            d = self.vishnu.loadComponentConfigurationXML(file, manager.LOCAL_IDENTITY)
            d.addCallback(lambda _: self._workers["worker"].mind.waitForComponentsCreate())
            d.addCallback(lambda _: self._verifyConfigAndOneWorker())
            d.addCallback(lambda _: workerAvatar)
            return d
示例#46
0
文件: gst010.py 项目: flyapen/UgFlu
def check1394devices(mid):
    """
    Fetch the available firewire devices.

    Return a deferred firing a result.

    The result is either:
     - succesful, with a list of tuples of guid and device-name
     - failed

    @param mid: the id to set on the message.

    @rtype: L{twisted.internet.defer.Deferred} of
            L{flumotion.common.messages.Result}
    """
    result = messages.Result()

    element = gst.element_factory_make('dv1394src')
    if not element:
        m = messages.Error(T_(
            N_("GStreamer error, dv1394src factory could not be found.\n"
               "Maybe gstreamer-plugins-good is not properly installed.")))
        m.id = mid
        result.add(m)
        return defer.succeed(result)

    guids = element.probe_get_values_name('guid')

    pipeline_str = 'dv1394src name=source guid=%s ! fakesink'

    devices = []

    for guid in guids:
        pipeline = gst.parse_launch(pipeline_str % guid)
        pipeline.set_state(gst.STATE_READY)
        source = pipeline.get_by_name('source')
        name = source.get_property('device-name')
        log.debug('check', 'New firewire device found: %s with guid=%s',
                  name, guid)
        devices.append((name, guid))
        pipeline.set_state(gst.STATE_NULL)

    if devices:
        result.succeed(devices)
        return defer.succeed(result)
    else:
        m = messages.Error(T_(
            N_("Could not find any Firewire device on the system.\n"
               "Please, check whether the device is correctly plugged "
               "or the modules are correctly loaded.")))

        m.id = mid
        result.add(m)
        return defer.succeed(result)
示例#47
0
文件: http.py 项目: flyapen/UgFlu
def runHTTPStreamerChecks():
    """Runs all the http checks
    @returns: a deferred returning a guess of the public
              hostname for this worker
    """
    # FIXME: Move over more checks from httpstreamer.py
    log.debug('httpcheck', 'Checking...')
    result = Result()
    result.succeed(guess_public_hostname())
    log.debug('httpcheck', 'done, returning')
    return result
示例#48
0
def runHTTPStreamerChecks():
    """Runs all the http checks
    @returns: a deferred returning a guess of the public
              hostname for this worker
    """
    # FIXME: Move over more checks from httpstreamer.py
    log.debug('httpcheck', 'Checking...')
    result = Result()
    result.succeed(guess_public_hostname())
    log.debug('httpcheck', 'done, returning')
    return result
示例#49
0
def checkDVBVideo(p, mid='check-dvb-video'):
    """
    @rtype: L{twisted.internet.defer.Deferred}
    """
    result = messages.Result()

    def get_dvb_video_params(element):
        pad = element.get_pad('src')

        if pad.get_negotiated_caps() == None:
            raise errors.GStreamerError('Pipeline failed to negotiate?')

        caps = pad.get_negotiated_caps()
        s = caps[0]
        w = s['width']
        h = s['height']
        par = s['pixel-aspect-ratio']
        fr = s['framerate']
        result = dict(width=w, height=h, par=(par.num, par.denom),
                      framerate=(fr.num, fr.denom))

        log.debug('check', 'returning dict %r' % result)
        return result


    if p.get('dvb_type') == "T":
        pipeline = ("dvbsrc modulation=\"QAM %(modulation)d\" "
                    "trans-mode=%(trans_mode)s bandwidth=%(bandwidth)d "
                    "code-rate-lp=%(code_rate_lp)s "
                    "code-rate-hp=%(code_rate_hp)s "
                    "guard=%(guard)d hierarchy=%(hierarchy)d ") % p
    elif p.get('dvb_type') == "S":
        pipeline = ("dvbsrc polarity=%(polarity)s symbol-rate=%(symbol_rate)s "
                    "diseqc-source=%(sat)d ") % p
        if p.get('code-rate-hp'):
            pipeline += " code-rate-hp=%s" % p.get('code_rate_hp')
    elif p.get('dvb_type') == "C":
        pipeline = ("dvbsrc modulation=\"QAM %(modulation)d\" "
                    "code-rate-hp=%(code_rate_hp)s ") % p

    if p.get('dvb_type') in ["S", "T", "C"]:
        pipeline += ("frequency=%d adapter=%d frontend=%d " %
                     (p.get('frequency'), p.get('adapter'), p.get('frontend')))


    pipeline += ("! mpegtsdemux program-number=%d "
                 "! mpegvideoparse name=parser ! fakesink" %
                 p.get('program_number'))

    log.debug('check', 'Using pipeline: %s', pipeline)

    d = do_element_check(pipeline, 'parser', get_dvb_video_params)
    d.addCallback(check.callbackResult, result)
    return d
示例#50
0
    def validate(self):
        super(Muxer, self).validate()

        if not self.eaters:
            raise ComponentValidationError(
                "muxer component %s must have at least one eater" %
                (self.name, ))

        if not self.feeders:
            log.debug(
                "component-validation",
                "muxer component %s doesn't have any feeder" % (self.name, ))
示例#51
0
def handleGStreamerDeviceError(failure, device, mid=None):
    """
    Handle common GStreamer GstErrors or other.
    Return a message or None.
    """
    if not mid:
        log.warning('check',
            'handleGStreamerDeviceError: no message id specified')

    m = None

    if failure.check(errors.GStreamerGstError):
        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_READ):
                m = messages.Error(T_(
                    N_("Could not open device '%s' for reading.  "
                       "Check permissions on the device."), device), mid=mid)
                documentation.messageAddFixBadPermissions(m)
            if gerror.code == int(gst.RESOURCE_ERROR_OPEN_WRITE):
                m = messages.Error(T_(
                    N_("Could not open device '%s' for writing.  "
                       "Check permissions on the device."), device), mid=mid)
                documentation.messageAddFixBadPermissions(m)
            elif gerror.code == int(gst.RESOURCE_ERROR_OPEN_READ_WRITE):
                m = messages.Error(T_(
                    N_("Could not open device '%s'.  "
                       "Check permissions on the device."), device), mid=mid)
                documentation.messageAddFixBadPermissions(m)
            elif gerror.code == int(gst.RESOURCE_ERROR_BUSY):
                m = messages.Error(T_(
                    N_("Device '%s' is already in use."), device), mid=mid)
            elif gerror.code == int(gst.RESOURCE_ERROR_SETTINGS):
                m = messages.Error(T_(
                    N_("Device '%s' did not accept the requested settings."),
                    device),
                    debug="%s\n%s" % (gerror.message, debug), mid=mid)

        # fallback GStreamer GstError handling
        if not m:
            m = messages.Error(T_(N_("Internal unhandled GStreamer error.")),
                debug="%s\n%s: %d\n%s" % (
                    gerror.message, gerror.domain, gerror.code, debug),
                               mid=mid)
    elif failure.check(errors.GStreamerError):
        m = messages.Error(T_(N_("Internal GStreamer error.")),
            debug=debugFailure(failure), mid=mid)
    log.debug('check', 'handleGStreamerError: returning %r' % m)
    return m
示例#52
0
文件: worker.py 项目: flyapen/UgFlu
    def makeAvatarInitArgs(klass, heaven, avatarId, remoteIdentity, mind):
        def havePorts(res):
            log.debug("worker-avatar", "got port information")
            (_s1, feedServerPort), (_s2, (ports, random)) = res
            return (heaven, avatarId, remoteIdentity, mind, feedServerPort, ports, random)

        log.debug("worker-avatar", "calling mind for port information")
        d = defer.DeferredList(
            [mind.callRemote("getFeedServerPort"), mind.callRemote("getPorts")], fireOnOneErrback=True
        )
        d.addCallback(havePorts)
        return d
示例#53
0
 def start(self, component):
     """
     @type component: L{HTTPFileStreamer}
     """
     if not isinstance(component, HTTPFileStreamer):
         raise ComponentStartError("An HTML5Plug %s must be plugged into a "
                                   " HTTPFileStreamer component, not a %s" %
                                   (self, component.__class__.__name__))
     log.debug('html5', 'Attaching to %r' % (component, ))
     resource = Html5DirectoryResource(component.getMountPoint(),
                                       self.args['properties'])
     component.setRootResource(resource)
示例#54
0
文件: check.py 项目: mithro/flumotion
def handleGStreamerDeviceError(failure, device, mid=None):
    """
    Handle common GStreamer GstErrors or other.
    Return a message or None.
    """
    if not mid:
        log.warning('check',
            'handleGStreamerDeviceError: no message id specified')

    m = None

    if failure.check(errors.GStreamerGstError):
        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_READ):
                m = messages.Error(T_(
                    N_("Could not open device '%s' for reading.  "
                       "Check permissions on the device."), device), mid=mid)
                documentation.messageAddFixBadPermissions(m)
            if gerror.code == int(Gst.RESOURCE_ERROR_OPEN_WRITE):
                m = messages.Error(T_(
                    N_("Could not open device '%s' for writing.  "
                       "Check permissions on the device."), device), mid=mid)
                documentation.messageAddFixBadPermissions(m)
            elif gerror.code == int(Gst.RESOURCE_ERROR_OPEN_READ_WRITE):
                m = messages.Error(T_(
                    N_("Could not open device '%s'.  "
                       "Check permissions on the device."), device), mid=mid)
                documentation.messageAddFixBadPermissions(m)
            elif gerror.code == int(Gst.RESOURCE_ERROR_BUSY):
                m = messages.Error(T_(
                    N_("Device '%s' is already in use."), device), mid=mid)
            elif gerror.code == int(Gst.RESOURCE_ERROR_SETTINGS):
                m = messages.Error(T_(
                    N_("Device '%s' did not accept the requested settings."),
                    device),
                    debug="%s\n%s" % (gerror.message, debug), mid=mid)

        # fallback GStreamer GstError handling
        if not m:
            m = messages.Error(T_(N_("Internal unhandled GStreamer error.")),
                debug="%s\n%s: %d\n%s" % (
                    gerror.message, gerror.domain, gerror.code, debug),
                               mid=mid)
    elif failure.check(errors.GStreamerError):
        m = messages.Error(T_(N_("Internal GStreamer error.")),
            debug=debugFailure(failure), mid=mid)
    log.debug('check', 'handleGStreamerError: returning %r' % m)
    return m
示例#55
0
    def validate(self):
        super(Producer, self).validate()

        if self.eaters:
            raise ComponentValidationError(
                "producer component %s can not have any eaters" %
                (self.name, ))

        if not self.feeders:
            log.debug(
                "component-validation",
                "producer component %s doesn't have any feeder" %
                (self.name, ))
        def loadConfigAndOneWorker(workerAvatar):
            log.debug('unittest', 'loadConfigAndOneWorker')
            self.failUnlessEqual(len(self._workers), 1)
            self.failUnlessEqual(len(self._components), 0)

            # load configuration
            d = self.vishnu.loadComponentConfigurationXML(
                file, manager.LOCAL_IDENTITY)
            d.addCallback(lambda _: self._workers['worker'].mind.
                          waitForComponentsCreate())
            d.addCallback(lambda _: self._verifyConfigAndOneWorker())
            d.addCallback(lambda _: workerAvatar)
            return d
示例#57
0
def cleanup_reactor(force=False):
    log.debug('comptest', 'running cleanup_reactor...')
    delayed = reactor.getDelayedCalls()
    for dc in delayed:
        dc.cancel()
    # the rest is taken from twisted trial...
    sels = reactor.removeAll()
    if sels:
        log.info('comptest',
                 'leftover selectables...: %r %r' % (sels, reactor.waker))
        for sel in sels:
            if interfaces.IProcessTransport.providedBy(sel):
                sel.signalProcess('KILL')
示例#58
0
 def setMood(self, moodValue):
     if self._jobState and moodValue != moods.sad.value:
         log.warning('componentstate', 'cannot set component mood to '
                     'something other than sad when we have a '
                     'jobState -- fix your code!')
     elif moodValue == self.get('mood'):
         log.log('componentstate', '%s already in mood %d',
                 self.get('name'), moodValue)
     else:
         log.debug('componentstate',
                   'manager sets mood of %s from %s to %d',
                   self.get('name'), self.get('mood'), moodValue)
         self.set('mood', moodValue)
示例#59
0
def checkFile(filePath):
    """
    Checks if a path is a file.

    @param filePath : The path of the file
    @type  filePath : str

    @returns : True if filePath exists and is a file, False otherwise.
    @rtype   : L{messages.Result}
    """
    log.debug('check', 'checkFile: %s', filePath)
    result = messages.Result()
    result.succeed(os.path.isfile(filePath))
    return result