[GRASS-dev] [GRASS-SVN] r73692 - grass/trunk/lib/init

Markus Metz markus.metz.giswork at gmail.com
Thu Nov 22 07:57:25 PST 2018


On Thu, Nov 22, 2018 at 3:31 PM Vaclav Petras <wenzeslaus at gmail.com> wrote:
>
>
>
> On Wed, Nov 21, 2018 at 2:12 PM Martin Landa <landa.martin at gmail.com>
wrote:
>>
>> Hi,
>>
>> st 21. 11. 2018 v 20:05 odesílatel <svn_grass at osgeo.org> napsal:
>> > +        # clean the sqlite db
>> > +        from grass.script import db as gdb
>> > +        from grass.script import core as gcore
>> > +        conn = gdb.db_connection()
>> > +        if conn and conn['driver'] == 'sqlite':
>> > +           # check if db exists
>> > +           gisenv = gcore.gisenv()
>> > +           database = conn['database']
>> > +           database = database.replace('$GISDBASE',
gisenv['GISDBASE'])
>> > +           database = database.replace('$LOCATION_NAME',
gisenv['LOCATION_NAME'])
>> > +           database = database.replace('$MAPSET', gisenv['MAPSET'])
>> > +           if os.path.exists(database):
>> > +               message(_("Cleaning up sqlite database ..."))
>> > +               gcore.start_command('db.execute', sql = 'VACUUM')
>>
>> a small note, the added code could be probably moved to new a fn eg.
>> clean_db(), Ma
>
>
> Yes, ideally to grass.script.setup.

But this is only initializing a GRASS session, without any mechanism to
terminate a session. Basic usage in the documentation:

        # ... use GRASS modules here
        # remove the session's gisrc file to end the session
        os.remove(gisrc)

maybe a new fn to terminate a session is needed? This fn could clean temp
files like clean_temp() in grass.py and also clean any default sqlite db
when terminating the grass session.

Markus M
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20181122/6f96d6a5/attachment.html>


More information about the grass-dev mailing list