diff --git a/ansible/README.md b/ansible/README.md index 1645f1f..878bd7d 100644 --- a/ansible/README.md +++ b/ansible/README.md @@ -40,6 +40,12 @@ You can also change the war used to deploy geoserver with the following variable * Change the 'DATAQS_APPS' setting to add/remove individual dataqs processors * Change the 'CELERYBEAT_SCHEDULE' setting to add/remove/modify scheduled dataqs celery tasks +### Additional Customizations + +* roles/dataqs/templates/custom_settings.py: + * Replace this file with your own or add/modify/remove settings in the current file + * Any settings and/or apps specified in this file will be added to the GeoNode instance + ### Setting up a vagrant box To configure a local development virtual machine, you will need to have virtualbox and vagrant installed. diff --git a/ansible/roles/dataqs/tasks/main.yml b/ansible/roles/dataqs/tasks/main.yml index 8752063..add2cd7 100644 --- a/ansible/roles/dataqs/tasks/main.yml +++ b/ansible/roles/dataqs/tasks/main.yml @@ -42,18 +42,19 @@ strip=1 notify: restart uwsgi -- name: copy settings to geonode application +- name: copy dataqs settings to geonode application template: src=dataq_settings.py dest={{geonode_root}}/dataq_settings.py - notify: restart uwsgi + +- name: copy custom settings to geonode application + template: src=custom_settings.py dest={{geonode_root}}/custom_settings.py - name: import dataq settings in geonode configuration lineinfile: name="{{geonode_root}}/local_settings.py" state=present insertafter="EOF" line="from dataq_settings import *" - notify: restart uwsgi -- name: enable dataq apps in geonode configuration - lineinfile: name={{geonode_root}}/local_settings.py state=present - insertafter=EOF line="dataqs_extend()" +- name: import custom settings in geonode configuration + lineinfile: name="{{geonode_root}}/local_settings.py" state=present + insertafter="EOF" line="from custom_settings import *" notify: restart uwsgi - name: install supervisor config for workers diff --git a/ansible/roles/dataqs/templates/custom_settings.py b/ansible/roles/dataqs/templates/custom_settings.py new file mode 100644 index 0000000..9040e87 --- /dev/null +++ b/ansible/roles/dataqs/templates/custom_settings.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +######################################################################### +# +# Copyright (C) 2012 OpenPlans +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +######################################################################### + +# Custom BSVE settings and apps for GeoNode/dataqs. +from settings import INSTALLED_APPS + +LANDSCAN_FILEPATH = \ + "http://web.ornl.gov/sci/landscan/landscan2011/LS11sample_Cyprus.zip" + +CUSTOM_APPS = ( + # Insert any custom/additional Django apps here +) + +INSTALLED_APPS += CUSTOM_APPS \ No newline at end of file diff --git a/ansible/roles/dataqs/templates/dataq_settings.py b/ansible/roles/dataqs/templates/dataq_settings.py index 4d00452..ed10ea3 100644 --- a/ansible/roles/dataqs/templates/dataq_settings.py +++ b/ansible/roles/dataqs/templates/dataq_settings.py @@ -20,6 +20,7 @@ # Django settings for the GeoNode project. from celery.schedules import crontab +from settings import INSTALLED_APPS # Append these to INSTALLED_APPS DATAQS_APPS = ( @@ -287,7 +288,4 @@ 'description': "The Jewish Synagogues dataset is derived from the TGS 2009 Q4 'PlacesofWorship' data layer and contains all Jewish Synagogues in the United States. The remaining portion of this abstract, as well as much of the remaining metadata, references the entire Places of Worship database from which this subset was derived: The Places of Worship dataset is composed of any type of building or portion of a building that is used, constructed, designed, or adapted to be used as a place for religious and spiritual activities. These facilities include, but are not limited to, the following types: chapels, churches, mosques, shrines, synagogues, and temples. The license free Large Protestant Churches, Mosques, Jewish Synagogues, and Roman Catholic Churches in Large Cities datasets were merged together to create the initial data for the Places of Worship dataset. Additional entities have been added from TGS research. This dataset contains Buddhist, Christian, Hindu, Islamic, Judaic, and Sikh places of worship. Unitarian places of worship have been included when a congregation from one of these religions meets at a church owned by a Unitarian congregation. Some Protestant denominations are not currently represented in this dataset. The Places of Worship dataset is not intended to include homes of religious leaders (unless they also serve as a place of organized worship), religious schools (unless they also serve as a place of organized worship for people other than those enrolled in the school), Jewish Mikvahs or Hillel facilities, and buildings that serve a purely administrative purpose. If a building's primary purpose is something other than worship (e.g., a community center, a public school), but a religious group uses the building for worship on a regular basis, it was included in this dataset if it otherwise met the criteria for inclusion. Convents and monasteries are included in this dataset, regardless of whether or not the facilities are open to the public, because religious services are regularly held at these locations. TGS was not tasked with ensuring the completeness of this layer. No entities are included in this dataset for the Commonwealth of the Northern Mariana Islands. On 08/07/2007, TGS ceased making phone calls to verify information about religious locations. Therefore, most entities in this dataset were verified using alternative reference sources such as topographic maps, parcel maps, various sources of imagery, and internet research. The [CONTHOW] (contact how) value for these entities has been set to 'ALT REF'. The website http://www.gettochurch.org was used for verification during processing. As of August 2009, this website is no longer active. Records with '-DOD' appended to the end of the [NAME] value are located on a military base, as defined by the Defense Installation Spatial Data Infrastructure (DISDI) military installations and military range boundaries." } ] - -def dataqs_extend(): - from settings import INSTALLED_APPS - INSTALLED_APPS += DATAQS_APPS +INSTALLED_APPS += DATAQS_APPS \ No newline at end of file diff --git a/dataqs/landscan/landscan.py b/dataqs/landscan/landscan.py index aad5089..5291445 100755 --- a/dataqs/landscan/landscan.py +++ b/dataqs/landscan/landscan.py @@ -17,11 +17,9 @@ # limitations under the License. ############################################################################### import os -from urllib import urlretrieve import zipfile - import gdal - +from django.conf import settings from dataqs.helpers import style_exists from dataqs.processor_base import GeoDataProcessor @@ -41,19 +39,28 @@ def get_landscan(self): Downloads the sample landscan image for Cyprus """ - url = "http://web.ornl.gov/sci/landscan/" + \ - "landscan2011/LS11sample_Cyprus.zip" - - zip_dir = os.path.join(self.tmp_dir, "landscan.zip") - urlretrieve(url, zip_dir) - - # Open up the zip file - zip_ref = zipfile.ZipFile(zip_dir, 'r') - landscan_dir = os.path.join(self.tmp_dir, "landscan") - zip_ref.extractall(landscan_dir) - zip_ref.close() - - return landscan_dir + landscan = getattr(settings, "LANDSCAN_FILEPATH", + "http://web.ornl.gov/sci/landscan/" + + "landscan2011/LS11sample_Cyprus.zip") + print(landscan) + if landscan.startswith("http"): + filepath = os.path.join(self.tmp_dir, landscan.split("/")[-1]) + self.download(landscan, filepath) + else: + filepath = landscan + + if os.path.splitext(filepath)[1].lower() == ".zip": + # Open up the zip file + zip_ref = zipfile.ZipFile(filepath, 'r') + landscan_dir = os.path.join(self.tmp_dir, "landscan") + zip_ref.extractall(landscan_dir) + zip_ref.close() + print(landscan_dir) + return landscan_dir + else: + # Assume it's a directory + print(filepath) + return filepath def convert_landscan(self, landscan_dir): """ diff --git a/local_settings.py.template b/local_settings.py.template index 41a7e88..a777f70 100644 --- a/local_settings.py.template +++ b/local_settings.py.template @@ -2,4 +2,15 @@ from django.conf import settings INSTALLED_APPS = settings.INSTALLED_APPS + ( 'dataqs', + 'dataqs.aqicn', + 'dataqs.airnow', + 'dataqs.forecastio', + 'dataqs.gfms', + 'dataqs.gdacs', + 'dataqs.hifld', + 'dataqs.nasa_gpm', + 'dataqs.spei', + 'dataqs.usgs_quakes', + 'dataqs.gistemp', + 'dataqs.worldclim', )