Я пытаюсь запустить двоичный файл с использованием подпроцесса в облачной функции Google на основе этого примера из https://github.com/zdenulo/google-cloud-functions-system-packages/tree/master/cf_ascii:
import os
import subprocess
import logging
from flask import make_response
def main(request):
text = request.args.get('text', '')
if not text:
return 'missing text parameter', 404
logging.info(f'received url: {text}')
cmd = f"./figlet -d fonts {text}".split(' ')
p = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
stdout, stderr = p.communicate()
error = stderr.decode('utf8')
if error:
return error, 403
out = stdout.decode('utf8')
response = make_response(out)
response.headers["content-type"] = "text/plain"
return response
Из того, что я прочитал, это должно быть возможно, но я получаю эту ошибку при выполнении:
...
File "/opt/python3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: './figlet'
Таким образом, похоже, что функции не хватает правильных разрешений, но я не могу понять, почему (настройки разрешений файлов, разрешения IAM / учетной записи службы ...) , Что мне здесь не хватает?