[GRASS-dev] Working with TGIS without starting GRASS explicitly

Laurent C. lrntct at gmail.com
Thu Sep 22 09:01:30 PDT 2016


Hello Stefan,

My software is not really a GRASS module, it is more independent and
use only GRASS as a back-end. It is fully written in Python and using
--exec or GRASS_BATCH_JOB does not seems very practical.
By the way it is not the first time I run into this problem of
temporal framework not finding the temporal DB, even when t.connect is
well set. Unfortunately is seems a bit random and not easy to
replicate. That is why I haven't filled a bug report.
Setting TGISDB_DRIVER and TGISDB_DATABASE does not solve the problem either.

Regards,
Laurent

2016-09-22 1:36 GMT-05:00 Blumentrath, Stefan <Stefan.Blumentrath at nina.no>:
> Hei Laurent,
>
> What about using the --exec magic from > GRASS 7.2?
> https://grass.osgeo.org/grass72/manuals/grass7.html#batch-jobs-with-the-exec-interface
> (or the GRASS_BATCH_JOB solution)?
>
> Cheers
> Stefan
>
>
> -----Original Message-----
> From: grass-dev [mailto:grass-dev-bounces at lists.osgeo.org] On Behalf Of Laurent C.
> Sent: 22. september 2016 02:47
> To: Sören Gebbert <soerengebbert at googlemail.com>
> Cc: GRASS developers list <grass-dev at lists.osgeo.org>
> Subject: Re: [GRASS-dev] Working with TGIS without starting GRASS explicitly
>
> Hello all,
>
> I've ran into another related issue.
> One of the goal of running the software outside of GRASS shell is to batch process simulations in various Locations/mapsets.
>
> I set the GRASS session for each case. The simulation works well for the first case.
> However when starting the second case, tgis.init() fails with the following error:
>
> ERROR: Unable to execute sql statement. There is no temporal database connection defined for mapset <hull>
>
> The mapset and location are properly set.
> If this case is run first, it works well and it's the second one that fail.
> Running t.connect -c between two cases does not solve the problem.
> Actually, t.connect -p shows the correct connection parameters, but
> tgis.init() still fails.
>
> Regards,
> Laurent
>
>
> 2016-09-21 18:27 GMT-05:00 Laurent C. <lrntct at gmail.com>:
>> Hi Sören,
>>
>> Setting LD_LIBRARY_PATH is working, thanks. But it cannot be set at
>> run-time, which is not very user-friendly.
>> I guess this issue is related to the ticket 2424 [1].
>>
>> I managed to get it work at run-time by restarting the program with
>> sys.execv() after setting the path [2], but I find it a bit ugly and
>> quite verbose to be multi-platform.
>>
>> It would be great if an easier option was possible.
>>
>> Regards,
>> Laurent
>>
>> [1] https://trac.osgeo.org/grass/ticket/2424
>> [2]
>> http://stackoverflow.com/questions/6543847/setting-ld-library-path-fro
>> m-inside-python
>>
>>
>> 2016-09-21 15:40 GMT-05:00 Sören Gebbert <soerengebbert at googlemail.com>:
>>> Hi,
>>> i think you have to put the GRASS libraries into your LD_LIBRARY_PATH
>>> so that the python wrapper can access them.
>>>
>>> Best regards
>>> Soeren
>>>
>>> 2016-09-21 20:37 GMT+02:00 Laurent C. <lrntct at gmail.com>:
>>>>
>>>> Hello all,
>>>>
>>>> I'm trying to adapt a python module in order for it to be run
>>>> outside of GRASS.
>>>> I followed the instructions from the wiki and
>>>> lib/python/script/setup.py
>>>>
>>>> gsetup.init() run without error and I can list maps like in the example.
>>>>
>>>> However, when I try to import the temporal module, I receive this error:
>>>>
>>>> import grass.temporal as tgis
>>>>   File "/usr/lib/grass70/etc/python/grass/temporal/__init__.py",
>>>> line 1, in <module>
>>>>     from core import *
>>>>   File "/usr/lib/grass70/etc/python/grass/temporal/core.py", line
>>>> 38, in <module>
>>>>     from c_libraries_interface import *
>>>>   File
>>>> "/usr/lib/grass70/etc/python/grass/temporal/c_libraries_interface.py
>>>> ",
>>>> line 19, in <module>
>>>>     import grass.lib.gis as libgis
>>>>   File "/usr/lib/grass70/etc/python/grass/lib/gis.py", line 23, in
>>>> <module>
>>>>     _libs["grass_gis.7.0.4"] = load_library("grass_gis.7.0.4")
>>>>   File "/usr/lib/grass70/etc/python/grass/lib/ctypes_loader.py",
>>>> line 55, in load_library
>>>>     return self.load(path)
>>>>   File "/usr/lib/grass70/etc/python/grass/lib/ctypes_loader.py",
>>>> line 71, in load
>>>>     raise ImportError,e
>>>> ImportError: libgrass_datetime.7.0.4.so: cannot open shared object
>>>> file: No such file or directory
>>>>
>>>>
>>>> Did I forgot to set-up something or this is a bug?
>>>>
>>>> Cheers,
>>>> Laurent
>>>> _______________________________________________
>>>> grass-dev mailing list
>>>> grass-dev at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/grass-dev
>>>
>>>
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev


More information about the grass-dev mailing list