示例#1
0
文件: libav.py 项目: theblazehen/duct
    def get(self):
        host = self.config.get('destination', self.hostname)

        t0 = time.time()
        try:
            _out, err, code = yield fork(
                '/usr/bin/avprobe',
                args=('rtsp://%s/sample_100kbit.mp4' % host, ),
                timeout=30.0
            )
        except:
            code = 1
            err = None

        t_delta = (time.time() - t0) * 1000

        if code == 0:
            e = self.createEvent('ok', 'RTSP Request time to %s' % host,
                                 t_delta)
        else:
            if err:
                try:
                    error = err.strip('\n').split('\n')[-2]
                except:
                    error = err.replace('\n', '-')
            else:
                error = "Execution error"

            e = self.createEvent('critical',
                                 'Unable to stream %s:%s' % (host, error),
                                 t_delta)

        defer.returnValue(e)
示例#2
0
    def test_utils_fork_timeout(self):
        died = False
        try:
            o, e, c = yield fork('sleep', args=('2', ), timeout=0.1)
        except error.ProcessTerminated:
            died = True

        self.assertTrue(died)
示例#3
0
    def fork(self, *a, **kw):
        """Wrapper function to execute another process

           Passes off to either ssh or local system based on whether
           use_ssh is set
        """
        if self.use_ssh:
            return self.ssh_client.fork(*a, **kw)
        else:
            return fork(*a, **kw)
示例#4
0
    def test_utils_fork(self):
        o, e, c = yield fork('echo', args=('hi', ))

        self.assertEquals(o, "hi\n")
        self.assertEquals(c, 0)