我正在运行由拨号方案触发的python2代码。为了处理保存的录音,我需要运行python 3脚本。有没有办法做到这一点。如果我将代码切换到python3,代码就不起作用了。这是扩展same=>n,AGI(code.py)
在code.py中给出标题#!/usr/bin/env python2
我可以运行该函数
def run_cmd(cmd):
#This runs the general command
sys.stderr.write(cmd)
sys.stderr.flush()
sys.stdout.write(cmd)
sys.stdout.flush()
result = sys.stdin.readline().strip()
checkresult(result)它能够处理各种agi命令,但在切换到Python3时,#!/usr/bin/env python3代码将无法运行。现在,我需要使用google cloud engine来处理用python3编写的内容
有没有办法让它运行我已经做到了?
def run_sys_command(command):
subprocess.call(command, shell=True)
checkresult(result)
command = "sudo python3 /root/Downloads/check2.py"
run_sys_command(command)有没有办法运行python3脚本或者用agi直接运行python3脚本。
我已经检查了所有东西的权限
发布于 2021-04-11 03:18:25
当然,你可以在AGI中运行线程。
但它应该在AGI脚本结束之前停止。
最简单的方法是做你想做的事情--设置某种类型的队列(在mysql中是rabbitmq/simple task list?)并在asterisk进程范围之外处理它。
将python3作为AGI脚本运行没有任何问题。我在我的项目中有很多这样的脚本。检查你的代码就行了。
https://stackoverflow.com/questions/67031940
复制相似问题