示例#1
0
 def celery_status(self):
     if self.status == 2:
         return 'SUCCESS'
     if not self.cid:
         return 'NO SUBMIT'
     status = AsyncResult(self.cid).status
     if status != 'SUCCESS' and self.started_at and utc_now().timestamp(
     ) - self.started_at.timestamp() > 300:
         return 'ABORT'
     return status
示例#2
0
def notification_service(self):
    from task.models import Notice
    connection = mail.get_connection()
    connection.open()
    cid = str(self.request.id)
    notices = Notice.objects.filter(status=0, cid='')
    notices.update(cid=cid)
    for notice in Notice.objects.filter(cid=cid):
        notice.send()
        notice.started_at = utc_now()
        notice.status = 1
        notice.save()
    for notice in Notice.objects.filter(status=1):
        if notice.celery_status == 'ABORT':
            notice.cid = cid
            notice.send()
        notice.finished_at = utc_now()
        notice.status = 2
        notice.save()
    connection.close()
示例#3
0
    def run(self):
        self.task.status = self.task.StatusChoices.RUNNING
        self.task.started_at = utc_now()
        self.task.save()
        self.task.run_notices()

        self.task.rc, self.task.msg = subprocess.getstatusoutput(self.task.cmd)
        if 'Invalid sequence file. Please make sure file is in FASTA format' in self.task.msg:
            self.task.rc = 1
        self.task.save()

        if self.task.rc:
            self.task.fail()
        else:
            self.task.success()
示例#4
0
 def success(self):
     self.status = self.StatusChoices.SUCCESS
     self.finished_at = utc_now()
     self.save()
     self.success_notices()
示例#5
0
 def fail(self):
     self.status = self.StatusChoices.FAIL
     self.finished_at = utc_now()
     self.save()
     self.fail_notices()