当前位置: 首页>>代码示例>>Python>>正文


Python Server.run方法代码示例

本文整理汇总了Python中gstswitch.server.Server.run方法的典型用法代码示例。如果您正苦于以下问题:Python Server.run方法的具体用法?Python Server.run怎么用?Python Server.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gstswitch.server.Server的用法示例。


在下文中一共展示了Server.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_audio_port

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import run [as 别名]
def get_audio_port(num):
        """Test get_audio_port"""
        audio_port = 8000
        serv = Server(path=PATH, audio_port=audio_port)
        try:
            serv.run()
            sources = TestSources(audio_port=audio_port)
            sources.new_test_audio()

            expected_res = [3003] * num

            controller = Controller()
            controller.establish_connection()
            res = []
            for _ in range(num):
                res.append(controller.get_audio_port())

            assert expected_res == res

        finally:
            if serv.proc:
                    poll = serv.proc.poll()
                    if poll == -11:
                        print("SEGMENTATION FAULT OCCURRED")
                    print("ERROR CODE - {0}".format(poll))
                    serv.terminate(1)
                    log = open('server.log')
                    print(log.read())
开发者ID:a740122,项目名称:gst-switch,代码行数:30,代码来源:performance_dbus.py

示例2: get_encode_port

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import run [as 别名]
def get_encode_port(num):
        """Test get_encode_port - num times"""
        video_port = 3000
        serv = Server(path=PATH, video_port=video_port)
        try:
            serv.run()
            sources = TestSources(video_port=video_port)
            sources.new_test_video()
            
            expected_res = [video_port + 2] * num

            controller = Controller()
            controller.establish_connection()
            res = []
            for _ in range(num):
                res.append(controller.get_encode_port())

            assert expected_res == res
        finally:
            if serv.proc:
                    poll = serv.proc.poll()
                    if poll == -11:
                        print "SEGMENTATION FAULT OCCURRED"
                    print "ERROR CODE - {0}".format(poll)
                    serv.terminate(1)
                    log = open('server.log')
                    print log.read()
开发者ID:bossjones,项目名称:gst-switch,代码行数:29,代码来源:performance_dbus.py

示例3: main

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import run [as 别名]
def main(args):

    print("running server")
    serv = Server(path=args.path)
    serv.run()

    wait(5)

    print("running source pattern=1")
    sources = TestSources(video_port=3000, audio_port=4000)
    sources.new_test_video(pattern=1)

    wait(5)

    print("running gst-switch-ui")
    # the & will run this in the background so control returns 
    # and we can bring up the 2nd source 
    call("gst-switch-ui &", shell=True)

    wait(5)
       
    print("running source pattern=18")
    sources.new_test_video(pattern=18)

    raw_input("hit enter:")


    # need to kill off the processes.

    # a better wy of doing is would be to use
    # https://docs.python.org/2/library/subprocess.html#subprocess.Popen.kill
    # but I don't feel like figuring it out :p

    call("pkill gst-switch-ui", shell=True)
    call("pkill gst-switch-srv", shell=True)
开发者ID:CarlFK,项目名称:Gst-Files,代码行数:37,代码来源:run-demo.py

示例4: test_get_preview_ports

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import run [as 别名]
    def test_get_preview_ports(self):
        """Test get_preview_ports"""

        for _ in range(self.NUM):
            serv = Server(path=PATH)
            try:
                serv.run()
                sources = TestSources(video_port=3000, audio_port=4000)
                for _ in range(self.NUM):
                    sources.new_test_audio()
                    sources.new_test_video()
                expected_result = map(
                    tuple,
                    [[x for x in range(3003, 3004 + self.NUM)]]
                    * self.NUM * self.FACTOR)
                res = map(tuple, self.get_preview_ports())
                print '\n', res, '\n'
                print expected_result
                assert set(expected_result) == set(res)
                sources.terminate_video()
                sources.terminate_audio()
                serv.terminate(1)
            finally:
                if serv.proc:
                    poll = serv.proc.poll()
                    print self.__class__
                    if poll == -11:
                        print "SEGMENTATION FAULT OCCURRED"
                    print "ERROR CODE - {0}".format(poll)
                    serv.terminate(1)
                    log = open('server.log')
                    print log.read()
开发者ID:hyades,项目名称:gst-switch,代码行数:34,代码来源:test_controller.py

示例5: get_preview_ports

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import run [as 别名]
def get_preview_ports(num):
    """Get Preview Ports when num number of sources are added"""
    video_port = 3000
    serv = Server(path=PATH, video_port=video_port)
    try:
        serv.run()
        sources = TestSources(video_port=video_port)
        
        
        expected_res = [ i for i in range(3003, 3003 + num)]

        controller = Controller()
        
        res = []
        for _ in range(num):
            sources.new_test_video()
        controller.establish_connection()
        res = controller.get_preview_ports()
        print res

        assert expected_res == res
    finally:
        if serv.proc:
                poll = serv.proc.poll()
                if poll == -11:
                    print "SEGMENTATION FAULT OCCURRED"
                print "ERROR CODE - {0}".format(poll)
                serv.terminate(1)
                log = open('server.log')
                print log.read()
