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


Python Controller.establish_connection方法代码示例

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


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

示例1: test_on_preview_port_added

# 需要导入模块: from gstswitch.controller import Controller [as 别名]
# 或者: from gstswitch.controller.Controller import establish_connection [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

示例2: test_normal

# 需要导入模块: from gstswitch.controller import Controller [as 别名]
# 或者: from gstswitch.controller.Controller import establish_connection [as 别名]
 def test_normal(self, monkeypatch):
     """Test if the parameters are valid"""
     monkeypatch.setattr(Connection, 'connect_dbus', Mock())
     monkeypatch.setattr(Connection, 'signal_subscribe', Mock())
     controller = Controller(address='unix:abstract=abcd')
     controller.establish_connection()
     assert controller.connection is not None
开发者ID:techman83,项目名称:gst-switch,代码行数:9,代码来源:test_controller_unit.py

示例3: get_preview_ports

# 需要导入模块: from gstswitch.controller import Controller [as 别名]
# 或者: from gstswitch.controller.Controller import establish_connection [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

示例4: get_audio_port

# 需要导入模块: from gstswitch.controller import Controller [as 别名]
# 或者: from gstswitch.controller.Controller import establish_connection [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

示例5: do_adjust_pip

# 需要导入模块: from gstswitch.controller import Controller [as 别名]
# 或者: from gstswitch.controller.Controller import establish_connection [as 别名]
 def do_adjust_pip(self, line):
     c = Controller()
     c.establish_connection()
     if len(line.split()) != 4:
         print "Inavlid number of arguments"
         return
     print c.adjust_pip(*map(int, line.split()))
开发者ID:a740122,项目名称:gst-switch,代码行数:9,代码来源:console.py

示例6: get_encode_port

# 需要导入模块: from gstswitch.controller import Controller [as 别名]
# 或者: from gstswitch.controller.Controller import establish_connection [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

示例7: get_encode_port

# 需要导入模块: from gstswitch.controller import Controller [as 别名]
# 或者: from gstswitch.controller.Controller import establish_connection [as 别名]
 def get_encode_port(self):
     """Create a Controller object and call get_encode_port method"""
     res = []
     controller = Controller()
     controller.establish_connection()
     for _ in range(self.NUM * self.FACTOR):
         res.append(controller.get_encode_port())
     return res
开发者ID:mithro,项目名称:gst-switch,代码行数:10,代码来源:test_controller.py

示例8: do_switch

# 需要导入模块: from gstswitch.controller import Controller [as 别名]
# 或者: from gstswitch.controller.Controller import establish_connection [as 别名]
 def do_switch(self, line):
     try:
         val = self.SWITCH_MAPPING[line.lower()]
     except KeyError:
         print "Invalid"
         return
     c = Controller()
     c.establish_connection()
     print c.switch(self.SWITCH_MAPPING[line.split()[0]], int(line.split()[1]))
开发者ID:a740122,项目名称:gst-switch,代码行数:11,代码来源:console.py

示例9: do_set_composite_mode

# 需要导入模块: from gstswitch.controller import Controller [as 别名]
# 或者: from gstswitch.controller.Controller import establish_connection [as 别名]
 def do_set_composite_mode(self, line):
     try:
         val = self.COMPOSITE_MAPPING[line.lower()]
     except KeyError:
         print "Invalid"
         return
     c = Controller()
     c.establish_connection()
     print c.set_composite_mode(val)
开发者ID:a740122,项目名称:gst-switch,代码行数:11,代码来源:console.py

示例10: test_action_fails

# 需要导入模块: from gstswitch.controller import Controller [as 别名]
# 或者: from gstswitch.controller.Controller import establish_connection [as 别名]
 def test_action_fails(self):
     """Test what happens if the requested action fails"""
     controller = Controller(address='unix:abstract=abcde')
     controller.establish_connection = Mock(return_value=None)
     controller.connection = MockConnection(
         return_variant=True, should_fail=True)
     assert controller.click_video(1, 2, 3, 4) is False
开发者ID:a740122,项目名称:gst-switch,代码行数:9,代码来源:test_controller_unit.py

示例11: test_unpack

# 需要导入模块: from gstswitch.controller import Controller [as 别名]
# 或者: from gstswitch.controller.Controller import establish_connection [as 别名]
 def test_unpack(self):
     """Test if unpack fails"""
     controller = Controller(address='unix:abstract=abcde')
     controller.establish_connection = Mock(return_value=None)
     controller.connection = MockConnection(return_variant=False)
     with pytest.raises(ConnectionReturnError):
         controller.new_record()
开发者ID:a740122,项目名称:gst-switch,代码行数:9,代码来源:test_controller_unit.py

示例12: test_unpack

# 需要导入模块: from gstswitch.controller import Controller [as 别名]
# 或者: from gstswitch.controller.Controller import establish_connection [as 别名]
 def test_unpack(self):
     """Test if unpack fails"""
     controller = Controller(address='unix:abstract=abcde')
     controller.establish_connection = Mock(return_value=None)
     controller.connection = MockConnection(True)
     with pytest.raises(ConnectionReturnError):
         controller.switch(Controller.VIDEO_CHANNEL_A, 2)
开发者ID:techman83,项目名称:gst-switch,代码行数:9,代码来源:test_controller_unit.py

示例13: test_normal

# 需要导入模块: from gstswitch.controller import Controller [as 别名]
# 或者: from gstswitch.controller.Controller import establish_connection [as 别名]
 def test_normal(self):
     """Test if valid"""
     controller = Controller(address='unix:abstract=abcde')
     controller.establish_connection = Mock(return_value=None)
     controller.connection = MockConnection(True)
     face = [(1, 2, 3, 4), (1, 1, 1, 1)]
     controller.mark_tracking(face)
开发者ID:bossjones,项目名称:gst-switch,代码行数:9,代码来源:test_controller_unit.py

示例14: test_unpack

# 需要导入模块: from gstswitch.controller import Controller [as 别名]
# 或者: from gstswitch.controller.Controller import establish_connection [as 别名]
 def test_unpack(self):
     """Test if unpack fails"""
     controller = Controller(address='unix:abstract=abcdefghijk')
     controller.establish_connection = Mock(return_value=None)
     controller.connection = MockConnection(True)
     with pytest.raises(ConnectionReturnError):
         controller.set_composite_mode(1)
开发者ID:bossjones,项目名称:gst-switch,代码行数:9,代码来源:test_controller_unit.py

示例15: test_on_new_mode_online

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

            controller = Controller()
            controller.establish_connection()

            test_cb = Mock(side_effect=self.quit_mainloop)
            controller.on_new_mode_online(test_cb)
            controller.set_composite_mode(0)

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

            test_cb.assert_called_once_with(0)

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


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