def start_scenarios_again(start_id, end_id): for scenario_id in range(start_id, end_id + 1): workflow_template = workermodels.WorkflowTemplate.objects.get( code=workermodels.WorkflowTemplate.DEFAULT_TEMPLATE_CODE) workerexecutor.start_workflow(scenario_id, workflow_template.id)
def start_scenarios_again(start_id, end_id): for scenario_id in range(start_id, end_id+1): workflow_template = workermodels.WorkflowTemplate.objects.get( code=workermodels.WorkflowTemplate.DEFAULT_TEMPLATE_CODE) workerexecutor.start_workflow(scenario_id, workflow_template.id)
def start(self): # Make a workflow for the export and run it if self.export_scenario_data: # Run the corresponding template workflow_template_code = ExportRun.WORKFLOW_TEMPLATE_DATA_EXPORT else: workflow_template_code = ExportRun.WORKFLOW_TEMPLATE_MAP_EXPORT workflow_template = WorkflowTemplate.objects.get( code=workflow_template_code) start_workflow(self.id, workflow_template.id, log_level='INFO', scenario_type='flooding_exportrun')
def start(self): # Make a workflow for the export and run it if self.export_scenario_data: # Run the corresponding template workflow_template_code = ExportRun.WORKFLOW_TEMPLATE_DATA_EXPORT else: workflow_template_code = ExportRun.WORKFLOW_TEMPLATE_MAP_EXPORT workflow_template = WorkflowTemplate.objects.get( code=workflow_template_code) start_workflow( self.id, workflow_template.id, log_level='INFO', scenario_type='flooding_exportrun')
def handle(self, *args, **options): scenarios = options.get('scenarios') templatecode = options.get('templatecode') workflow_template = None if templatecode is None: print "Pass a templatecode." return else: try: workflow_template = WorkflowTemplate.objects.get(code=templatecode) except: print "Templete {} does not exsist.".templatecode return if scenarios is None: sc = models.Scenario.objects.all() else: scenarios = scenarios.replace(' ', '').split(',') sc = models.Scenario.objects.filter(id__in=scenarios) for s in sc: result = start_workflow(s.id, workflow_template.id, log_level='DEBUG') print "The end."
def handle(self, *args, **options): scenarios = options.get('scenarios') templatecode = options.get('templatecode') workflow_template = None if templatecode is None: print "Pass a templatecode." return else: try: workflow_template = WorkflowTemplate.objects.get( code=templatecode) except: print "Templete {} does not exsist.".templatecode return if scenarios is None: sc = models.Scenario.objects.all() else: scenarios = scenarios.replace(' ', '').split(',') sc = models.Scenario.objects.filter(id__in=scenarios) for s in sc: result = start_workflow(s.id, workflow_template.id, log_level='DEBUG') print "The end."
def post(self, request): if request.user.is_superuser is False: return render_to_response("403.html") scenario_id = request.POST.get("scenario_id") template_id = request.POST.get("template_id") success = executor.start_workflow(scenario_id, template_id) message = "Scenario {0} is {1} in de wachtrij geplaatst." if success is False: message = message.format(scenario_id, "NIET") else: message = message.format(scenario_id, "") context = {"success": success, "message": message} return HttpResponse(content=json.dumps(context))
def post(self, request): if request.user.is_superuser is False: return render_to_response('403.html') scenario_id = request.POST.get('scenario_id') template_id = request.POST.get('template_id', u'') success = False if template_id != u'': success = executor.start_workflow(scenario_id, template_id) message = "Scenario {0} is {1} in de wachtrij geplaatst." if success is False: message = message.format(scenario_id, "NIET") else: message = message.format(scenario_id, "") context = {'success': success, 'message': message} return HttpResponse(content=json.dumps(context))
def handle(self, *args, **kwargs): print "Starting workflow 4 (3Di)..." workflow_template = WorkflowTemplate.objects.get(code='4') result = start_workflow( args[0], # scenario id workflow_template.id, log_level='DEBUG')
def new_export(request): """ Renders a html with only the form for creating a new export run * It uses the Django-validation bud adds a custom validation rule: there has to be at least one scenario selected. Otherwis an error is added to the error list. * If the form information is valid, a new export run is created and saved, Also the needed information for the genereation of the waterdepth map is saved in a CSV-file. """ if not (request.user.is_authenticated() and request.user.has_perm('exporttool.can_create')): return HttpResponse(_("No permission to create export")) if request.method == 'POST': form = ExportRunForm(request.POST) # necessary to call 'is_valid()' before adding custom errors valid = form.is_valid() scenario_ids = simplejson.loads(request.REQUEST.get('scenarioIds')) if not scenario_ids: form._errors['scenarios'] = form.error_class( [u"U heeft geen scenario's geselecteerd."]) valid = False if valid: new_export_run = ExportRun( export_type=ExportRun.EXPORT_TYPE_WATER_DEPTH_MAP, name=form.cleaned_data['name'], description=form.cleaned_data['description'], owner=request.user, creation_date=datetime.datetime.now(), export_max_waterdepth=form.cleaned_data['export_max_waterdepth'], export_max_flowvelocity=form.cleaned_data['export_max_flowvelocity'], export_possibly_flooded=form.cleaned_data['export_possibly_flooded'] ) new_export_run.save() new_export_run.scenarios = Scenario.objects.filter( pk__in=scenario_ids) # This part is obsolete, soon to be removed if the task is finished. if (new_export_run.export_type == ExportRun.EXPORT_TYPE_WATER_DEPTH_MAP): # Choices here are gridmaxwaterdepth and gridmaxflowvelocity export_result_type = ResultType.objects.get(name='gridmaxwaterdepth').id #export_result_type = 1 # TODO: get the id from ResultType table. # Get the EXPORT_FOLDER settings (from the settings of # the export-tool) export_folder = Setting.objects.get(key='EXPORT_FOLDER').value csv_file_location = os.path.join( export_folder, str(new_export_run.id) + '.csv') text_file_location = os.path.join( export_folder, str(new_export_run.id) + '.txt') new_export_run.create_csv_file_for_gis_operation( export_result_type, csv_file_location) new_export_run.create_general_file_for_gis_operation( text_file_location) # Make a workflow for the export and run it workflow_template = WorkflowTemplate.objects.get(code='3') result = start_workflow( new_export_run.id, workflow_template.id, log_level='INFO', scenario_type='flooding_exportrun') #print 'ActionWorkflowExportRun: %r' % result return HttpResponse( 'redirect_in_js_to_' + reverse('flooding_tools_export_index')) else: form = ExportRunForm() return render_to_response('export/exports_new.html', {'form': form})