[Pywps-dev] Import qgis.core into PyWPS process

Eduardo Silverio da Silva eduardosilverio1990 at gmail.com
Mon Jan 2 12:38:09 PST 2017


In my case I am using QGIS 2.18 (x32) and Python 2.7.13 (x32) on Windows
10, and I have already added the following environment variables:

PYTHONPATH:
C:\Program Files (x86)\QGIS 2.18\apps\qgis\python
C:\Program Files (x86)\QGIS 2.18\apps\qgis\python\plugins
C:\Program Files (x86)\QGIS 2.18\apps\Python27\Lib\site-packages

PATH:
C:\Program Files (x86)\QGIS 2.18\bin
C:\Program Files (x86)\QGIS 2.18\apps\qgis\bin
C:\Python27
C:\Python27\Scripts

Here is the code where I want to import the classes:

#I would like to use these classes:
# from qgis.core import *
# from qgis.gui import *
# from processing.core.Processing import Processing
# import processing

from pywps.Process import WPSProcess
from types import FloatType

class Process(WPSProcess):
     def __init__(self):
         WPSProcess.__init__(self,
              identifier       = "processar",
              title            = "Title",
              version          = "1",
              storeSupported   = "false",
              statusSupported  = "false",
              abstract         = "Abstract")

         self.value1 = self.addLiteralInput(identifier = "value1", title =
"Input 1", type = FloatType)
         self.value2 = self.addLiteralInput(identifier = "value2", title =
"Input 2", type = FloatType)
         self.result = self.addLiteralOutput(identifier = "result", title =
"Result", type = FloatType)

     def execute(self):
    # Here I would like to write the necessary code to execute the
qgis:extractnodes algorithm:
    # processing.runalg('qgis:extractnodes', 'river.shp', 'output.shp')

v1 = self.value1.getValue()
         v2 = self.value2.getValue()
         self.result.setValue(v1 + v2)
         return
--------------------------------------

But even with those PATH variables configured I could not access the
algorithm via WPS-client plugin.

Regards,


2017-01-02 17:31 GMT-02:00 Salvatore Larosa <lrssvtml at gmail.com>:

> Hi,
>
> On Mon, Jan 2, 2017 at 4:31 PM, Eduardo Silverio da Silva <
> eduardosilverio1990 at gmail.com> wrote:
>
>> Hello people,
>>
>> I have a python script that uses some classes from qgis and it runs
>> correctly in my standalone app (IDLE Python). But when I try to publish the
>> script through PyWPS (3.2.5), the process does not apear in the list of
>> GetCapabilities. I think the problem is with the following imports:
>>
>> from qgis.core import *
>> from qgis.gui import *
>> from processing.core.Processing import Processing
>>
>> When I comment these lines the algorithm is showed.
>>
>
> I guess the problem is with your environment variable, you should add the
> QGIS python and plugins paths to PYTHONPATH and probably the QGIS lib path
> to LD_LIBRARY.
>
> Also, any error message could be useful in order to get some help from the
> community. :)
>
> Regards,
> -SL
>
>
> --
> Salvatore Larosa
> linkedIn: http://linkedin.com/in/larosasalvatore
> twitter: @lrssvt
> skype: s.larosa
> IRC: lrssvt on freenode
>



-- 
Eduardo Silverio da Silva
Mestrando em Ciências Geodésicas na Universidade Federal do Paraná
Engenheiro Cartógrafo e Agrimensor
+55 41 99873-6274
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pywps-dev/attachments/20170102/7becf7cd/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GetCapabilities.png
Type: image/png
Size: 12989 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/pywps-dev/attachments/20170102/7becf7cd/attachment-0001.png>


More information about the pywps-dev mailing list