开发者ID:bossjones,项目名称:gst-switch,代码行数:32,代码来源:performance_dbus.py

示例6: mark_tracking

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import run [as 别名]
    def mark_tracking(self, faces, index, generate_frames=False):
        """Create Controller object and call mark_tracking method"""
        for _ in range(self.NUM):
            serv = Server(path=PATH, video_format="debug")
            try:
                serv.run()
                sources = TestSources(video_port=3000)
                preview = PreviewSinks()
                preview.run()
                out_file = "output-{0}.data".format(index)
                video_sink = VideoFileSink(3001, out_file)
                sources.new_test_video(pattern=4)
                sources.new_test_video(pattern=5)
                controller = Controller()
                time.sleep(1)
                res = controller.mark_tracking(faces)
                print(res)
                time.sleep(1)
                sources.terminate_video()
                preview.terminate()
                video_sink.terminate()
                serv.terminate(1)
                if not generate_frames:
                    assert res is not None
                    assert self.verify_output(index, out_file) is True

            finally:
                serv.terminate_and_output_status(cov=True)
开发者ID:mithro,项目名称:gst-switch,代码行数:30,代码来源:test_controller.py

示例7: adjust_pip

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import run [as 别名]
    def adjust_pip(self,
                   xpos,
                   ypos,
                   width,
                   heigth,
                   index,
                   generate_frames=False):
        """Create Controller object and call adjust_pip"""
        for _ in range(self.NUM):
            serv = Server(path=PATH, video_format="debug")
            try:
                serv.run()
                sources = TestSources(video_port=3000)
                preview = PreviewSinks()
                preview.run()
                out_file = "output-{0}.data".format(index)
                video_sink = VideoFileSink(3001, out_file)
                sources.new_test_video(pattern=4)
                sources.new_test_video(pattern=5)
                controller = Controller()
                controller.set_composite_mode(Controller.COMPOSITE_PIP)
                time.sleep(3)
                res = controller.adjust_pip(xpos, ypos, width, heigth)
                time.sleep(3)
                sources.terminate_video()
                preview.terminate()
                video_sink.terminate()
                serv.terminate(1)
                if not generate_frames:
                    assert res is not None
                    assert self.verify_output(index, out_file) is True

            finally:
                serv.terminate_and_output_status(cov=True)
开发者ID:mithro,项目名称:gst-switch,代码行数:36,代码来源:test_controller.py

示例8: switch

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import run [as 别名]
    def switch(self, channel, port, index):
        """Create Controller object and call switch method"""
        for _ in range(self.NUM):
            serv = Server(path=PATH, video_format="debug")
            try:
                serv.run()

                sources = TestSources(3000)
                sources.new_test_video(pattern=4)
                sources.new_test_video(pattern=5)
                preview = PreviewSinks(3001)
                preview.run()
                out_file = "output-{0}.data".format(index)
                video_sink = VideoFileSink(3001, out_file)
                time.sleep(3)
                controller = Controller()
                res = controller.switch(channel, port)
                print(res)
                time.sleep(3)
                video_sink.terminate()
                sources.terminate_video()
                preview.terminate()
                serv.terminate(1)

            finally:
                serv.terminate_and_output_status(cov=True)
开发者ID:mithro,项目名称:gst-switch,代码行数:28,代码来源:test_controller.py

示例9: main

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import run [as 别名]
def main(args):

    print("running server")
    serv = Server(path=args.path)
    serv.run()

    wait(5)

    print("running source pattern=1")
    sources = TestSources(video_port=3000, audio_port=4000)
    sources.new_test_video(pattern=1)

    wait(5)

    print("running gst-switch-ui")
    # the & will run this in the background so control returns 
    # and we can bring up the 2nd source 

    # Replaced call with subprocess.Popen. 
    SwitchUi = subprocess.Popen("gst-switch-ui &",shell=True)

    wait(5)
       
    print("running source pattern=18")
    sources.new_test_video(pattern=18)

    raw_input("hit enter:")


    # Replaced pkill call with Popen.kill
    subprocess.Popen.kill(SwitchUi)
    serv.kill()
开发者ID:KKcorps,项目名称:Gst-Files,代码行数:34,代码来源:run-demo.py

示例10: test_on_preview_port_added

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import run [as 别名]
    def test_on_preview_port_added(self):
        """Create a Controller object, call add a source method and
        check that the callback fires
        """
        serv = Server(path=PATH, video_port=3000)
        try:
            serv.run()

            controller = Controller()
            controller.establish_connection()

            test_cb = Mock(side_effect=lambda mode, serve, type:
                           self.quit_mainloop_after(2))
            controller.on_preview_port_added(test_cb)

            sources = TestSources(video_port=3000)
            sources.new_test_video()
            sources.new_test_video()

            GLib.timeout_add_seconds(5, self.quit_mainloop)
            self.run_mainloop()

            print(test_cb.call_args_list)
            test_cb.assert_any_call(3003, 1, 7)
            test_cb.assert_any_call(3004, 1, 8)
            assert test_cb.call_count == 2

            serv.terminate(1)
        finally:
            serv.terminate_and_output_status(cov=True)
