把scrcpy录屏方法封装在conftest.py文件里,在本地直接运行可以成功,但是放在jenkins上运行报错
Jenkins报错信息:
______________________ ERROR at setup of Test001.test002 ______________________
@pytest.fixture(scope="class", autouse=True)
def record():
cmd = shlex.split("scrcpy --record mp.mp4")
> p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
conftest.py:14:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
D:\python\python36\lib\subprocess.py:709: in __init__
restore_signals, start_new_session)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <subprocess.Popen object at 0x000002347B29C198>
args = 'scrcpy --record mp.mp4', executable = None, preexec_fn = None
close_fds = False, pass_fds = (), cwd = None, env = None
startupinfo = <subprocess.STARTUPINFO object at 0x000002347B29C0B8>
creationflags = 0, shell = False, p2cread = Handle(604), p2cwrite = -1
c2pread = 11, c2pwrite = Handle(780), errread = -1, errwrite = Handle(768)
unused_restore_signals = True, unused_start_new_session = False
def _execute_child(self, args, executable, preexec_fn, close_fds,
pass_fds, cwd, env,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite,
unused_restore_signals, unused_start_new_session):
"""Execute program (MS Windows version)"""
assert not pass_fds, "pass_fds not supported on Windows."
if not isinstance(args, str):
args = list2cmdline(args)
# Process startup details
if startupinfo is None:
startupinfo = STARTUPINFO()
if -1 not in (p2cread, c2pwrite, errwrite):
startupinfo.dwFlags |= _winapi.STARTF_USESTDHANDLES
startupinfo.hStdInput = p2cread
startupinfo.hStdOutput = c2pwrite
startupinfo.hStdError = errwrite
if shell:
startupinfo.dwFlags |= _winapi.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = _winapi.SW_HIDE
comspec = os.environ.get("COMSPEC", "cmd.exe")
args = '{} /c "{}"'.format (comspec, args)
# Start the process
try:
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
# no special security
None, None,
int(not close_fds),
creationflags,
env,
os.fspath(cwd) if cwd is not None else None,
> startupinfo)
E FileNotFoundError: [WinError 2] The system cannot find the file specified
scrcpy录屏方法封装:
@pytest.fixture(scope="class", autouse=True)
def record():
cmd = shlex.split("scrcpy --record mp.mp4")
p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
yield
#os.kill(p.pid, signal.CTRL_C_EVENT)
# os.popen('taskkill.exe/pid:'+str(p.pid))
os.kill(p.pid, signal.SIGTERM)
sleep(1)
with open("mp.mp4", "rb") as f:
content = f.read()
allure.attach(content, attachment_type=allure.attachment_type.MP4)
请老师帮忙查看下是哪里的问题,如何在Jenkins上成功运行,谢谢