This commit is contained in:
Anastasiya Semenkevich 2024-10-04 17:45:36 +03:00
parent ffc5da3805
commit 790c1dcc42
1 changed files with 7 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import logging
import os
import signal
import subprocess
import time
import typing
import allure
@ -39,12 +40,16 @@ def kill_process(pid):
if get_platform() == "Windows":
subprocess.call(f"taskkill /F /T /PID {str(pid)}")
elif get_platform() in ["Linux", "Darwin"]:
os.kill(pid, signal.SIGKILL)
p = psutil.Process(pid)
p.kill()
time.sleep(1)
assert not p.is_running()
else:
raise NotImplementedError(f"Unsupported platform: {get_platform()}")
except Exception as e:
print(f"Failed to terminate process {pid}: {e}")
@allure.step('System execute command')
def execute(
command: list,
@ -75,6 +80,7 @@ def run(
check=True
)
@allure.step('Get pid by process name')
def get_pid_by_process_name(name):
pid_list = []