Django Amazon S3 Heroku。通过对等连接重置。删除对collectstatic脚本的确认。

时间:2021-10-27 23:07:09

Ok, so I get the well known error [Errno 104] Connection reset by peer When I do collectstatic on my Django project. The project is on Heroku and I want to send the staticfiles to Amazon S3. I know I have the permissions and I know it works cause the first time I ran the command, it copied 10 files and then reset the conection.

好的,所以当我在Django项目上执行collectstatic时,就会得到众所周知的错误[Errno 104]连接被peer重置。项目在Heroku上,我想把staticfiles发送到Amazon S3。我知道我有权限,我知道它可以工作,因为我第一次运行这个命令时,它复制了10个文件,然后重置了conection。

Ok, so I was thinking, maybe I could write a python script that calls python manage.py collectstatic on the terminal every two hours, just to check if the connection works. The problem is that collectstatic has a confirmation:

好,我在想,也许我可以写一个叫python manage的python脚本。py collectstatic在终端上,每两个小时检查连接是否正常。问题是collectstatic有一个确认:

You have requested to collect static files at the destination
location as specified in your settings.

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: 

Is there a way for the script to programatically accept this?

是否有一种方法可以让脚本程序地接受这一点?

2 个解决方案

#1


1  

$ python manage.py collectstatic --no-input

The Django docs are usually very good, it's right there in the command's --help menu:

Django文档通常都很好,它就在命令的帮助菜单中:

$ python manage.py collectstatic --help
...
  --noinput, --no-input
                    Do NOT prompt the user for input of any kind.

#2


0  

Ok this solved it for me:

好吧,这就解决了我的问题

import os

correr = True
for x in range(0, 10):
    respuesta = os.system("python manage.py collectstatic --noinput")
    if not str(respuesta) == "256":
        print "RESPUESTA NO FUE 256, OJALA HAYA FUNCIONADO"
        break

#1


1  

$ python manage.py collectstatic --no-input

The Django docs are usually very good, it's right there in the command's --help menu:

Django文档通常都很好,它就在命令的帮助菜单中:

$ python manage.py collectstatic --help
...
  --noinput, --no-input
                    Do NOT prompt the user for input of any kind.

#2


0  

Ok this solved it for me:

好吧,这就解决了我的问题

import os

correr = True
for x in range(0, 10):
    respuesta = os.system("python manage.py collectstatic --noinput")
    if not str(respuesta) == "256":
        print "RESPUESTA NO FUE 256, OJALA HAYA FUNCIONADO"
        break