Skip to content

Commit

Permalink
[Cumulative patch] - Backport minor fixes from master (#4006)
Browse files Browse the repository at this point in the history
* [Cumulative patch] - Backport minor fixes from master

*  - fix travis build

* - fix travis build
  • Loading branch information
Alessio Fabiani authored and francbartoli committed Oct 17, 2018
1 parent 5654588 commit 241847b
Show file tree
Hide file tree
Showing 16 changed files with 207 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -81,7 +81,7 @@ install:
- sudo apt-get install -y python-dev libxml2 libxml2-dev libxslt1-dev zlib1g-dev libjpeg-dev libpq-dev libgdal-dev git default-jdk
- sudo add-apt-repository -y ppa:webupd8team/java
- sudo apt-get update
- sudo apt-get install -y --force-yes oracle-java8-installer ant maven2 --no-install-recommends
- sudo apt-get install -y --force-yes oracle-java8-set-default ant maven --no-install-recommends
- sudo update-java-alternatives --set java-8-oracle
- pip install -r requirements.txt --upgrade
- pip install -e . --upgrade
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
@@ -1,4 +1,4 @@
FROM geonode/geonode:2.7.x
FROM geonode/geonode:2.8.x
MAINTAINER GeoNode development team

COPY requirements.txt /usr/src/app/
Expand Down
2 changes: 1 addition & 1 deletion README.rst
@@ -1,7 +1,7 @@
.. raw:: html

<div align="right">
<a href="http://travis-ci.org/GeoNode/geonode"><img src="https://secure.travis-ci.org/GeoNode/geonode.png"></a> <a href="https://coveralls.io/github/GeoNode/geonode?branch=master"><img src="https://coveralls.io/repos/github/GeoNode/geonode/badge.svg?branch=master"></a> <a href="https://codecov.io/gh/GeoNode/geonode)
<a href="http://travis-ci.org/GeoNode/geonode"><img src="https://secure.travis-ci.org/GeoNode/geonode.png"></a> <a href="https://codecov.io/gh/GeoNode/geonode)
[![travis-ci.org"><img src="https://codecov.io/gh/GeoNode/geonode/branch/master/graph/badge.svg"></a> <a href="https://www.gnu.org/licenses/gpl-3.0.en.html"><img src="docs/img/gpl.png" alt="GPL badge"></a></div><img src="docs/img/geonode-logo_for_readme.gif" alt="GeoNode Logo" width="450px"/><div style="text-align:center"><hr><b>A powerful yet easy to use web-based application and platform for deploying spatial data infrastructures (SDI).</b><hr></div>


Expand Down
36 changes: 36 additions & 0 deletions codecov.yml
@@ -0,0 +1,36 @@
codecov:
notify:
require_ci_to_pass: yes

coverage:
precision: 2
round: down
range: "70...100"

status:
project: yes
patch: yes
changes: no

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: "header, diff"
behavior: default
require_changes: no

ignore:
- */management/*
- */test*
- */wsgi*
- */middleware*
- */context_processors*
- geonode/qgis_server/*
- geonode/contrib/*
- geonode/upload/*
4 changes: 2 additions & 2 deletions docker-compose.yml
Expand Up @@ -38,7 +38,7 @@ services:

celery:
restart: unless-stopped
image: geonode/geonode:2.7.x
image: geonode/geonode:2.8.x
container_name: celery4${COMPOSE_PROJECT_NAME}
stdin_open: true
# tty: true
Expand Down Expand Up @@ -88,7 +88,7 @@ services:

django:
restart: unless-stopped
image: geonode/geonode:2.7.x
image: geonode/geonode:2.8.x
container_name: django4${COMPOSE_PROJECT_NAME}
stdin_open: true
# tty: true
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/devel/devel_env/index.txt
Expand Up @@ -122,7 +122,7 @@ Summary of the installation steps

.. code-block:: console

$ sudo apt-get install -y --force-yes openjdk-7-jdk --no-install-recommends
$ sudo apt-get install -y openjdk-7-jdk --no-install-recommends

*Supporting tools*

Expand Down Expand Up @@ -374,7 +374,7 @@ Summary of the installation steps
Start working on Geonode the next day after install
===================================================

With every restart of your machine, you have to restart GeoNode as well. That means, you will not be able to open http://localhost:8000 directly after starting your machine new. In order to be able to use GeoNode now, you have to activate your virtualenv and to start the development servers.
With every restart of your machine, you have to restart GeoNode as well. That means, you will not be able to open http://localhost:8000 directly after starting your machine new. In order to be able to use GeoNode now, you have to activate your virtualenv and to start the development servers.

.. note:: *username* is the name of your machine and personal folder!

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/devel/devel_env/index_bk.txt
Expand Up @@ -122,7 +122,7 @@ Summary of the installation steps

.. code-block:: console

$ sudo apt-get install -y --force-yes openjdk-6-jdk --no-install-recommends
$ sudo apt-get install -y openjdk-6-jdk --no-install-recommends

*supporting tools*

Expand Down
Expand Up @@ -155,15 +155,15 @@ Place the following content inside the file
<Directory "/home/geonode/my_geonode/my_geonode/uploaded/documents/">
Order allow,deny
Options Indexes FollowSymLinks
Allow from all
Deny from all
Require all granted
IndexOptions FancyIndexing
</Directory>

<Directory "/home/geonode/my_geonode/my_geonode/uploaded/layers/">
Order allow,deny
Options Indexes FollowSymLinks
Allow from all
Deny from all
Require all granted
IndexOptions FancyIndexing
</Directory>
Expand Down
10 changes: 7 additions & 3 deletions docs/tutorials/install_and_admin/quick_install.txt
Expand Up @@ -53,10 +53,14 @@ The steps to install geonode and all dependencies in Ubuntu 16.04 are as follows

.. note:: If you want to run geonode on your local instance, just run::

sudo geonode-updateip localhost
sudo geonode-updateip -p localhost

IP_ADDRESS=$(ip route get 8.8.8.8 | awk '{print $NF; exit}')
sudo geonode-updateip $IP_ADDRESS
sudo geonode-updateip -p $IP_ADDRESS

.. note:: If geoserver and geonode are not on the same machine then add your local geonode address::

sudo geonode-updateip -p $IP_ADDRESS -l yourlocaladdress

NB: The IP address must be set to enable access from another machine, e.g. the host machine if geonode is installed in a virtual machine.

Expand Down Expand Up @@ -102,7 +106,7 @@ This option installs geonode in a virtual environment. This option is very usefu

sudo add-apt-repository ppa:ubuntugis/ppa && sudo apt-get update
sudo apt-get install gdal-bin

# install the correct PyGDAL version
gdal-config --version | cut -c 1-5 | xargs -I % pip install 'pygdal>=%.0,<=%.999'

Expand Down
Expand Up @@ -40,7 +40,7 @@ Clone the repository::

Launch the stack with the build of GeoNode so any changes you did will be immediately available::

docker-compose up -f docker-compose.override.localhost.yml --build
docker-compose -f docker-compose.override.localhost.yml up --build

.. note::
**docker-compose.override.localhost.yml** containse environment variables to allow you run the instances on *localhost*. You can use this file as template in order to run on other public addresses.
Expand Down
5 changes: 3 additions & 2 deletions geonode/geoserver/helpers.py
Expand Up @@ -85,10 +85,11 @@ def check_geoserver_is_up():
"""Verifies all geoserver is running,
this is needed to be able to upload.
"""
url = "%sweb/" % ogc_server_settings.LOCATION
url = "%s" % ogc_server_settings.LOCATION
resp, content = http_client.request(url, "GET")
msg = ('Cannot connect to the GeoServer at %s\nPlease make sure you '
'have started it.' % ogc_server_settings.LOCATION)
'have started it.' % url)
logger.debug(resp)
assert resp['status'] == '200', msg


Expand Down
96 changes: 96 additions & 0 deletions geonode/geoserver/tests.py
Expand Up @@ -42,6 +42,9 @@
from geonode.layers.populate_layers_data import create_layer_data
from geonode.layers.models import Layer

import logging
logger = logging.getLogger(__name__)

san_andres_y_providencia_sld = """<?xml version="1.0" encoding="UTF-8"?>
<sld:StyledLayerDescriptor xmlns:sld="http://www.opengis.net/sld"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down Expand Up @@ -901,6 +904,99 @@ def test_ogc_server_defaults(self):
# Make sure we get None vs a KeyError when the key does not exist
self.assertIsNone(ogc_settings.SFDSDFDSF)

# Testing OWS endpoints
from urlparse import urljoin
from django.core.urlresolvers import reverse
from .ows import _wcs_get_capabilities, _wfs_get_capabilities, _wms_get_capabilities
wcs = _wcs_get_capabilities()
logger.debug(wcs)
self.assertIsNotNone(wcs)

try:
wcs_url = urljoin(settings.SITEURL, reverse('wcs_endpoint'))
except BaseException:
wcs_url = urljoin(ogc_settings.PUBLIC_LOCATION, 'ows')
self.assertEquals(wcs,
'%s?version=2.0.1&request=GetCapabilities&service=WCS' % wcs_url)

wfs = _wfs_get_capabilities()
logger.debug(wfs)
self.assertIsNotNone(wfs)

try:
wfs_url = urljoin(settings.SITEURL, reverse('wfs_endpoint'))
except BaseException:
wfs_url = urljoin(ogc_settings.PUBLIC_LOCATION, 'ows')
self.assertEquals(wfs,
'%s?version=1.1.0&request=GetCapabilities&service=WFS' % wfs_url)

wms = _wms_get_capabilities()
logger.debug(wms)
self.assertIsNotNone(wms)

try:
wms_url = urljoin(settings.SITEURL, reverse('wms_endpoint'))
except BaseException:
wms_url = urljoin(ogc_settings.PUBLIC_LOCATION, 'ows')
self.assertEquals(wms,
'%s?version=1.1.1&request=GetCapabilities&service=WMS' % wms_url)

# Test OWS Download Links
import urllib
from geonode.geoserver.ows import wcs_links, wfs_links, wms_links
instance = Layer.objects.all()[0]
bbox = instance.bbox
srid = instance.srid
height = 512
width = 512

# WMS Links
wms_links = wms_links(ogc_settings.public_url + 'wms?',
instance.alternate.encode('utf-8'),
bbox,
srid,
height,
width)
self.assertIsNotNone(wms_links)
self.assertEquals(len(wms_links), 3)
wms_url = urljoin(ogc_settings.PUBLIC_LOCATION, 'wms')
identifier = urllib.urlencode({'layers': instance.alternate.encode('utf-8')})
for _link in wms_links:
logger.debug('%s --> %s' % (wms_url, _link[3]))
self.assertTrue(wms_url in _link[3])
logger.debug('%s --> %s' % (identifier, _link[3]))
self.assertTrue(identifier in _link[3])

# WFS Links
wfs_links = wfs_links(ogc_settings.public_url + 'wfs?',
instance.alternate.encode('utf-8'),
bbox,
srid)
self.assertIsNotNone(wfs_links)
self.assertEquals(len(wfs_links), 6)
wfs_url = urljoin(ogc_settings.PUBLIC_LOCATION, 'wfs')
identifier = urllib.urlencode({'typename': instance.alternate.encode('utf-8')})
for _link in wfs_links:
logger.debug('%s --> %s' % (wfs_url, _link[3]))
self.assertTrue(wfs_url in _link[3])
logger.debug('%s --> %s' % (identifier, _link[3]))
self.assertTrue(identifier in _link[3])

# WCS Links
wcs_links = wcs_links(ogc_settings.public_url + 'wcs?',
instance.alternate.encode('utf-8'),
bbox,
srid)
self.assertIsNotNone(wcs_links)
self.assertEquals(len(wcs_links), 2)
wcs_url = urljoin(ogc_settings.PUBLIC_LOCATION, 'wcs')
identifier = urllib.urlencode({'coverageid': instance.alternate.encode('utf-8')})
for _link in wcs_links:
logger.debug('%s --> %s' % (wcs_url, _link[3]))
self.assertTrue(wcs_url in _link[3])
logger.debug('%s --> %s' % (identifier, _link[3]))
self.assertTrue(identifier in _link[3])

@on_ogc_backend(geoserver.BACKEND_PACKAGE)
def test_importer_configuration(self):
"""
Expand Down
26 changes: 14 additions & 12 deletions geonode/geoserver/views.py
Expand Up @@ -727,14 +727,13 @@ def layer_acls(request):


# capabilities
def get_layer_capabilities(layer, version='1.1.0', access_token=None, tolerant=False):
def get_layer_capabilities(layer, version='1.3.0', access_token=None, tolerant=False):
"""
Retrieve a layer-specific GetCapabilities document
"""
workspace, layername = layer.alternate.split(":") if ":" in layer.alternate else (None, layer.alternate)
if not layer.remote_service:
# TODO implement this for 1.3.0 too
wms_url = '%s%s/%s/ows?service=wms&version=%s&request=GetCapabilities'\
wms_url = '%s%s/%s/wms?service=wms&version=%s&request=GetCapabilities'\
% (ogc_server_settings.LOCATION, workspace, layername, version)
if access_token:
wms_url += ('&access_token=%s' % access_token)
Expand All @@ -744,7 +743,6 @@ def get_layer_capabilities(layer, version='1.1.0', access_token=None, tolerant=F

http = httplib2.Http()
response, getcap = http.request(wms_url)
# TODO this is to bypass an actual bug of GeoServer 2.12.x
if tolerant and ('ServiceException' in getcap or response.status == 404):
# WARNING Please make sure to have enabled DJANGO CACHE as per
# https://docs.djangoproject.com/en/2.0/topics/cache/#filesystem-caching
Expand All @@ -759,18 +757,19 @@ def get_layer_capabilities(layer, version='1.1.0', access_token=None, tolerant=F
return getcap


def format_online_resource(workspace, layer, element):
def format_online_resource(workspace, layer, element, namespaces):
"""
Replace workspace/layer-specific OnlineResource links with the more
generic links returned by a site-wide GetCapabilities document
"""
layerName = element.find('.//Name')
if not layerName:
layerName = element.find('.//wms:Capability/wms:Layer/wms:Layer/wms:Name',
namespaces)
if layerName is None:
return

layerName.text = workspace + ":" + layer if workspace else layer
layerresources = element.findall('.//OnlineResource')
if not layerresources:
layerresources = element.findall('.//wms:OnlineResource', namespaces)
if layerresources is None:
return

for resource in layerresources:
Expand Down Expand Up @@ -825,13 +824,16 @@ def get_capabilities(request, layerid=None, user=None,
tolerant=tolerant)
if layercap: # 1st one, seed with real GetCapabilities doc
try:
namespaces = {'wms': 'http://www.opengis.net/wms',
'xlink': 'http://www.w3.org/1999/xlink',
'xsi': 'http://www.w3.org/2001/XMLSchema-instance'}
layercap = etree.fromstring(layercap)
rootdoc = etree.ElementTree(layercap)
format_online_resource(workspace, layername, rootdoc)
service_name = rootdoc.find('.//Service/Name')
format_online_resource(workspace, layername, rootdoc, namespaces)
service_name = rootdoc.find('.//wms:Service/wms:Name', namespaces)
if service_name:
service_name.text = cap_name
rootdoc = rootdoc.find('.//Capability/Layer/Layer')
rootdoc = rootdoc.find('.//wms:Capability/wms:Layer/wms:Layer', namespaces)
except Exception as e:
import traceback
traceback.print_exc()
Expand Down

0 comments on commit 241847b

Please sign in to comment.