本文整理汇总了Python中gstswitch.server.Server.is_alive方法的典型用法代码示例。如果您正苦于以下问题:Python Server.is_alive方法的具体用法?Python Server.is_alive怎么用?Python Server.is_alive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gstswitch.server.Server
的用法示例。
在下文中一共展示了Server.is_alive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_is_not_alive
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import is_alive [as 别名]
def test_is_not_alive(self, monkeypatch):
""" Test that is_alive returns True when the
underlying proc returns None on Poll
"""
serv = Server()
serv.proc = Mock()
monkeypatch.setattr(serv.proc, "poll", Mock(return_value=123))
assert serv.is_alive() is False
示例2: IntegrationTestbase
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import is_alive [as 别名]
class IntegrationTestbase(object):
"""Base class for integration tests."""
# Tests are not allowed to have an __init__ method
def setup_method(self, _):
"""Set up called automatically before every test_XXXX method."""
self.log = logging.getLogger()
self.log.setLevel(logging.DEBUG)
logging.basicConfig(
format="%(filename)s:%(lineno)d (%(funcName)s): %(message)s")
self.serv = None
self._sources = None
self.controller = None
def setup_server(self, record_file=False):
"""Set up a gst-switch server for testing."""
assert self.serv is None
self.log.info("setting up Server")
self.serv = Server(path=PATH, video_format="debug",
record_file=record_file)
self.log.info("running Server")
self.serv.run()
assert self.serv.is_alive()
self.log.info("waiting for Server to open Controller-Port")
self.serv.wait_for_output('tcp:host=::,port=5000')
self.log.info("setting up TestSources")
self._sources = TestSources(
video_port=self.serv.video_port,
audio_port=self.serv.audio_port)
def setup_controller(self):
"""Create Controller object and call setup_controller."""
self.log.info("setting up Controller")
self.controller = Controller()
self.log.info("connecting Controller to Server")
self.controller.establish_connection()
self.serv.wait_for_output('registered: ')
assert self.controller.connection is not None
def new_test_video(self, pattern=None):
"""Start a new Video-Testsource and wait until it's ready"""
self.serv.wait_for_output(':::3000')
self._sources.new_test_video(pattern=pattern)
def setup_video_sources(self, count):
""" Starts some Test-Video streams and waits until they are ready
"""
self.log.info("starting 2 test-video sources")
for _ in range(0, count):
self.new_test_video()
self.log.info("waiting for the test-video sources to come up")
self.wait_for_sources(count)
def new_test_audio(self, freq=110, wave=AudioSrc.WAVE_SINE):
"""Start a new Audio-Testsource and wait until it's ready"""
self.serv.wait_for_output(':::4000')
self._sources.new_test_audio(freq=freq, wave=wave)
def setup_audio_sources(self, count):
""" Starts some Test-Audio streams and waits until they are ready
"""
self.log.info("starting 2 test-audio sources")
for _ in range(0, count):
self.new_test_audio()
self.log.info("waiting for the test-audio sources to come up")
self.wait_for_sources(count)
def wait_for_sources(self, count):
""" Blocks until the Server has reported, that the right number of
preview-ports are is started
"""
self.log.info("waiting for Server to start preview-port-outputs")
self.serv.wait_for_output('tcpserversink name=sink', count=count)
def teardown_method(self, _):
"""Tear down called automatically after every test_XXXX method."""
self.controller = None
# Kill all the sources
if self._sources is not None:
self.log.info("terminating Video-TestSource")
self._sources.terminate_video()
self.log.info("terminating Audio-TestSource")
self._sources.terminate_audio()
self._sources = None
if self.serv is not None:
self.log.info("terminating Server")
self.serv.terminate(cov=True)
#.........这里部分代码省略.........