Alejandro Veintimilla
Alejandro Veintimilla

Reputation: 11523

Django Amazon S3 Heroku. Connection reset by peer. Remove confirmation on collectstatic script

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.

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:

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?

Upvotes: 3

Views: 292

Answers (2)

Paul M Furley
Paul M Furley

Reputation: 1025

$ python manage.py collectstatic --no-input

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

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

Upvotes: 2

Alejandro Veintimilla
Alejandro Veintimilla

Reputation: 11523

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

Upvotes: 0

Related Questions