【发布时间】:2020-09-24 10:57:57
【问题描述】:
这是我的代码`
@app.route('/social_add/<us_id>/<us_phone>/<us_birth>/<us_gen>', methods=['POST', 'GET'])
def social_add(us_id, us_phone, us_birth, us_gen):
os.system("sudo chmod 777 /home/gor/tarber/static/user_image")
os.system("mkdir /home/gor/tarber/static/user_image/" + us_id)
os.system("sudo chmod 777 /home/gor/tarber/static/user_image/" + us_id)
这是错误`
gunicorn[119261]: sh: 1: sudo: not found
gunicorn[119261]: sh: 1: mkdir: not found
gunicorn[119261]: sh: 1: sudo: not found
我试过这个程序`
subprocess.Popen("sudo chmod 777 /home/gor/tarber/static/user_image", shell=True)
subprocess.Popen("mkdir /home/gor/tarber/static/user_image/" + us_id, shell=True)
subprocess.Popen("sudo chmod 777 /home/gor/tarber/static/user_image/" + us_id, shell=True)
但错误是一样的
【问题讨论】:
-
您是否尝试过使用
subprocess.run作为替代方案? SubProcess -
我已经找到解决方案 os.mdkri(filename, mode=0o777)
-
然后添加问题的答案
标签: python flask gunicorn python-venv