[Zoo-discuss] WPS Service and GRASS7 - setup.init()

Francesco Massa massa80 at gmail.com
Fri Jun 26 06:45:07 PDT 2015


Hi, Luca how are you?

Below my funct.py and GetRasterKrige.py script.

Best regards

Francesco

------

funct.py:
#!/usr/bin/env python
#

"""
export GISBASE="/usr/local/grass70"
export PATH="$PATH:$GISBASE/bin:$GISBASE/scripts"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$GISBASE/lib"
export GIS_LOCK=$$
# path to GRASS settings file
#export GISRC="$HOME/.grassrc6"
export GISRC="$HOME/.grass7"
export PYTHONPATH="$PYTHONPATH:$GISBASE/etc/python"
"""


# WPS file configuration

import sys
import os
import tempfile
import shutil
import urllib


def GRASSEnvConfig():
    grass7="locate grass70 -c"
    if  grass7>0:
        GISBASE = "/usr/lib/grass70" #"/usr/lib/grass64/"
##"/usr/local/grass-7.0.svn" #check grass folder
    else:
        GISBASE = "/usr/lib/grass64/"
    os.environ['MPLCONFIGDIR'] = "/tmp/ZooWPS/"
    os.environ['GISBASE'] = GISBASE
    os.environ['PATH'] = os.environ['PATH'] + ':' + GISBASE + 'scripts/'
    if 'LD_LIBRARY_PATH' in os.environ.keys():
        os.environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
+ ":$GISBASE/lib"
    else:
        os.environ['LD_LIBRARY_PATH'] = ":$GISBASE/lib"
    os.environ['GRASS_LD_LIBRARY_PATH'] = "$LD_LIBRARY_PATH"
    os.environ['GIS_LOCK'] = str(os.getpid())
    # path to GRASS settings file
    os.environ['GISRC'] = "$HOME/.grass7/rc"  #"$HOME/.grassrc6"
    grasspath = os.path.join(GISBASE, 'etc','python')
    if grasspath not in sys.path:
        sys.path.append(grasspath)
    return os.environ,sys.path



----------------

GetRasterKrige.py
#!/usr/bin/env python
try:
    import sys
    import uuid
    import funct
    import zipfile
    from datetime import datetime, date, time
    from pyper import *
except ImportError:
    print "NO module found"



#-----GRASS GIS CONFIG-----#

funct.GRASSEnvConfig()
uid=uuid.uuid4()
try:
    import grass.script as grass
except ImportError:
    print "No GRASS-python library found"



from grass.script import setup
setup.init("/usr/lib/grass70/", "/var/www/zoo/data/dbgrass/",
"SEPG_WPS", "PERMANENT")


area="/var/www/zoo/data/mare_porto_genova.shp" #mask input shapefile

[cut]

2015-06-26 14:51 GMT+02:00 Luca Delucchi <lucadeluge at gmail.com>:
> On 26 June 2015 at 14:14, Francesco Massa <massa80 at gmail.com> wrote:
>> Hi
>
> Hi,
>
>> I receive this error from my WPS service when I call my service
>> GetRasterKrige I understand that it's something about the GRASS7
>> configuration, in particular error is rised when .py invokes
>> setup.init but I can't solve it.
>> The GetRasterKrige.py script seemingly is okay: I haven't python error .
>>
>> Can you help me? Any suggestions about that?
>>
>
> It seems there is an error with initialization of GRASS, but we need
> more info, could you share the code with us...
>
>> Best regards
>>
>> Francesco
>>
>> <?xml version="1.0" encoding="utf-8"?>
>> <ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/1.1"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://www.opengis.net/ows/1.1
>> http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd"
>> xml:lang="en-US" version="1.1.0">
>> <ows:Exception exceptionCode="NoApplicableCode">
>> <ows:ExceptionText>Python module GetRasterKrige cannot be loaded.
>> Message: TRACE: 'NoneType' object has no attribute 'endswith'
>> <type 'exceptions.AttributeError'>
>> Unable to run your python process properly. Please check the following
>> messages : [' File "/usr/lib/cgi-bin/GetRasterKrige.py", line 29, in
>> <module>\n setup.init("/usr/lib/grass70/",
>> "/var/www/zoo/data/dbgrass", "SEPG_WPS", "PERMANENT")\n', ' File
>> "/usr/lib/grass70/etc/python/grass/script/setup.py", line 161, in
>> init\n config_dir = os.path.join(os.getenv(\'HOME\'),
>> config_dirname)\n', ' File "/usr/lib/python2.7/posixpath.py", line 68,
>> in join\n elif path == \'\' or path.endswith(\'/\'):\n']
>> </ows:ExceptionText>
>> </ows:Exception>
>> </ows:ExceptionReport>
>> _______________________________________________
>> Zoo-discuss mailing list
>> Zoo-discuss at lists.osgeo.org
>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/zoo-discuss
>
>
>
> --
> ciao
> Luca
>
> http://gis.cri.fmach.it/delucchi/
> www.lucadelu.org


More information about the Zoo-discuss mailing list