Skip to content

Commit

Permalink
Merge pull request GeoNode#2 from lucernae/geosafe
Browse files Browse the repository at this point in the history
Move save impact layer to celery tasks
  • Loading branch information
ismailsunni committed Nov 4, 2015
2 parents 8329315 + 1f1ee0a commit 17e45bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
9 changes: 0 additions & 9 deletions geosafe/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from geonode.layers.models import Layer
from geonode.people.models import Profile
from geonode.layers.utils import file_upload

# geosafe
import os
Expand Down Expand Up @@ -256,11 +255,3 @@ def run_analysis_post_save(sender, instance, created, **kwargs):
"""Call InaSAFE headless here"""
arguments, output_file, layer_folder, output_folder = instance.generate_cli()
run_analysis_docker.delay(arguments=arguments, output_file=output_file, layer_folder=layer_folder, output_folder=output_folder)

impact_layer = file_upload(
output_file,
overwrite=True,
)
impact_layer.set_default_permissions()
instance.impact_layer = impact_layer
instance.save()
7 changes: 6 additions & 1 deletion geosafe/tasks/analysis.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from subprocess import call, Popen, PIPE
from celery.task import task

from geonode.layers.utils import file_upload

__author__ = 'lucernae'

Expand All @@ -16,6 +16,11 @@ def run_analysis_docker(arguments, output_file, layer_folder, output_folder):
# call system function
call(["inasafe", arguments, layer_folder, output_folder])
# TODO: Save the layer file and all info to geonode (upload?)
saved_layer = file_upload(
output_file,
overwrite=True,
)
saved_layer.set_default_permissions()


@task(name='geosafe.tasks.analysis.run_analysis_cli', queue='cleanup')
Expand Down

0 comments on commit 17e45bc

Please sign in to comment.