zkwurst / GSoC2017-GRASS-GIS

GNU General Public License v2.0
2 stars 1 forks source link

pygrass and messages #6

Closed zkwurst closed 7 years ago

zkwurst commented 7 years ago

Should I be using pygrass to access the messages shortcuts?

If so, I can't get it to work. Is it a separate dependency I didn't compile?

Running this:

from grass.pygrass.modules.shortcuts import general as g
g.error("TEST")

Gives me this:

Traceback (most recent call last):
  File "/home/zechariah/git/GSoC2017-GRASS-
GIS/r.in.usgsned/r.in.usgsned.py", line 299, in <module>
    main()
  File "/home/zechariah/git/GSoC2017-GRASS-
GIS/r.in.usgsned/r.in.usgsned.py", line 123, in main
    g.error("TEST")
  File "/home/zechariah/dev/grass7_trunk/dist.x86_64-pc-
linux-gnu/etc/python/grass/pygrass/modules/shortcuts.py",
line 47, in __getattr__
    return self.cls('%s.%s' % (self.prefix,
name.replace('_', '.')))
  File "/home/zechariah/dev/grass7_trunk/dist.x86_64-pc-
linux-
gnu/etc/python/grass/pygrass/modules/interface/module.py",
line 530, in __init__
    raise GrassError(str_err % self.name)
grass.exceptions.GrassError: Error running: `g.error
--interface-description`.
OSError error(2): No such file or directory
(Wed Jun 28 17:57:36 2017) Command finished (0 sec)  
petrasovaa commented 7 years ago

It is compiled, otherwise the import would fail first.

The way you call it is not correct, it is interpreted as calling a module g.error which does not exist. Just use:

gscript.verbose()
gscript.info()
gscript.warning()
gscript.fatal()

The information about the files which are to be downloaded should be probably printed always, but without the -i flag it should use verbose() and with the flag it would use info() and exit the module.

petrasovaa commented 7 years ago

what is the *** tag?

zkwurst commented 7 years ago

Got it. Thanks.

The is one of the flags (, , *, **) I thought might help you know which issues were holding me up the most if you only had time to get to one of them or something. Good in theory, probably not that useful in practice.