Skip to content

[Bug] python script.setup issues related to message translation #2515

@tpilz

Description

@tpilz

Describe the bug

I want to use GRASS in a python module but get some errors when using certain functions of the grass.script.setup module.

To Reproduce

Connect to a grass mapset in python as described in the docs, e.g.

import grass.script.setup as gsetup
rcfile = gsetup.init('my_db', 'my_location', 'my_mapset')
rcfile.finish()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/grass82/etc/python/grass/script/setup.py", line 415, in finish
    finish()
  File "/usr/local/grass82/etc/python/grass/script/setup.py", line 474, in finish
    clean_default_db()
  File "/usr/local/grass82/etc/python/grass/script/setup.py", line 434, in clean_default_db
    gcore.message(_("Cleaning up default sqlite database ..."))
TypeError: 'str' object is not callable

System description (please complete the following information):

Tested on two Linux systems with GRASS 7.8 and GRASS 8.2 using python 3.6.2 and 3.9.10, respectively.

Additional context

Error is caused by gcore.message(_("<message>")) calls in setup.py. I think #551 is related where the issue was discussed but never really solved.

For the time being a workaround works for my case with gutils.try_remove(os.environ["GISRC"]) which is basically what I need here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions