Skip to content

Commit 7a3f670

Browse files
committed
Merge branch 'develop' of github.com:geopython/pywps into develop
2 parents d2fcde3 + ae1a6ce commit 7a3f670

11 files changed

Lines changed: 79 additions & 35 deletions

docs/demobuffer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __init__(self):
5959
title='Buffer',
6060
abstract='This process demonstrates, how to create any process in PyWPS environment',
6161
metadata=[Metadata('process metadata 1', 'http://example.org/1'),
62-
Metadata('process metadata 2', 'http://example.org/2')]
62+
Metadata('process metadata 2', 'http://example.org/2')],
6363
inputs=inputs,
6464
outputs=outputs,
6565
store_supported=True,

docs/external-tools.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,18 @@ work.
3636
grass.run_command('v.out.ogr', input="myvector", ...)
3737
3838
Also do not forget to set ``gisbase`` :ref:`configuration` option.
39+
40+
OpenLayers WPS client
41+
---------------------
42+
43+
ZOO-Project
44+
-----------
45+
46+
`ZOO-Project <http://www.zoo-project.org>`_ provides both a server (C) and
47+
client (JavaScript) framework.
48+
49+
QGIS WPS Client
50+
---------------
51+
52+
The `QGIS WPS <https://plugins.qgis.org/plugins/wps/>`_ client provides a
53+
plugin with WPS support for the QGIS Desktop GIS.

docs/process.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,17 +389,25 @@ To make the server visible from another computer, replace ``localhost`` with ``0
389389
Automated process documentation
390390
===============================
391391

392-
WPS :class:`Processes` can be automatically documented with `Sphinx`_ using the
392+
A :class:`Process` can be automatically documented with `Sphinx`_ using the
393393
`autoprocess` directive. The :class:`Process` object is instantiated and its
394394
content examined to create, behind the scenes, a docstring in the Numpy format. This
395395
lets developers embed the documentation directly in the code instead of having to
396-
describe each process in a separate file. For example::
396+
describe each process manually. For example::
397397

398398
.. autoprocess:: pywps.tests.DocExampleProcess
399+
:docstring:
400+
:skiplines: 1
399401

400402
would yield
401403

402404
.. autoprocess:: pywps.tests.DocExampleProcess
405+
:docstring:
406+
:skiplines: 1
407+
408+
The :option:`docstring` option fetches the :class:`Process` docstring and appends it after the
409+
Reference section. The first lines of this docstring can be skipped using the
410+
:option:`skiplines` option.
403411

404412
To use the `autoprocess` directive, first add `'sphinx.ext.napoleon'` and
405413
`'pywps.ext_autodoc'` to the list of extensions in the Sphinx configuration file

pywps/app/Process.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def __init__(self, handler, identifier, title, abstract='', keywords=[], profile
6666
self.workdir = None
6767
self._grass_mapset = None
6868
self.grass_location = grass_location
69+
self.service = None
6970

7071
if store_supported:
7172
self.store_supported = 'true'
@@ -290,12 +291,14 @@ def _run_process(self, wps_request, wps_response):
290291
request_json = request_json.decode('utf-8')
291292
new_wps_request = WPSRequest()
292293
new_wps_request.json = json.loads(request_json)
294+
process_identifier = new_wps_request.identifier
295+
process = self.service.prepare_process_for_execution(process_identifier)
296+
process._set_uuid(uuid)
297+
process.async = True
293298
response_cls = get_response("execute")
294-
295-
new_wps_response = response_cls(new_wps_request, process=self, uuid=uuid)
299+
new_wps_response = response_cls(new_wps_request, process=process, uuid=uuid)
296300
new_wps_response.status = STATUS.STORE_AND_UPDATE_STATUS
297-
self._set_uuid(uuid)
298-
self._run_async(new_wps_request, new_wps_response)
301+
process._run_async(new_wps_request, new_wps_response)
299302
dblog.remove_stored(uuid)
300303
except Exception as e:
301304
LOGGER.error("Could not run stored process. %s", e)

pywps/app/Service.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,25 @@ def execute(self, identifier, wps_request, uuid):
7979
:param uuid: string identifier of the request
8080
"""
8181
self._set_grass()
82+
process = self.prepare_process_for_execution(identifier)
83+
return self._parse_and_execute(process, wps_request, uuid)
84+
85+
def prepare_process_for_execution(self, identifier):
86+
"""Prepare the process identified by ``identifier`` for execution.
87+
"""
8288
try:
8389
process = self.processes[identifier]
84-
85-
# make deep copy of the process instace
86-
# so that processes are not overriding each other
87-
# just for execute
88-
process = copy.deepcopy(process)
89-
90-
workdir = os.path.abspath(config.get_config_value('server', 'workdir'))
91-
tempdir = tempfile.mkdtemp(prefix='pywps_process_', dir=workdir)
92-
process.set_workdir(tempdir)
9390
except KeyError:
9491
raise InvalidParameterValue("Unknown process '%r'" % identifier, 'Identifier')
95-
96-
return self._parse_and_execute(process, wps_request, uuid)
92+
# make deep copy of the process instace
93+
# so that processes are not overriding each other
94+
# just for execute
95+
process = copy.deepcopy(process)
96+
process.service = self
97+
workdir = os.path.abspath(config.get_config_value('server', 'workdir'))
98+
tempdir = tempfile.mkdtemp(prefix='pywps_process_', dir=workdir)
99+
process.set_workdir(tempdir)
100+
return process
97101

98102
def _parse_and_execute(self, process, wps_request, uuid):
99103
"""Parse and execute request

pywps/app/WPSRequest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def __init__(self, http_request=None):
3636
self.operation = None
3737
self.version = None
3838
self.language = None
39+
self.identifier = None
3940
self.identifiers = None
4041
self.store_execute = None
4142
self.status = None
@@ -316,6 +317,7 @@ def default(self, obj):
316317
'operation': self.operation,
317318
'version': self.version,
318319
'language': self.language,
320+
'identifier': self.identifier,
319321
'identifiers': self.identifiers,
320322
'store_execute': self.store_execute,
321323
'status': self.status,
@@ -337,6 +339,7 @@ def json(self, value):
337339
self.operation = value['operation']
338340
self.version = value['version']
339341
self.language = value['language']
342+
self.identifier = value['identifier']
340343
self.identifiers = value['identifiers']
341344
self.store_execute = value['store_execute']
342345
self.status = value['status']

pywps/ext_autodoc.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# -*- coding: utf-8 -*-
2-
from sphinx.ext.autodoc import ClassDocumenter
2+
from sphinx.ext.autodoc import ClassDocumenter, bool_option
33
from sphinx.ext.napoleon.docstring import NumpyDocstring
44
from sphinx.util.docstrings import prepare_docstring
55
from sphinx.util import force_decode
6+
from docutils.parsers.rst import directives
67
from pywps import Process
78
from pywps.app.Common import Metadata
89

@@ -12,12 +13,26 @@ class ProcessDocumenter(ClassDocumenter):
1213
pywps.Process class.
1314
1415
The Process description, its inputs and docputs are converted to a
15-
numpy style docstring. Additional sections (Notes, References,
16-
Examples, etc.) can be added in the Process subclass docstring.
16+
numpy style docstring.
17+
18+
Additional sections (Notes, References, Examples, etc.) can be added
19+
in the Process subclass docstring using the `docstring` option.
20+
Additionally, docstring lines can be skipped using the `skiplines` option.
21+
22+
For, example, the following would append the SimpleProcess class docstring
23+
to the published docs, skipping the first line.
24+
25+
.. autoprocess:: pywps.SimpleProcess
26+
:docstring:
27+
:skiplines: 1
28+
1729
"""
1830
directivetype = 'class'
1931
objtype = 'process'
2032
priority = ClassDocumenter.priority + 1
33+
option_spec = {'skiplines':directives.nonnegative_int,
34+
'docstring':bool_option}
35+
option_spec.update(ClassDocumenter.option_spec)
2136

2237
@classmethod
2338
def can_document_member(cls, member, membername, isattr, parent):
@@ -96,7 +111,7 @@ class instance.
96111
for i in obj.outputs:
97112
doc.append("{} : {}".format(i.identifier, self.fmt_type(i)))
98113
doc.append(" {}".format(i.abstract or i.title))
99-
doc.append('')
114+
doc.extend(['',''])
100115

101116
# Metadata
102117
hasref = False
@@ -129,6 +144,7 @@ def get_doc(self, encoding=None, ignore=1):
129144
from six import text_type
130145
# Get the class docstring. This is a copy of the ClassDocumenter.get_doc method. Using "super" does weird stuff.
131146
docstring = self.get_attr(self.object, '__doc__', None)
147+
132148
# make sure we have Unicode docstrings, then sanitize and split
133149
# into lines
134150
if isinstance(docstring, text_type):
@@ -139,9 +155,9 @@ def get_doc(self, encoding=None, ignore=1):
139155
# Create the docstring by scraping info from the Process instance.
140156
pdocstrings = self.make_numpy_doc()
141157

142-
# Add the sections from the class itself.
143-
if docstring is not None:
144-
pdocstrings.extend(docstring)
158+
if self.options.docstring and docstring is not None:
159+
# Add the sections from the class docstring itself.
160+
pdocstrings.extend(docstring[self.options.skiplines:])
145161

146162
# Parse using the Numpy docstring format.
147163
docstrings = NumpyDocstring(pdocstrings, self.env.config, self.env.app, what='class', obj=self.object,

pywps/tests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
logging.disable(logging.CRITICAL)
2020

2121
class DocExampleProcess(Process):
22-
"""
22+
"""This first line is going to be skipped by the :skiplines:1 option.
23+
2324
Notes
2425
-----
2526
26-
This is additional documentation that can be added following the numpy docstring convention.
27+
This is additional documentation that can be added following the Numpy docstring convention.
2728
"""
2829

2930
def __init__(self):

requirements-dev.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
coverage
22
flake8
3+
flufl.enum
34
pylint
45
Sphinx
5-
six
6+
six

requirements-py2.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)