[Pywps-dev] Raster Output error

Jachym Cepicky jachym.cepicky at gmail.com
Wed Jun 29 01:23:13 PDT 2016


Hi Lorenzo,

looks like your request is not formatted well - the XML input. How does it
look?

J

út 28. 6. 2016 v 15:29 odesílatel Lorenzo Bottaccioli <
lorenzo.bottaccioli at gmail.com> napsal:

> HI all,
>
> I have setup the pywps linked by Jachym (
> https://github.com/jachym/pywps/tree/pygrass) run on Apache2 with
> mod_wsgi.
> I have created a wsgi file with this script
>
> *import sys*
> *sys.path.insert(0, '/home/lorenzo/tools/pywps-4/')*
> *import pywps*
> *from pywps.app import Service,  Process*
> *from processes.raster import Raster*
> *from processes.solar.PV_NOCT import PV_CALC*
> *from processes.get_year_rad import get_year_rad_pitch*
> *from processes.get_year_rad_zstat import get_year_rad_pitch_query*
> *from processes.get_year_rad_all import get_year_rad_all*
> *from processes.solar.real_sky import Real_sky*
>
> *application = Service(processes=[Raster(),*
> * PV_CALC(),*
> * get_year_rad_pitch(),*
> * get_year_rad_pitch_query(),*
> * Real_sky(),*
> * get_year_rad_all()], cfgfile='/var/www/pywps/pywps.cfg')*
>
> I still get an error when I try to use the Raster process which is:
>
> *from pywps import Process, ComplexInput, ComplexOutput,
> get_format,LiteralOutput, Format*
> *class Raster(Process):*
>
> *    def __init__(self):*
> *        inputs = [ComplexInput('raster','Raster
> input',[Format('GEOTIFF')])]*
>
> *        outputs = [ComplexOutput('raster_out', 'Raster
> output',[Format('GEOTIFF')]),LiteralOutput('response', 'Output response',
> data_type='string')]*
> *        super(Raster, self).__init__(*
> *            self._handler,*
> *            identifier='rast_try',*
> *            title='Raster try',*
> *            inputs=inputs,*
> *            outputs=outputs,*
> *            store_supported=True,*
> *            status_supported=True*
> *        )*
>
> *    def _handler(self, request, response):*
>
> *        from osgeo import gdal*
> *        app=request.inputs['raster'][0].file*
> *        inds = gdal.Open(app)*
> *        outdriver = gdal.GetDriverByName('GTiff')*
> *        outds = outdriver.CreateCopy('output.tiff', inds)*
> *        outds.FlushCache()*
> *        response.outputs['raster_out'].output_format = Format('GEOTIFF')*
> *        response.outputs['raster_out'].file = 'output.tiff'*
> *        response.outputs['response'].data = 'done'*
> *        return response*
>
>  The error I get in the apache error.log is:
>
> [Tue Jun 28 15:23:54.052594 2016] [:error] [pid 4437:tid 140256591759104]
> ERROR:PYWPS:Exception: code: 400, locator: None, description:
> [Tue Jun 28 15:23:54.052615 2016] [:error] [pid 4437:tid 140256591759104]
> Traceback (most recent call last):
> [Tue Jun 28 15:23:54.052617 2016] [:error] [pid 4437:tid 140256591759104]
>   File
> "/usr/local/lib/python2.7/dist-packages/pywps-4.0.0_alpha2-py2.7.egg/pywps/app/WPSRequest.py",
> line 80, in _post_request
> [Tue Jun 28 15:23:54.052618 2016] [:error] [pid 4437:tid 140256591759104]
>     doc = lxml.etree.fromstring(self.http_request.get_data())
> [Tue Jun 28 15:23:54.052620 2016] [:error] [pid 4437:tid 140256591759104]
>   File "lxml.etree.pyx", line 3032, in lxml.etree.fromstring
> (src/lxml/lxml.etree.c:68106)
> [Tue Jun 28 15:23:54.052622 2016] [:error] [pid 4437:tid 140256591759104]
>   File "parser.pxi", line 1785, in lxml.etree._parseMemoryDocument
> (src/lxml/lxml.etree.c:102455)
> [Tue Jun 28 15:23:54.052626 2016] [:error] [pid 4437:tid 140256591759104]
>   File "parser.pxi", line 1673, in lxml.etree._parseDoc
> (src/lxml/lxml.etree.c:101284)
> [Tue Jun 28 15:23:54.052628 2016] [:error] [pid 4437:tid 140256591759104]
>   File "parser.pxi", line 1074, in lxml.etree._BaseParser._parseDoc
> (src/lxml/lxml.etree.c:96466)
> [Tue Jun 28 15:23:54.052629 2016] [:error] [pid 4437:tid 140256591759104]
>   File "parser.pxi", line 582, in
> lxml.etree._ParserContext._handleParseResultDoc
> (src/lxml/lxml.etree.c:91275)
> [Tue Jun 28 15:23:54.052630 2016] [:error] [pid 4437:tid 140256591759104]
>   File "parser.pxi", line 683, in lxml.etree._handleParseResult
> (src/lxml/lxml.etree.c:92461)
> [Tue Jun 28 15:23:54.052632 2016] [:error] [pid 4437:tid 140256591759104]
>   File "parser.pxi", line 633, in lxml.etree._raiseParseError
> (src/lxml/lxml.etree.c:91924)
> [Tue Jun 28 15:23:54.052633 2016] [:error] [pid 4437:tid 140256591759104]
> XMLSyntaxError: None
>
> Any suggestion to solve it?
>
> Best,
>
> Lorenzo
>
>
>
> 2016-06-28 10:28 GMT+02:00 Lorenzo Bottaccioli <
> lorenzo.bottaccioli at gmail.com>:
>
>> Hi Jachym,
>>
>> I have changed my code in this. I create the file 'output.tiff' the error
>> indeed was not related to output.tiff.
>>
>> from pywps import Process, ComplexInput, ComplexOutput,
>> get_format,LiteralOutput, Format
>>
>>
>> *class Raster(Process):*
>>
>> *    def __init__(self):*
>> *        inputs = [ComplexInput('raster','Raster
>> input',[Format('GEOTIFF')])]*
>>
>> *        outputs = [ComplexOutput('raster_out', 'Raster
>> output',[Format('GEOJSON')])]*
>> *        super(Raster, self).__init__(*
>> *            self._handler,*
>> *            identifier='rast_try',*
>> *            title='Raster try',*
>> *            inputs=inputs,*
>> *            outputs=outputs,*
>> *            store_supported=True,*
>> *            status_supported=True*
>> *        )*
>>
>> *    def _handler(self, request, response):*
>>
>> *        from osgeo import gdal*
>> *        app=request.inputs['raster'][0].file*
>> *        inds = gdal.Open(app)*
>> *        outdriver = gdal.GetDriverByName('GTiff')*
>> *        outds = outdriver.CreateCopy('output.tiff', inds)*
>> *        outds.FlushCache()*
>> *        response.outputs['raster_out'].output_format = Format('GEOTIFF')*
>> *        response.outputs['raster_out'].file = 'output.tiff'*
>> *        return response*
>>
>>  This is the Error:
>>
>> 130.192.5.114 - - [28/Jun/2016 10:26:51] "GET
>> /wps?service=wps&version=1.0.0&request=execute&Identifier=rast_try&datainputs=raster=@xlink:href=file:///home/lorenzo/aspect_1ifGBx0
>> HTTP/1.1" 500 -
>> Traceback (most recent call last):
>>   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836,
>> in __call__
>>     return self.wsgi_app(environ, start_response)
>>   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820,
>> in wsgi_app
>>     response = self.make_response(self.handle_exception(e))
>>   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403,
>> in handle_exception
>>     reraise(exc_type, exc_value, tb)
>>   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817,
>> in wsgi_app
>>     response = self.full_dispatch_request()
>>   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1478,
>> in full_dispatch_request
>>     response = self.make_response(rv)
>>   File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1577,
>> in make_response
>>     rv = self.response_class.force_type(rv, request.environ)
>>   File
>> "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.11.4-py2.7.egg/werkzeug/wrappers.py",
>> line 847, in force_type
>>     response = BaseResponse(*_run_wsgi_app(response, environ))
>>   File
>> "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.11.4-py2.7.egg/werkzeug/wrappers.py",
>> line 57, in _run_wsgi_app
>>     return _run_wsgi_app(*args)
>>   File
>> "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.11.4-py2.7.egg/werkzeug/test.py",
>> line 871, in run_wsgi_app
>>     app_rv = app(environ, start_response)
>>   File
>> "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.11.4-py2.7.egg/werkzeug/wrappers.py",
>> line 291, in application
>>     return f(*args[:-2] + (request,))(*args[-2:])
>>   File
>> "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.11.4-py2.7.egg/werkzeug/wrappers.py",
>> line 291, in application
>>     return f(*args[:-2] + (request,))(*args[-2:])
>>   File
>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/app/WPSResponse.py",
>> line 180, in __call__
>>     except HTTPException as httpexp:
>> NameError: global name 'HTTPException' is not defined
>>
>> I'll test your banch ASAP and I let you know.
>>
>> Tnx,
>>
>> Lorenzo
>>
>>
>> 2016-06-27 22:39 GMT+02:00 Jachym Cepicky <jachym.cepicky at gmail.com>:
>>
>>> Lorenzo,
>>>
>>> two things,
>>>
>>> in your code:
>>>
>>> IOError: [Errno 2] No such file or directory:
>>> '/tmp/pywps/pypws_process_lQqN_6/done'
>>> ERROR:root:Service error: near "''": syntax error
>>>
>>> means - you can not save output.file as 'done' - it must be file name
>>>
>>> second: there was bug in pywps, which lead to error while constructing
>>> the final response from pywps, please test pygrass branch in my repository
>>>
>>> https://github.com/jachym/pywps/tree/pygrass
>>>
>>> one more time:
>>>
>>>         response.outputs['raster_out'].output_format = Format('GEOTIFF')
>>>         response.outputs['raster_out'].file = 'output.tiff'
>>>
>>> should work ASSUMING, output.tiff is existing file!
>>>
>>>
>>> pá 24. 6. 2016 v 13:17 odesílatel Lorenzo Bottaccioli <
>>> lorenzo.bottaccioli at gmail.com> napsal:
>>>
>>>> Hi all,
>>>>
>>>> Can you please show a simple PyWPS process that revice a geotiff and
>>>> returns it back and the url for requesting it?.
>>>> I'm not finding a way to do that.
>>>>
>>>> Thanks in advantage,
>>>> Best
>>>>
>>>>
>>>> Lorenzo
>>>>
>>>> 2016-06-21 17:40 GMT+02:00 Jachym Cepicky <jachym.cepicky at gmail.com>:
>>>>
>>>>> hi,
>>>>>
>>>>> if you are running pywps in apache2, it's usually
>>>>> /var/log/apache2/error.log
>>>>> if flask - it should be written to the command line
>>>>>
>>>>> look for some pythonish error
>>>>>
>>>>> po 20. 6. 2016 v 17:29 odesílatel Lorenzo Bottaccioli <
>>>>> lorenzo.bottaccioli at gmail.com> napsal:
>>>>>
>>>>>> Hi Jachym,
>>>>>>
>>>>>> As I wrote in the previous mail I have changed
>>>>>>
>>>>>> response.outputs['response'].file* = 'done' *in
>>>>>> response.outputs['response'].data = 'done'  .
>>>>>>
>>>>>> But I stil get an error:
>>>>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
>>>>>> <title>500 Internal Server Error</title>
>>>>>> <h1>Internal Server Error</h1>
>>>>>> <p>The server encountered an internal error and was unable to
>>>>>> complete your request.  Either the server is overloaded or there is an
>>>>>> error in the application.</p>
>>>>>>
>>>>>>
>>>>>> Which is the HTTPD error.log file? The pywps.log file is always empty
>>>>>> and the log level is set to DEBUG
>>>>>> Best,
>>>>>>
>>>>>> Lorenzo
>>>>>>
>>>>>> 2016-06-18 23:39 GMT+02:00 Jachym Cepicky <jachym.cepicky at gmail.com>:
>>>>>>
>>>>>>> hi,
>>>>>>>
>>>>>>> as jonas was saying: response.outputs['response'].data = 'done'
>>>>>>> should work better
>>>>>>>
>>>>>>> Lorenzo:  do you get anything in the HTTPD server error.log file?
>>>>>>>
>>>>>>> pá 10. 6. 2016 v 15:30 odesílatel Lorenzo Bottaccioli <
>>>>>>> lorenzo.bottaccioli at gmail.com> napsal:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I'have changed from file to data in response.outputs['response'].data
>>>>>>>> = 'done', but bow I still get an error in the response.
>>>>>>>>
>>>>>>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
>>>>>>>> <title>500 Internal Server Error</title>
>>>>>>>> <h1>Internal Server Error</h1>
>>>>>>>> <p>The server encountered an internal error and was unable to
>>>>>>>> complete your request.  Either the server is overloaded or there is an
>>>>>>>> error in the application.</p>
>>>>>>>>
>>>>>>>>
>>>>>>>> The GET request is written like this:
>>>>>>>>
>>>>>>>>
>>>>>>>> http://130.192.5.114:8080/wps?service=wps&version=1.0.0&request=execute&Identifier=rast_try&datainputs=raster=@xlink:href=file:///home/lorenzo/aspect_1ifGBx0
>>>>>>>>
>>>>>>>> In the terminal I dont get any error report.
>>>>>>>>
>>>>>>>> Tnx,
>>>>>>>>
>>>>>>>> Lorenzo
>>>>>>>>
>>>>>>>> 2016-06-10 10:20 GMT+02:00 Jonas Eberle <jonas.eberle at gmx.de>:
>>>>>>>>
>>>>>>>>> The error "no such file or directory" comes from the following
>>>>>>>>> line:
>>>>>>>>> response.outputs['response'].file = 'done'
>>>>>>>>>
>>>>>>>>> As response is a LiteralOutput I guess it is not correct to use
>>>>>>>>> the file attribute, better use the data attribute:
>>>>>>>>> response.outputs['response'].data = 'done'
>>>>>>>>>
>>>>>>>>> Cheers,
>>>>>>>>> Jonas
>>>>>>>>>
>>>>>>>>> ----- Am 10. Jun 2016 um 10:13 schrieb Jachym Cepicky <
>>>>>>>>> jachym.cepicky at gmail.com>:
>>>>>>>>>
>>>>>>>>> Hi Lorenzo,
>>>>>>>>> There are two bugs as I understand. The first one:
>>>>>>>>>
>>>>>>>>> IOError: [Errno 2] No such file or directory:
>>>>>>>>> '/tmp/pywps/pypws_process_lQqN_6/done'
>>>>>>>>>
>>>>>>>>> do you have /tmp/pywps/ directory in you system (and is it
>>>>>>>>> writeable?)
>>>>>>>>>
>>>>>>>>> The second bug is about attempt to write log to database
>>>>>>>>>
>>>>>>>>> nice report btw, with the process I believe, we can fix it (both)
>>>>>>>>> once we find out what the problem could be
>>>>>>>>>
>>>>>>>>> Jachym
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> st 8. 6. 2016 v 11:50 odesílatel Lorenzo Bottaccioli <
>>>>>>>>> lorenzo.bottaccioli at gmail.com> napsal:
>>>>>>>>>
>>>>>>>>>> Hi List,
>>>>>>>>>>
>>>>>>>>>> I'm trying to run a process that recives a GeoTIFF as input and
>>>>>>>>>> response a GeoTIFF as output. But I'm having an error. The process is this:
>>>>>>>>>> from pywps import Process, ComplexInput, ComplexOutput,
>>>>>>>>>> get_format,LiteralOutput, Format
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> class Raster(Process):
>>>>>>>>>>
>>>>>>>>>>     def __init__(self):
>>>>>>>>>>         inputs = [ComplexInput('raster','Raster
>>>>>>>>>> input',[Format('GEOTIFF')])]
>>>>>>>>>>
>>>>>>>>>>         outputs = [ComplexOutput('raster_out', 'Raster
>>>>>>>>>> output',[Format('GEOJSON')]),LiteralOutput('response', 'Output response',
>>>>>>>>>> data_type='string')]
>>>>>>>>>>         super(Raster, self).__init__(
>>>>>>>>>>             self._handler,
>>>>>>>>>>             identifier='rast_try',
>>>>>>>>>>             title='Raster try',
>>>>>>>>>>             inputs=inputs,
>>>>>>>>>>             outputs=outputs,
>>>>>>>>>>             store_supported=True,
>>>>>>>>>>             status_supported=True
>>>>>>>>>>         )
>>>>>>>>>>
>>>>>>>>>>     def _handler(self, request, response):
>>>>>>>>>>
>>>>>>>>>>         from osgeo import gdal
>>>>>>>>>>         app=request.inputs['raster'][0].file
>>>>>>>>>>         inds = gdal.Open(app)
>>>>>>>>>>         outdriver = gdal.GetDriverByName('GTiff')
>>>>>>>>>>         outds = outdriver.CreateCopy('output.tiff', inds)
>>>>>>>>>>         outds.FlushCache()
>>>>>>>>>>         response.outputs['raster_out'].output_format =
>>>>>>>>>> Format('GEOTIFF')
>>>>>>>>>>         response.outputs['raster_out'].file = 'output.tiff'
>>>>>>>>>>         response.outputs['response'].file = 'done'
>>>>>>>>>>         return response
>>>>>>>>>>
>>>>>>>>>> The error that I recive is this one:
>>>>>>>>>>
>>>>>>>>>> Traceback (most recent call last):
>>>>>>>>>>   File
>>>>>>>>>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/app/Process.py",
>>>>>>>>>> line 156, in _run_process
>>>>>>>>>>     wps_response.update_status('PyWPS Process finished', 100)
>>>>>>>>>>   File
>>>>>>>>>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/app/WPSResponse.py",
>>>>>>>>>> line 41, in update_status
>>>>>>>>>>     self.doc = self._construct_doc()
>>>>>>>>>>   File
>>>>>>>>>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/app/WPSResponse.py",
>>>>>>>>>> line 171, in _construct_doc
>>>>>>>>>>     output_elements = [self.outputs[o].execute_xml() for o in
>>>>>>>>>> self.outputs]
>>>>>>>>>>   File
>>>>>>>>>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/inout/outputs.py",
>>>>>>>>>> line 276, in execute_xml
>>>>>>>>>>     literal_data_doc = WPS.LiteralData(text_type(self.data))
>>>>>>>>>>   File
>>>>>>>>>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/inout/basic.py",
>>>>>>>>>> line 231, in get_data
>>>>>>>>>>     return IOHandler.get_data(self)
>>>>>>>>>>   File
>>>>>>>>>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/inout/basic.py",
>>>>>>>>>> line 173, in get_data
>>>>>>>>>>     file_handler = open(self.source, mode='r')
>>>>>>>>>> IOError: [Errno 2] No such file or directory:
>>>>>>>>>> '/tmp/pywps/pypws_process_lQqN_6/done'
>>>>>>>>>> ERROR:root:Service error: near "''": syntax error
>>>>>>>>>> Traceback (most recent call last):
>>>>>>>>>>   File
>>>>>>>>>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/app/Service.py",
>>>>>>>>>> line 358, in _parse_and_execute
>>>>>>>>>>     wps_response = process.execute(wps_request, uuid)
>>>>>>>>>>   File
>>>>>>>>>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/app/Process.py",
>>>>>>>>>> line 145, in execute
>>>>>>>>>>     wps_response = self._run_process(wps_request, wps_response)
>>>>>>>>>>   File
>>>>>>>>>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/app/Process.py",
>>>>>>>>>> line 178, in _run_process
>>>>>>>>>>     wps_response.update_status('Process error: %s.%s Line %i %s'
>>>>>>>>>> % (fname, method_name, exc_tb.tb_lineno, e), -1)
>>>>>>>>>>   File
>>>>>>>>>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/app/WPSResponse.py",
>>>>>>>>>> line 47, in update_status
>>>>>>>>>>     update_response(self.uuid, self)
>>>>>>>>>>   File
>>>>>>>>>> "/usr/local/lib/python2.7/dist-packages/pywps-4.0-py2.7.egg/pywps/dblog.py",
>>>>>>>>>> line 67, in update_response
>>>>>>>>>>     cur.execute(update)
>>>>>>>>>> OperationalError: near "''": syntax error
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> How can I fix this?
>>>>>>>>>>
>>>>>>>>>> Best,
>>>>>>>>>>
>>>>>>>>>> Lorenzo
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> pywps-dev mailing list
>>>>>>>>>> pywps-dev at lists.osgeo.org
>>>>>>>>>> http://lists.osgeo.org/mailman/listinfo/pywps-dev
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> pywps-dev mailing list
>>>>>>>>> pywps-dev at lists.osgeo.org
>>>>>>>>> http://lists.osgeo.org/mailman/listinfo/pywps-dev
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pywps-dev/attachments/20160629/a4779b3f/attachment-0001.html>


More information about the pywps-dev mailing list