Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def create_mimetype_process():
def _handler(request, response):
response.outputs['mimetype'].data = response.outputs['mimetype'].data_format.mime_type
return response
frmt_txt = Format(mime_type='text/plain')
frmt_txt2 = Format(mime_type='text/plain+test')
return Process(handler=_handler,
identifier='get_mimetype_process',
title='Get mimeType process',
inputs=[],
outputs=[
ComplexOutput(
'mimetype',
'mimetype of requested output',
supported_formats=[frmt_txt, frmt_txt2])
])
config.load_configuration(config_file)
self.output_url = config.get_config_value('server', 'outputUrl')
self.output_path = config.get_config_value('server', 'outputPath')
self.temp_path = config.get_config_value('server', 'tempPath')
self.host = config.get_config_value('wps', 'serveraddress').split('://')[1]
self.port = int(config.get_config_value('wps', 'serverport'))
self.processes = [
Process(say_hello,
version='1.3.3.7',
inputs=[LiteralInput('name', data_type='string')],
outputs=[LiteralOutput('response', data_type='string')],
store_supported=True,
status_supported=True),
Process(feature_count,
inputs=[ComplexInput('layer', 'Layer', [Format('SHP')])],
outputs=[ComplexOutput('layer', 'Layer', [Format('GML')])]),
Process(centroids,
inputs=[ComplexInput('layer', 'Layer', [Format('GML')])],
outputs=[ComplexOutput('out', 'Referenced Output', [Format('JSON')])],
store_supported=True,
status_supported=True),
UltimateQuestion(),
Sleep()
]
# if any processes have been passed then prioritize these
if processes:
self.processes = processes
self.service = Service(processes=self.processes)
units_tasmin = self.field.data_variables[0].units
units_tasmax = self.field.data_variables[1].units
c1 = get_are_units_equal_by_string_or_cfunits(
units_tasmin, 'K', try_cfunits=env.USE_CFUNITS)
c2 = get_are_units_equal_by_string_or_cfunits(
units_tasmax, 'K', try_cfunits=env.USE_CFUNITS)
if not (c1 and c2):
raise NotImplementedError("Units not in kelvin.")
crosses_zero = np.bitwise_and(tasmin < 273.15, tasmax > 273.15)
return crosses_zero.sum(self.sum_dim())
FunctionRegistry.append(FreezeThawOura)
class OuranosPublicIndicatorProcess(Process, object):
identifier = "ouranos_public_indicators"
title = "Climate indicators for the public web site."
abstract = "Compute climate indicators: mean daily temp., min daily temp., max daily temp., growing degree days, number of days above 30C, freeze thaw cycles, total precipitation, and max 5-day precip."
##########
# Inputs #
##########
inputs = [
ComplexInput('tasmin', 'Minimum daily temperature',
abstract='NetCDF Files or archive (tar/zip) containing netCDF files storing minimum daily temperature.',
metadata=[Metadata('Info')],
min_occurs=1,
max_occurs=1000,
supported_formats=[
Format('application/x-netcdf'),
Format('application/x-tar'),
def can_document_member(cls, member, membername, isattr, parent):
from six import class_types
return isinstance(member, class_types) and issubclass(member, Process)
import traceback
# TODO: Python 3.6 Warning- Find replacement for urlparse
from urlparse import urlparse
from flyingpigeon.handler_common import wfs_common
from flyingpigeon.utils import CookieNetCDFTransfer
from pywps import Process, LiteralInput, ComplexOutput, get_format
json_format = get_format('JSON')
class AveragerBboxProcess(Process):
"""Weighted spatial average of NetCDF file using bounding box geometry."""
def __init__(self):
inputs = [
LiteralInput('resource',
'NetCDF resource',
abstract='NetCDF files, can be OPEnDAP urls.',
data_type='string',
max_occurs=1000),
LiteralInput('lon0',
'Minimum longitude',
abstract='Minimum longitude.',
data_type='float'),
LiteralInput('lon1',
'Maximum longitude',
abstract='Maximum longitude.',
from pywps import ComplexInput, ComplexOutput
from pywps import Format
from pywps import LiteralInput
from pywps import Process
from pywps.app.Common import Metadata
from flyingpigeon import plt_ncdata
from flyingpigeon.utils import extract_archive
from flyingpigeon.nc_utils import get_variable
# from flyingpigeon.utils import rename_complexinputs
# from flyingpigeon.log import init_process_logger
LOGGER = logging.getLogger("PYWPS")
class PlotspaghettiProcess(Process):
def __init__(self):
inputs = [
ComplexInput('resource', 'Resource',
abstract='NetCDF Files (with one variable) or archive (tar/zip) containing NetCDF files.',
metadata=[Metadata('Info')],
min_occurs=1,
max_occurs=1000,
supported_formats=[
Format('application/x-netcdf'),
Format('application/x-tar'),
Format('application/zip'),
]),
LiteralInput("variable", "Variable",
abstract="Variable to be expected in the input files (variable will be detected if not set)",
default=None,
def isComplexData(dummy,inputName):
inputInstance=process.inputs[inputName]
#Checking if the input is of complexInput type
return isinstance(inputInstance,pywps.Process.InAndOutputs.ComplexInput("foo","foo").__class__)
from flyingpigeon import sdm
from flyingpigeon.sdm import _SDMINDICES_
from flyingpigeon.utils import rename_complexinputs
from flyingpigeon.utils import archive, archiveextract, download
from flyingpigeon.visualisation import map_gbifoccurrences
from flyingpigeon.visualisation import map_PAmask
from flyingpigeon.visualisation import pdfmerge, concat_images
from flyingpigeon.log import init_process_logger
import tempfile
import logging
LOGGER = logging.getLogger("PYWPS")
class SDMcsvProcess(Process):
def __init__(self):
inputs = [
ComplexInput('resource', 'Resource',
abstract='NetCDF Files or archive (tar/zip) containing netCDF files.',
metadata=[Metadata('Info')],
min_occurs=1,
max_occurs=1000,
supported_formats=[
Format('application/x-netcdf'),
Format('application/x-tar'),
Format('application/zip'),
]),
LiteralInput("gbif", "GBIF csv file",
abstract="GBIF table (csv) with tree occurence \
(output of 'GBIF data fetch' process )",
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import json
import os
import subprocess
from pywps import Process, ComplexInput, ComplexOutput, Format, FORMATS
from pywps.wpsserver import temp_dir
class Centroids(Process):
def __init__(self):
inputs = [ComplexInput('layer', 'Layer',
supported_formats=[Format('application/gml+xml')])]
outputs = [ComplexOutput('out', 'Referenced Output',
supported_formats=[Format('application/json')])]
super(Centroids, self).__init__(
self._handler,
identifier='centroids',
title='Process Centroids',
inputs=inputs,
outputs=outputs,
store_supported=True,
status_supported=True
)
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
from pywps import Process, LiteralInput, LiteralOutput
from pywps.app.Common import Metadata
class Sleep(Process):
SUCCESS_MESSAGE = 'done sleeping'
def __init__(self):
inputs = [LiteralInput('delay',
'Delay between every update',
data_type='float')]
outputs = [LiteralOutput('sleep_output',
'Sleep Output',
data_type='string')]
super(Sleep, self).__init__(
self._handler,
identifier='sleep',
version='None',
title='Sleep Process',