示例#1
0
def generate_csa(result_pk, monitor_pk=None):
    result = models.Results.objects.get(pk=result_pk)
    report_dir = result.get_report_dir()
    raw_data_dir = result.experiment.expDir

    try:
        monitor = models.FileMonitor.objects.get(pk=monitor_pk)
    except models.FileMonitor.DoesNotExist:
        monitor = models.FileMonitor()
        monitor.tags = "generate_csa"

    csa_file_name = "csa_{0:04d}.zip".format(int(result_pk))
    monitor.status = "Generating"
    monitor.local_dir = report_dir
    monitor.name = csa_file_name
    monitor.save()

    # Generate report PDF file.
    # This will create a file named report.pdf in results directory
    makePDF.write_report_pdf(result_pk)
    csa_path = makeCSA.makeCSA(report_dir, raw_data_dir, monitor.name)

    digest_hex, digest_64, size = md5_stats_file(csa_path)
    monitor.md5sum = digest_hex
    monitor.size = size
    monitor.status = "Generated"
    monitor.save()
示例#2
0
def export_upload_report(request):
    try:
        report_pk = int(request.POST.get("report"))
    except ValueError:
        raise Http404("'{0}' is not a valid report ID".format(report_pk))
    path = request.POST.get("file_path")
    report = get_object_or_404(models.Results, pk=report_pk)
    root = report.get_report_dir()
    full_path = os.path.join(root, path)
    if not os.path.exists(full_path):
        raise Http404("'{0}' does not exist as a file in report {1}".format(
            path, report_pk))
    tag = "report/{0}/".format(report_pk)
    monitor = models.FileMonitor(
        local_dir=os.path.dirname(full_path),
        name=os.path.basename(full_path),
        tags="upload," + tag,
        status="Queued",
    )

    monitor.save()
    result = export_upload_file.delay(monitor.id)
    monitor.celery_task_id = result.task_id
    monitor.save()

    return redirect("list_export_uploads", tag="")
示例#3
0
文件: test_tasks.py 项目: dkeren/TS
    def getReady(self, zip_location):
        '''
            Create a publisher and a monitor, also copy the panel archive under test
            into a temp folder, which ampliseq_zip_upload can do whatever it wants with.
        '''
        monitor = models.FileMonitor()
        monitor.name = "fake_fixed_design.zip"
        monitor.url = "fake_url"
        monitor.celery_task_id = "fake_celery_task_id"
        monitor.created = datetime.datetime.now()
        monitor.updated = datetime.datetime.now()
        monitor.save()

        self.temp_intial_dir = tempfile.mkdtemp()
        self.full_path = os.path.join(self.temp_intial_dir,
                                      'fake_fixed_panel.zip')
        shutil.copy(zip_location, self.full_path)
示例#4
0
def report_support_upload(request):
    form = SupportUploadForm(request.POST)
    # check for existing support upload
    data = {
        "created": False,
    }
    account = models.RemoteAccount.objects.get(
        remote_resource="support.iontorrent")
    if not account.has_access():
        data["error"] = "invalid_auth"
    if not form.is_valid():
        data["error"] = "invalid_form"
        data["form_errors"] = form.errors

    if "error" not in data:
        result_pk = form.cleaned_data['result']
        support_upload = models.SupportUpload.objects.filter(
            result=result_pk).order_by('-id').first()
        if not support_upload:
            data["created"] = True
            support_upload = models.SupportUpload(
                account=account,
                result_id=result_pk,
                user=request.user,
                local_status="Preparing",
                contact_email=form.cleaned_data['contact_email'],
                description=form.cleaned_data['description'])
            support_upload.save()

        async_result = AsyncResult(support_upload.celery_task_id)
        if (not support_upload.celery_task_id
                or async_result.status in celery.states.READY_STATES):
            if not support_upload.file:
                monitor = models.FileMonitor()
                monitor.save()
                support_upload.file = monitor
                support_upload.save()
            support_upload.file.status = "Queued",
            support_upload.file.tags = "support_upload,generate_csa"
            support_upload.file.save()

            generate = generate_csa.s(result_pk, support_upload.file.pk)
            errback = filemonitor_errback.s(support_upload.file.pk)
            gen_result = generate.apply_async(link_error=errback)
            support_upload.file.celery_task_id = gen_result.task_id

            auth_result = check_authentication.delay(support_upload.pk)
            upload_result = check_and_upload.apply_async(
                (support_upload.pk, auth_result.task_id, gen_result.task_id),
                countdown=1)

            support_upload.celery_task_id = upload_result.task_id
            support_upload.save()

        resource = SupportUploadResource()
        uri = resource.get_resource_uri(support_upload)
        data["resource_uri"] = uri
    # make CSA
    # check auth
    # start upload task
    # respond with support upload object for JS polling
    return HttpResponse(json.dumps(data, indent=4, sort_keys=True),
                        mimetype='application/json')