Example #1
0
    def process_file(self):
        src = os.path.join(settings.MEDIA_ROOT, self.docfile.name)
        dst = "%s/%s.%s" % (self.get_root_path(), self.slug, self.docfile_basename.split(".")[-1].lower())
        fss.copy_file(src, dst)

        task = task_generate_document.apply_async(args=[self.pk], countdown=5)
        self = Document.objects.get(id=self.id)
        self.task_id = task.task_id
        self.save()
Example #2
0
    def process_file(self):
        file = open(os.path.join(settings.MEDIA_ROOT,self.docfile.name), 'r')
        filepath = "%s/%s.%s" % (
            self.get_root_path(), self.slug,
            self.docfile_basename.split('.')[-1].lower())
        f = open(filepath, "w")
        f.write(file.read())
        f.close()
        file.close()

        self.title = self.docfile_basename
        task = task_generate_document.apply_async(args=[self.pk], countdown=5)
        self.task_id = task.task_id
        self.save()
 def handle(self, *args, **options):
     
     if options.get('status') is not None:
         docs = Document.objects.filter(status = options.get('status'))
     else:
         docs = Document.objects.filter(pk__in=args)
     
     for doc in docs: 
         
         task = task_generate_document.apply_async(args=[doc.pk], countdown=5)
         
         print "create task for %s" % doc
         
         doc.status = Document.STATUS.waiting
         doc.task_start = None
         doc.task_id = task.task_id
         doc.save()
    def handle(self, *args, **options):

        if options.get('status') is not None:
            docs = Document.objects.filter(status=options.get('status'))
        else:
            docs = Document.objects.filter(pk__in=args)

        for doc in docs:

            task = task_generate_document.apply_async(args=[doc.pk],
                                                      countdown=5)

            print "create task for %s" % doc

            doc.status = Document.STATUS.waiting
            doc.task_start = None
            doc.task_id = task.task_id
            doc.save()
Example #5
0
 def set_file(self, path = None, file=None, filename = None):
     
     if path is not None:
         file = open(path, 'r')
         filepath = "%s/%s.%s" % (self.get_root_path(), self.slug, path.split('.')[-1].lower())
     else:
         filepath = "%s/%s.%s" % (self.get_root_path(), self.slug, filename.split('.')[-1].lower())
         
     f = open(filepath, "w")  
     f.write(file.read())
     f.close()
     file.close()
     
     self.filename = filepath.split('/')[-1].lower()
     
     task = task_generate_document.apply_async(args=[self.pk], countdown=5)
 
     self.task_id = task.task_id
     self.save()
Example #6
0
 def set_file(self, path = None, file=None, filename = None):
     
     if path is not None:
         file = open(path, 'r')
         filepath = "%s/%s.%s" % (self.get_root_path(), self.slug, path.split('.')[-1].lower())
     else:
         filepath = "%s/%s.%s" % (self.get_root_path(), self.slug, filename.split('.')[-1].lower())
         
     f = open(filepath, "w")  
     f.write(file.read())
     f.close()
     file.close()
     
     self.filename = filepath.split('/')[-1].lower()
     
     task = task_generate_document.apply_async(args=[self.pk], countdown=5)
 
     self.task_id = task.task_id
     self.save()