本文整理汇总了Python中gstswitch.server.Server.terminate方法的典型用法代码示例。如果您正苦于以下问题:Python Server.terminate方法的具体用法?Python Server.terminate怎么用?Python Server.terminate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gstswitch.server.Server
的用法示例。
在下文中一共展示了Server.terminate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_preview_ports
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import terminate [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()
示例2: switch
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import terminate [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)
示例3: get_encode_port
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import terminate [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()
示例4: adjust_pip
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import terminate [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)
示例5: test_on_preview_port_added
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import terminate [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)
示例6: permutate_adjust_pip
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import terminate [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()
示例7: get_preview_ports
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import terminate [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()
示例8: test_compose_ports
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import terminate [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)
示例9: switch
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import terminate [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()
示例10: test_new_record
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import terminate [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()
示例11: mark_tracking
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import terminate [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)
示例12: get_audio_port
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import terminate [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())
示例13: test_terminate_cov
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import terminate [as 别名]
def test_terminate_cov(self):
"""Test terminate and gcov_flush ServerProcessError"""
serv = Server(path='abc')
serv.proc = MockProcess(False)
serv.gcov_flush = Mock()
serv.make_coverage = Mock()
with pytest.raises(ServerProcessError):
serv.terminate(True)
示例14: test_establish
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import terminate [as 别名]
def test_establish(self):
"""Test for establish_connection"""
serv = Server(path=PATH, video_format="debug")
try:
serv.run()
for i in range(self.NUM):
print(i)
self.establish_connection()
serv.terminate(1)
finally:
serv.terminate_and_output_status(cov=True)
示例15: test_video_sources
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import terminate [as 别名]
def test_video_sources(self):
"""Test video sources"""
video_port = 3000
serv = Server(PATH, video_port=video_port)
try:
serv.run()
preview = PreviewSinks()
preview.run()
for i in range(self.NUM):
self.add_video_sources(i * 10 + 1, video_port)
preview.terminate()
serv.terminate()
finally:
if serv.proc:
serv.kill()