本文整理汇总了Python中gstswitch.server.Server.kill方法的典型用法代码示例。如果您正苦于以下问题:Python Server.kill方法的具体用法?Python Server.kill怎么用?Python Server.kill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gstswitch.server.Server
的用法示例。
在下文中一共展示了Server.kill方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_kill_fail
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import kill [as 别名]
def test_kill_fail(self):
"""Test when kill fails"""
serv = Server(path=PATH)
serv.proc = 1
serv.pid = -300
with pytest.raises(ServerProcessError):
serv.kill()
示例2: test_kill
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import kill [as 别名]
def test_kill(self, monkeypatch):
"""Test kill ServerProcessError"""
serv = Server(path='abc')
serv.proc = Mock()
monkeypatch.setattr(os, 'kill', Mock(side_effect=OSError))
with pytest.raises(ServerProcessError):
serv.kill()
示例3: main
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import kill [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()
示例4: test_kill_cov
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import kill [as 别名]
def test_kill_cov(self, monkeypatch):
"""Test kill and gcov_flush ServerProcessError"""
serv = Server(path='abc')
serv.proc = MockProcess(False)
serv.gcov_flush = Mock()
serv.make_coverage = Mock()
monkeypatch.setattr(os, 'kill', Mock(side_effect=OSError))
with pytest.raises(ServerProcessError):
serv.kill(True)
示例5: test_video_sources
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import kill [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()
示例6: test_audio_sources
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import kill [as 别名]
def test_audio_sources(self):
"""Test audio sources"""
audio_port = 4000
serv = Server(PATH, audio_port=audio_port)
try:
serv.run()
preview = PreviewSinks()
preview.run()
for i in range(self.NUM):
self.add_audio_sources(i * 10 + 1, audio_port)
preview.terminate()
serv.terminate()
finally:
if serv.proc:
serv.kill()
示例7: test_normal_kill
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import kill [as 别名]
def test_normal_kill(self, monkeypatch):
"""Test kill when normally called"""
serv = Server(path='abc')
serv.proc = Mock()
monkeypatch.setattr(os, 'kill', Mock())
res = serv.kill()
assert res is True
assert serv.proc is None
示例8: open
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import kill [as 别名]
cmd.split(),
stdout=tempf,
stderr=tempf,
bufsize=-1,
shell=False)
params = [(65,3004), (65, 3003)]
i = 0
p = psutil.Process(s.pid)
cpu_usage_file = open("cpu.log", "w")
while 1:
# print(i)
cpu = p.get_cpu_percent(interval=INTERVAL)
mem = p.get_memory_percent()
print(cpu)
print(mem)
cpu_usage_file.write(str(cpu) + '\n' + str(mem) + '\n')
controller.switch(params[i][0], params[i][1])
# time.sleep(1)
i+=1
i%=2
#end all
sources.terminate_audio()
vid1.terminate()
vid2.terminate()
s.terminate()
finally:
if s.proc:
s.kill()
示例9: test_no_process_kill
# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import kill [as 别名]
def test_no_process_kill(self):
"""Test when no process exists and kill is called"""
serv = Server(path=PATH)
with pytest.raises(ServerProcessError):
serv.kill()