我有一个烧瓶路由,它使用 subprocess 模块在服务器上调用 Python 脚本。我的问题是这个脚本会下载文件,并且无法确定执行所需的时间。我想通过获取子进程的输出以某种方式更新客户端。整个路线如下:
@app.route("/adyen_request_download", methods=["POST", "GET"])
def adyen_request_download():
merchant_manager = MerchantManager()
error = None
if request.method == "POST":
pfjs = []
prefixes = []
extensions = []
ftpd = "/var/ftp/CONTROLE_TESTE"
for result in request.get_json():
if result["name"] == "pfj-select":
pfjs.append(result["value"])
if result["name"] == "prefix-select":
prefixes.append(result["value"])
if result["name"] == "extension-select":
extensions.append(result["value"])
if result["name"] == "start-date":
start_date = result["value"]
logging.info(f"Requisição de download manual de arquivos realizada.")
logging.info(f">> PFJs: {str(pfjs)}")
logging.info(f">> Prefixos: {str(prefixes)}")
logging.info(f">> Extensões: {str(extensions)}")
logging.info(f">> Data: {start_date}")
if prefixes and not extensions:
run_command = f'python ../InputDataController/acquirer_file_downloader.py --acquirer "adyen" --pfj {" ".join(pfjs)} --prefix {" ".join(prefixes)} --date "{start_date}" --ftpd "{ftpd}" --force'
elif extensions and not prefixes:
run_command = f'python ../InputDataController/acquirer_file_downloader.py --acquirer "adyen" --pfj {" ".join(pfjs)} --ext {" ".join(extensions)} --date "{start_date}" --ftpd "{ftpd}" --force'
elif not prefixes and not extensions:
run_command = f'python ../InputDataController/acquirer_file_downloader.py --acquirer "adyen" --pfj {" ".join(pfjs)} --date "{start_date}" --ftpd "{ftpd}" --force'
我看到了getoutput方法,但它不是我想要的,我需要在某个文件中实时获取shell输出。是否有可能?
相关分类