开发者ID:mithro,项目名称:gst-switch,代码行数:32,代码来源:test_controller.py

示例11: test_run

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import run [as 别名]
 def test_run(self):
     """Test the run method"""
     serv = Server(path='abc')
     serv._run_process = Mock(return_value=MockProcess())
     serv.run()
     assert serv.pid == 1
     assert serv.proc is not None
开发者ID:mithro,项目名称:gst-switch,代码行数:9,代码来源:test_server_unit.py

示例12: permutate_adjust_pip

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import run [as 别名]
def permutate_adjust_pip(num, delay):
    """Adjust_pip num number of times"""
    import random

    video_port = 3000
    serv = Server(path=PATH, video_port=video_port)
    try:
        serv.run()
        sources = TestSources(video_port=video_port)
        sources.new_test_video(pattern=6)
        sources.new_test_video(pattern=5)
        preview = PreviewSinks()
        preview.run()
        controller = Controller()

        for _ in range(num):

            xpos = random.randrange(-20, 20)
            ypos = random.randrange(-20, 20)
            res = controller.adjust_pip(xpos, ypos, 0, 0)
            time.sleep(delay)
            assert res is not None 
        preview.terminate()
        sources.terminate_video()

    finally:
        if serv.proc:
                poll = serv.proc.poll()
                if poll == -11:
                    print "SEGMENTATION FAULT OCCURRED"
                print "ERROR CODE - {0}".format(poll)
                serv.terminate(1)
                log = open('server.log')
                print log.read()
开发者ID:bossjones,项目名称:gst-switch,代码行数:36,代码来源:performance_dbus.py

示例13: test_compose_ports

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import run [as 别名]
    def test_compose_ports(self):
        """Test get_compose_port"""
        res = []
        expected_result = []
        for i in range(self.NUM):
            video_port = (i + 7) * 1000
            expected_result.append([video_port + 1] * self.NUM * self.FACTOR)
            serv = Server(path=PATH, video_port=video_port)
            try:
                serv.run()
                sources = TestSources(video_port=video_port)
                sources.new_test_video()
                sources.new_test_video()

                res.append(self.get_compose_port())
                sources.terminate_video()
                serv.terminate(1)
            finally:
                if serv.proc:
                    poll = serv.proc.poll()
                    print self.__class__
                    if poll == -11:
                        print "SEGMENTATION FAULT OCCURRED"
                    print "ERROR CODE - {0}".format(poll)
                    serv.terminate(1)
                    log = open('server.log')
                    print log.read()

        set_expected = [tuple(i) for i in expected_result]
        set_res = [tuple(i) for i in res]
        assert set(set_expected) == set(set_res)
开发者ID:hyades,项目名称:gst-switch,代码行数:33,代码来源:test_controller.py

示例14: switch

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import run [as 别名]
    def switch(self, channel, port, index):
        """Create Controller object and call switch method"""
        for _ in range(self.NUM):
            serv = Server(path=PATH)
            try:
                serv.run()

                sources = TestSources(3000)
                sources.new_test_video(pattern=4)
                sources.new_test_video(pattern=5)
                preview = PreviewSinks(3001)
                preview.run()
                out_file = "output-{0}.data".format(index)
                video_sink = VideoFileSink(3001, out_file)
                time.sleep(3)
                controller = Controller()
                res = controller.switch(channel, port)
                print res
                time.sleep(3)
                video_sink.terminate()
                sources.terminate_video()
                preview.terminate()
                serv.terminate(1)

            finally:
                if serv.proc:
                    poll = serv.proc.poll()
                    print self.__class__
                    if poll == -11:
                        print "SEGMENTATION FAULT OCCURRED"
                    print "ERROR CODE - {0}".format(poll)
                    serv.terminate(1)
                    log = open('server.log')
                    print log.read()
开发者ID:hyades,项目名称:gst-switch,代码行数:36,代码来源:test_controller.py

示例15: test_new_record

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import run [as 别名]
    def test_new_record(self):
        """Test new_record"""
        for _ in range(self.NUM):
            serv = Server(path=PATH, record_file="test-%Y.data")
            try:
                serv.run()

                sources = TestSources(video_port=3000)
                sources.new_test_video()
                sources.new_test_video()

                curr_time = datetime.datetime.now()
                time_str = curr_time.strftime('%Y')
                test_filename = "test-{0}.data".format(time_str)

                res = self.new_record()
                print res
                sources.terminate_video()
                serv.terminate(1)
                assert os.path.exists(test_filename) is True
            finally:
                if serv.proc:
                    poll = serv.proc.poll()
                    print self.__class__
                    if poll == -11:
                        print "SEGMENTATION FAULT OCCURRED"
                    print "ERROR CODE - {0}".format(poll)
                    serv.terminate(1)
                    log = open('server.log')
                    print log.read()
开发者ID:hyades,项目名称:gst-switch,代码行数:32,代码来源:test_controller.py


注:本文中的gstswitch.server.Server.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。