Skip to content

Commit

Permalink
minor echo process fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Aug 15, 2023
1 parent abfbd26 commit e4a57bb
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pygeoapi/process/echo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# =================================================================
#
# Authors: Alexander Pilz <[email protected]>
# Tom Kralidis <[email protected]>
#
# Copyright (c) 2023 Alexander Pilz
# Copyright (c) 2023 Tom Kralidis
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
Expand All @@ -26,6 +28,7 @@
# OTHER DEALINGS IN THE SOFTWARE.
#
# =================================================================

import logging
import time

Expand Down Expand Up @@ -99,15 +102,15 @@
}


class echoProcessor(BaseProcessor):
class EchoProcessor(BaseProcessor):
"""Echo Processor example"""
def __init__(self, processor_def):
"""
Initialize object
:param processor_def: provider definition
:returns: pygeoapi.process.echo.echoProcessor
:returns: pygeoapi.process.echo.EchoProcessor
"""

super().__init__(processor_def, PROCESS_METADATA)
Expand All @@ -116,24 +119,26 @@ def execute(self, data):

mimetype = 'application/json'

echo = data.get('echoInput', None)
pause = data.get('pause', None)
echo = data.get('echoInput')
pause = data.get('pause')

if echo is None:
raise ProcessorExecuteError(
'Cannot run process without echo value')

if not isinstance(echo, str):
raise ProcessorExecuteError(
'Cannot run process with echo not of type String')
'Cannot run process with echo not of type string')

outputs = {
'id': 'echoOutput',
'value': echo
}

if pause is not None and isinstance(pause, float):
time.sleep(pause)

return mimetype, outputs

def __repr__(self):
return '<echoProcessor> {}'.format(self.name)
return f'<EchoProcessor> {self.name}'

0 comments on commit e4a57bb

Please sign in to comment.