[GRASS-user] issues with grass python script running outside grass without defined location
Vaclav Petras
wenzeslaus at gmail.com
Wed Jun 1 17:17:45 PDT 2016
Hi again Alassane!
On Wed, Jun 1, 2016 at 7:41 PM, alassane toure <atourej at gmail.com> wrote:
> alassane at alassane-MS-7593:~/Programs/grass/pythongrass$
> /home/alassane/Programs/grass/pythongrass/grass_noloc.py
> File "/home/alassane/Programs/grass/pythongrass/grass_noloc.py", line 62
> else:
> ^
> SyntaxError: invalid syntax
>
> The program works when I comment the followings statements
>
> # define GRASS DATABASE
> if sys.platform.startswith('win'):
> gisdb = os.path.join(os.getenv('APPDATA', 'grassdata')
> else:
>
>From looking at the code, it seems that the closing parentheses is missing
in the os.getenv() function call.
I'm not sure which code you are using and also where your data actually
are. APPDATA is not common for grassdata directory but should work of
course if it is what you want. Anyway, this is what the documentation [1]
suggests:
gisdb = os.path.join(os.path.expanduser("~"), "grassdata")
(and usually modifying for MS Windows with `os.path.expanduser("~"),
,"Documents", "grassdata"`.
Hope this helps,
Vaclav
PS: Please note you have grass-dev-request at lists.osgeo.org mailing list in
your To field. I don't think you want that (I'm not sure what would be the
reason). You can of course subscribe to grass-dev at lists.osgeo.org if you
want to discuss some development of GRASS GIS!
[1]
https://grass.osgeo.org/grass70/manuals/libpython/script.html#module-script.setup
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20160601/0daa1d08/attachment.html>
More information about the grass-user
mailing list