
import logging
LOGGER = logging.getLogger('apps.uploads')

from django.core.management.base import BaseCommand, CommandError
from apps.uploads.models import DropboxUploadFile, ManualUploadFile

class Command(BaseCommand):
    help = """Regular run of new dropbox links:

      manage.py process_uploads

    """
    def handle(self, **options):
        for cls in [DropboxUploadFile, ManualUploadFile]:
            for d_file in cls.objects.filter(retrieval_start__isnull=True):
                print " + Downloading: %s" % d_file.url
                d_file.download_now()
                if d_file.retrieval_error:
                    print " ! Error downloading"


@@ -1,63 +1,115 @@
-%0Aimport logging%0ALOGGER = logging.getLogger('apps.uploads')%0A
+%22%22%22Download from urls any uploads from outside sources%22%22%22%0Aimport logging%0A%0Afrom django.utils.timezone import now
 %0Afro
@@ -242,160 +242,276 @@
 File
-%0A%0Aclass Command(BaseCommand):%0A    help = %22%22%22Regular run of new dropbox links:%0A%0A      manage.py process_uploads%0A%0A    %22%22%22%0A    def handle(self, **options):
+, ResumableUploadFile%0A%0ALOGGER = logging.getLogger('apps.uploads')%0A%0Aclass Command(BaseCommand):%0A    %22%22%22Run command for uploads%22%22%22%0A    help = __doc__ + %22%22%22:%0A%0A      manage.py process_uploads%0A%0A    %22%22%22%0A    @staticmethod%0A    def handle(**_):%0A        %22%22%22Handle script call%22%22%22
 %0A   
@@ -530,9 +530,9 @@
  in 
-%5B
+(
 Drop
@@ -566,9 +566,9 @@
 File
-%5D
+)
 :%0A  
@@ -827,9 +827,322 @@
 oading%22%0A
+        count = ResumableUploadFile.objects.filter(retrieval_start__isnull=True).update(%0A            retrieval_error='Retry resumable upload, can not happen in server.',%0A            retrieval_start=now(),%0A        )%0A        if count:%0A            print(%22 * Resumable uploads marked as impossible: %7B%7D%22.format(count))
 %0A

Mark resuable uploads as broken if they are