(я удалил конфиденциальную информацию из команд)
Хорошо, я пытаюсь перебрать каталог и отправить команду bash с подпроцессом для каждого XML-файла, найденного в каталоге:
import os
import subprocess
directory ='/redacted/for/privacy'
for filename in os.listdir(directory):
if filename.endswith('.xml'):
print(f"\nSending: {directory}/{filename}\n")
push_command = f"hiptest-publisher --push {directory}/{filename} --push-format junit --token=666"
process = subprocess.run(push_command, stdout=subprocess.PIPE)
print(push_command)
output, error = process.communicate()
else:
continue
Но он продолжает выдавать ошибку об обнаружении файла:
FileNotFoundError: [Errno 2] No such file or directory: 'hiptest-publisher --push /redacted/for/privacy/TEST-crossPlatform.hiptest_publisher.test_project.Test20190621164008.xml --push-format junit --token=666': 'hiptest-publisher --push /redacted/for/privacy/TEST-crossPlatform.hiptest_publisher.test_project.Test20190621164008.xml --push-format junit --token=666'
Почему моя команда является файлом?