Example #1
0
                    return rc.FORBIDDEN
            else:
                return rc.FORBIDDEN
            if request.method == 'POST':
                global_id = request.POST.get('global_id', None)
                if global_id and Workflow.objects.filter(global_id=global_id).count() == 0:
                    return rc.NOT_FOUND

                input = request.POST.get('input', None)
                workflow = Workflow.objects.get(global_id=global_id)
                form = TavernaExecutionForm()
                taverna_execution = form.save(commit=False)
                n = TavernaExecution.objects.filter(title__contains=workflow.metadata['name'], ticket=ticket).count() + 1
                title = workflow.metadata['name'] + " execution " + str(n)
                taverna_execution.title = title
                taverna_execution.t2flow = get_file_data(workflow.t2flow)
                if input!=None:
                   taverna_execution.baclava = base64.b64decode(input)
                else:
                   taverna_execution.baclava = get_file_data(workflow.xml)
                taverna_execution.owner = user

                taverna_execution.status = 'Ready to run'
                taverna_execution.executionstatus = 0
                ## only for test mode
                taverna_execution.url = ''
                taverna_execution.taverna_atomic_id = 404
                ####
                taverna_execution.save()

                if taverna_execution.t2flow!= "" and taverna_execution.baclava!= "":
Example #2
0
def create(request):
    if request.method == 'POST' and request.POST.get('workflowId', None):
        form = TavernaExecutionForm()
        workflow = Workflow.objects.get(global_id=request.POST['workflowId'])
        taverna_execution = form.save(commit=False)
        taverna_execution.title = request.POST['title']
        taverna_execution.t2flow = get_file_data(workflow.t2flow)

        if request.POST.get('default_inputs', 'off') == 'on':
            if request.POST['input_definition_tab'] == 'baclava':

                # get file from post request
                taverna_execution.baclava = get_file_data(
                    request.FILES['inputFile']).replace('\r', '')

                # if filename is a csv file we convert to baclava
                fname = request.FILES['inputFile'].name
                if (fname.lower().endswith(".csv")):
                    try:
                        tavernaIO = Taverna2WorkflowIO()
                        tavernaIO.loadInputsFromCSVString(
                            taverna_execution.baclava)

                        # the xml baclava file
                        taverna_execution.baclava = tavernaIO.inputsToBaclava()

                    # fail to load from csv
                    except Exception:
                        client.captureException()

            if request.POST['input_definition_tab'] == 'dataset':
                dataset_query = DatasetQuery.objects.get(
                    id=request.POST['dataset_queryid'])
                tavernaIO = Taverna2WorkflowIO()
                tavernaIO.loadFromT2FLOWString(taverna_execution.t2flow)
                tavernaIO.loadInputsFromCSVFile

                input_ports = tavernaIO.getInputPorts()
                results = dataset_query.get_results(request.ticket)
                header = dataset_query.get_header(request.ticket)

                idx = 1
                for input in input_ports:
                    dataset_results_field = request.POST[input]
                    values = []

                    if dataset_results_field in _CUSTOM_HEADERS:
                        tmpInput = "CustomInput-%d" % (idx,)

                        custom_value = str( request.POST[tmpInput] )
                        custom_vector = [ custom_value for _ in range(len(results)) ]

                        values.extend(custom_vector)
                    else:
                        index = header.index(dataset_results_field)
                        for row in results:
                            values.append(row[index])

                    tavernaIO.setInputPortValues(input, values)
                    idx += 1

                taverna_execution.baclava = tavernaIO.inputsToBaclava()
        else:
            taverna_execution.baclava = get_file_data(workflow.xml)

        #taverna_execution.baclava = get_file_data(workflow.xml)
        taverna_execution.owner = request.user
        taverna_execution.status = 'Ready to run'
        taverna_execution.executionstatus = 0
        ## only for test mode
        taverna_execution.url = request.POST['taverna_url']
        taverna_execution.taverna_atomic_id = request.POST['taverna_servers']
        ####
        taverna_execution.save()
        request.session['statusmessage'] = "The workflow execution has been correctly created"
        return redirect('workspace')

    if request.method == 'GET' and request.GET.get('workflow_id',None):
        workflow = Workflow.objects.get(pk=request.GET['workflow_id'])
        n = TavernaExecution.objects.filter(title__contains=workflow.metadata['name'], ticket=request.ticket).count() + 1
        form = TavernaExecutionForm()
        form.fields['workflowId'].initial = workflow.global_id
        form.fields['title'].initial = workflow.metadata['name'] + " execution " + str(n)
        tavernaIO = Taverna2WorkflowIO()
        dataset_queries = request.user.datasetquery_set.all().values('id','name')
        return render_to_response(
        'scs_workspace/create.html',
        {'form': form, 'workflow': workflow, 'dataset_queries':dataset_queries},
        RequestContext(request)
        )
    else:
        raise PermissionDenied
Example #3
0
            props = {
                'outgoing_port': request.POST.get('outgoing_port', ''),
                'granted_roles': request.POST.get('granted_roles', ''),
                'listening_port': request.POST.get('listening_port', ''),
                'outgoing_address': request.POST.get('outgoing_address', ''),

            }
            configuration_file = create_configuration_file(props)

        # update/set by file content
        elif 'sumbitwithcontent' in request.POST:
            configuration_file = request.POST.get('filecontent')

        # update/set by file upload
        elif 'sumbitwithfile' in request.POST:
            configuration_file = get_file_data(request.FILES.get('fileupload'))

        # check if the file is correct or not
        configuration_file_ok = False
        try:
            extract_configurations(configuration_file)
            configuration_file_ok = True
        except Exception, e:
            configuration_file_ok = False

        if configuration_file_ok:
            if "newconfiguration" in request.POST:
                if cloudfacade.create_securityproxy_configuration(request.ticket, request.POST['name'], configuration_file):
                    data['statusmessage'] = "Security configuration file correctly created."
                    return  redirect('security_configuration')
                else: