Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2.11
4.4.0
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Vcs-Git: https://github.com/geopython/pywps.git

Package: python-pywps
Architecture: all
Depends: ${misc:Depends}, ${python:Depends}, python-pkg-resources, python-dateutil, python-flufl.enum, python-jsonschema, python-lxml, python-owslib, python-werkzeug
Depends: ${misc:Depends}, ${python:Depends}, python-pkg-resources, python-dateutil, python-jsonschema, python-lxml, python-owslib, python-werkzeug
Suggests: grass, apache2, apache
Homepage: https://pywps.org
Description: OGC Web Processing Service (WPS) Implementation
Expand Down
9 changes: 7 additions & 2 deletions pywps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from lxml.builder import ElementMaker

__version__ = '4.2.11'
__version__ = '4.4.0'

LOGGER = logging.getLogger('PYWPS')
LOGGER.debug('setting core variables')
Expand Down Expand Up @@ -79,8 +79,13 @@ def get_version_from_ns(ns):

OGCUNIT = {
'degree': 'urn:ogc:def:uom:OGC:1.0:degree',
'degrees': 'urn:ogc:def:uom:OGC:1.0:degree',
'meter': 'urn:ogc:def:uom:OGC:1.0:metre',
'metre': 'urn:ogc:def:uom:OGC:1.0:metre',
'unity': 'urn:ogc:def:uom:OGC:1.0:unity'
'meteres': 'urn:ogc:def:uom:OGC:1.0:metre',
'meters': 'urn:ogc:def:uom:OGC:1.0:metre',
'unity': 'urn:ogc:def:uom:OGC:1.0:unity',
'feet': 'urn:ogc:def:uom:OGC:1.0:feet'
}

from pywps.app import Process, Service, WPSRequest
Expand Down
30 changes: 0 additions & 30 deletions pywps/_compat.py

This file was deleted.

12 changes: 5 additions & 7 deletions pywps/app/Process.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from pywps.inout.inputs import input_from_json
from pywps.inout.outputs import output_from_json
import pywps.configuration as config
from pywps._compat import PY2
from pywps.exceptions import (StorageNotSupported, OperationNotSupported,
ServerBusy, NoApplicableCode)
from pywps.app.exceptions import ProcessError
Expand Down Expand Up @@ -201,7 +200,7 @@ def _execute_process(self, async_, wps_request, wps_response):
LOGGER.debug("Stored processes: {}".format(stored))

if running < maxparallel or maxparallel == -1:
wps_response._update_status(WPS_STATUS.ACCEPTED, u"PyWPS Request accepted", 0)
wps_response._update_status(WPS_STATUS.ACCEPTED, "PyWPS Request accepted", 0)
LOGGER.debug("Accepted request {}".format(self.uuid))
self._run_async(wps_request, wps_response)

Expand All @@ -212,13 +211,13 @@ def _execute_process(self, async_, wps_request, wps_response):
raise ServerBusy('Maximum number of processes in queue reached. Please try later.')
LOGGER.debug("Store process in job queue, uuid={}".format(self.uuid))
dblog.store_process(self.uuid, wps_request)
wps_response._update_status(WPS_STATUS.ACCEPTED, u'PyWPS Process stored in job queue', 0)
wps_response._update_status(WPS_STATUS.ACCEPTED, 'PyWPS Process stored in job queue', 0)

# not async
else:
if running >= maxparallel and maxparallel != -1:
raise ServerBusy('Maximum number of parallel running processes reached. Please try later.')
wps_response._update_status(WPS_STATUS.ACCEPTED, u"PyWPS Request accepted", 0)
wps_response._update_status(WPS_STATUS.ACCEPTED, "PyWPS Request accepted", 0)
wps_response = self._run_process(wps_request, wps_response)

return wps_response
Expand All @@ -245,7 +244,7 @@ def _run_process(self, wps_request, wps_response):
os.environ['HOME'] = self.workdir
LOGGER.info('Setting HOME to current working directory: {}'.format(os.environ['HOME']))
LOGGER.debug('ProcessID={}, HOME={}'.format(self.uuid, os.environ.get('HOME')))
wps_response._update_status(WPS_STATUS.STARTED, u'PyWPS Process started', 0)
wps_response._update_status(WPS_STATUS.STARTED, 'PyWPS Process started', 0)
self.handler(wps_request, wps_response) # the user must update the wps_response.
# Ensure process termination
if wps_response.status != WPS_STATUS.SUCCEEDED and wps_response.status != WPS_STATUS.FAILED:
Expand Down Expand Up @@ -303,8 +302,7 @@ def launch_next_process(self):
return

(uuid, request_json) = (stored_request.uuid, stored_request.request)
if not PY2:
request_json = request_json.decode('utf-8')
request_json = request_json.decode('utf-8')
LOGGER.debug("Launching the stored request {}".format(str(uuid)))
new_wps_request = WPSRequest()
new_wps_request.json = json.loads(request_json)
Expand Down
9 changes: 4 additions & 5 deletions pywps/app/Service.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import tempfile
from werkzeug.exceptions import HTTPException
from werkzeug.wrappers import Request, Response
from pywps._compat import PY2
from pywps._compat import urlparse
from urllib.parse import urlparse
from pywps.app.WPSRequest import WPSRequest
import pywps.configuration as config
from pywps.exceptions import MissingParameterValue, NoApplicableCode, InvalidParameterValue, FileSizeExceeded, \
Expand Down Expand Up @@ -318,11 +317,11 @@ def call(self, http_request):
response = None
if wps_request.operation == 'getcapabilities':
response = self.get_capabilities(wps_request, request_uuid)
response._update_status(WPS_STATUS.SUCCEEDED, u'', 100)
response._update_status(WPS_STATUS.SUCCEEDED, '', 100)

elif wps_request.operation == 'describeprocess':
response = self.describe(wps_request, request_uuid, wps_request.identifiers)
response._update_status(WPS_STATUS.SUCCEEDED, u'', 100)
response._update_status(WPS_STATUS.SUCCEEDED, '', 100)

elif wps_request.operation == 'execute':
response = self.execute(
Expand All @@ -334,7 +333,7 @@ def call(self, http_request):
except Exception as e:
# This ensure that logged request get terminated in case of exception while the request is not
# accepted
store_status(request_uuid, WPS_STATUS.FAILED, u'Request rejected due to exception', 100)
store_status(request_uuid, WPS_STATUS.FAILED, 'Request rejected due to exception', 100)
raise e
else:
raise RuntimeError("Unknown operation {}".format(wps_request.operation))
Expand Down
15 changes: 4 additions & 11 deletions pywps/app/WPSRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from pywps import get_ElementMakerForVersion
import base64
import datetime
from pywps._compat import text_type, PY2
from pywps.app.basic import get_xpath_ns
from pywps.inout.inputs import input_from_json
from pywps.exceptions import NoApplicableCode, OperationNotSupported, MissingParameterValue, VersionNegotiationFailed, \
Expand Down Expand Up @@ -87,10 +86,7 @@ def _post_request(self):
try:
doc = lxml.etree.fromstring(self.http_request.get_data())
except Exception as e:
if PY2:
raise NoApplicableCode(e.message)
else:
raise NoApplicableCode(e.msg)
raise NoApplicableCode(e.msg)

operation = doc.tag
version = get_version_from_ns(doc.nsmap[doc.prefix])
Expand Down Expand Up @@ -191,7 +187,7 @@ def parse_post_getcapabilities(doc):
acceptedversions = self.xpath_ns(
doc, '/wps:GetCapabilities/ows:AcceptVersions/ows:Version')
acceptedversions = ','.join(
map(lambda v: v.text, acceptedversions))
[v.text for v in acceptedversions])
wpsrequest.check_accepted_versions(acceptedversions)

language = doc.attrib.get('language')
Expand Down Expand Up @@ -395,7 +391,7 @@ def get_inputs_from_xml(doc):
value_el = literal_data[0]
inpt = {}
inpt['identifier'] = identifier_el.text
inpt['data'] = text_type(value_el.text)
inpt['data'] = str(value_el.text)
inpt['uom'] = value_el.attrib.get('uom', '')
inpt['datatype'] = value_el.attrib.get('datatype', '')
the_inputs[identifier].append(inpt)
Expand Down Expand Up @@ -574,10 +570,7 @@ def _get_dataelement_value(value_el):
"""

if isinstance(value_el, lxml.etree._Element):
if PY2:
return lxml.etree.tostring(value_el, encoding=unicode) # noqa
else:
return lxml.etree.tostring(value_el, encoding=str)
return lxml.etree.tostring(value_el, encoding=str)
else:
return value_el

Expand Down
11 changes: 2 additions & 9 deletions pywps/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
import tempfile
import pywps

from pywps._compat import PY2
if PY2:
import ConfigParser
else:
import configparser
import configparser

__author__ = "Calin Ciociu"

Expand Down Expand Up @@ -67,10 +63,7 @@ def load_configuration(cfgfiles=None):
global CONFIG

LOGGER.info('loading configuration')
if PY2:
CONFIG = ConfigParser.SafeConfigParser(os.environ)
else:
CONFIG = configparser.ConfigParser(os.environ)
CONFIG = configparser.ConfigParser(os.environ)

LOGGER.debug('setting default values')
CONFIG.add_section('server')
Expand Down
6 changes: 2 additions & 4 deletions pywps/dblog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import logging
from pywps import configuration
from pywps.exceptions import NoApplicableCode
from pywps._compat import PY2
import sqlite3
import datetime
import pickle
Expand Down Expand Up @@ -191,9 +190,8 @@ def store_process(uuid, request):

session = get_session()
request_json = request.json
if not PY2:
# the BLOB type requires bytes on Python 3
request_json = request_json.encode('utf-8')
# the BLOB type requires bytes on Python 3
request_json = request_json.encode('utf-8')
request = RequestInstance(uuid=str(uuid), request=request_json)
session.add(request)
session.commit()
Expand Down
31 changes: 15 additions & 16 deletions pywps/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from werkzeug.wrappers import Response
from werkzeug.exceptions import HTTPException
from werkzeug._compat import text_type
from werkzeug.utils import escape

import logging
Expand Down Expand Up @@ -66,14 +65,14 @@ def get_response(self, environ=None):
'name': escape(self.name),
'description': self.get_description(environ)
}
doc = text_type((
u'<?xml version="1.0" encoding="UTF-8"?>\n'
u'<!-- PyWPS {version} -->\n'
u'<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd" version="1.0.0">\n' # noqa
u' <ows:Exception exceptionCode="{name}" locator="{locator}" >\n'
u' {description}\n'
u' </ows:Exception>\n'
u'</ows:ExceptionReport>'
doc = str((
'<?xml version="1.0" encoding="UTF-8"?>\n'
'<!-- PyWPS {version} -->\n'
'<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd" version="1.0.0">\n' # noqa
' <ows:Exception exceptionCode="{name}" locator="{locator}" >\n'
' {description}\n'
' </ows:Exception>\n'
'</ows:ExceptionReport>'
).format(**args))

return Response(doc, self.code, mimetype='text/xml')
Expand Down Expand Up @@ -134,13 +133,13 @@ def get_body(self, environ=None):
'name': escape(self.name),
'description': self.get_description(environ)
}
return text_type((
u'<?xml version="1.0" encoding="UTF-8"?>\n'
u'<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/ows/1.1 ../../../ows/1.1.0/owsExceptionReport.xsd" version="1.0.0">' # noqa
u'<ows:Exception exceptionCode="{name}">'
u'{description}'
u'</ows:Exception>'
u'</ows:ExceptionReport>'
return str((
'<?xml version="1.0" encoding="UTF-8"?>\n'
'<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/ows/1.1 ../../../ows/1.1.0/owsExceptionReport.xsd" version="1.0.0">' # noqa
'<ows:Exception exceptionCode="{name}">'
'{description}'
'</ows:Exception>'
'</ows:ExceptionReport>'
).format(**args))


Expand Down
12 changes: 4 additions & 8 deletions pywps/ext_autodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class ProcessDocumenter(ClassDocumenter):

@classmethod
def can_document_member(cls, member, membername, isattr, parent):
from six import class_types
return isinstance(member, class_types) and issubclass(member, Process)
return isinstance(member, type) and issubclass(member, Process)

def fmt_type(self, obj):
"""Input and output type formatting (type, default and allowed
Expand Down Expand Up @@ -90,7 +89,7 @@ class instance.

# Description
doc = list()
doc.append(u":program:`{}` {} (v{})".format(obj.identifier, obj.title, obj.version or '', ))
doc.append(":program:`{}` {} (v{})".format(obj.identifier, obj.title, obj.version or '', ))
doc.append('')
doc.append(obj.abstract)
doc.append('')
Expand Down Expand Up @@ -130,7 +129,7 @@ class instance.
if isinstance(m, MetadataUrl):
extra_underscore = "_" if m.anonymous else ""
if title and href:
ref.append(u" - `{} <{}>`_{}".format(title, href, extra_underscore))
ref.append(" - `{} <{}>`_{}".format(title, href, extra_underscore))
hasref = True

ref.append('')
Expand All @@ -144,16 +143,13 @@ def get_doc(self, encoding=None, ignore=1):
"""Overrides ClassDocumenter.get_doc to create the doc scraped from the Process object, then adds additional
content from the class docstring.
"""
from six import text_type
# Get the class docstring. This is a copy of the ClassDocumenter.get_doc method. Using "super" does weird stuff.
docstring = self.get_attr(self.object, '__doc__', None)

# make sure we have Unicode docstrings, then sanitize and split
# into lines
if isinstance(docstring, text_type):
if isinstance(docstring, str):
docstring = prepare_docstring(docstring, ignore)
elif isinstance(docstring, str): # this will not trigger on Py3
docstring = prepare_docstring(force_decode(docstring, encoding), ignore)

# Create the docstring by scraping info from the Process instance.
pdocstrings = self.make_numpy_doc()
Expand Down
Loading