[GRASS-dev] [GRASS-user] execGRASS("r.diversity"): [Error 3] Cannot find path specified \\.grass7\\r.li

[CC to grass-dev]

Sandra MacFadyen wrote:

  File "C:/Program Files (x86)/GRASS GIS 7.0.0beta2/scripts/r.diversity.py",
line 116, in main
    os.mkdir(rlidir)
WindowsError: [Error 3] The system cannot find the path specified:
'D:/Bands_processed1\\.grass7\\r.li'

r.diversity.py is broken on Windows:

    home = os.path.expanduser('~')
    rlidir = os.path.join(home, '.grass7', 'r.li')

The script tries to create an r.li subdirectory, but fails because the
parent directory doesn't exist.

$HOME/.grass7 is correct for Unix, but on Windows it's
%APPDATA%\GRASS7. From lib/init/grass.py:

    # configuration directory
    grass_env_file = None # see check_shell()
    if sys.platform == 'win32':
        grass_config_dirname = "GRASS7"
        grass_config_dir = os.path.join(os.getenv('APPDATA'), grass_config_dirname)
    else:
        grass_config_dirname = ".grass7"
        grass_config_dir = os.path.join(os.getenv('HOME'), grass_config_dirname)

--
Glynn Clements <glynn@gclements.plus.com>

On Wed, May 21, 2014 at 7:38 PM, Glynn Clements
<glynn@gclements.plus.com> wrote:

[CC to grass-dev]

Sandra MacFadyen wrote:

  File "C:/Program Files (x86)/GRASS GIS 7.0.0beta2/scripts/r.diversity.py",
line 116, in main
    os.mkdir(rlidir)
WindowsError: [Error 3] The system cannot find the path specified:
'D:/Bands_processed1\\.grass7\\r.li'

r.diversity.py is broken on Windows:

    home = os.path.expanduser('~')
    rlidir = os.path.join(home, '.grass7', 'r.li')

The script tries to create an r.li subdirectory, but fails because the
parent directory doesn't exist.

$HOME/.grass7 is correct for Unix, but on Windows it's
%APPDATA%\GRASS7. From lib/init/grass.py:

    # configuration directory
    grass_env_file = None # see check_shell()
    if sys.platform == 'win32':
        grass_config_dirname = "GRASS7"
        grass_config_dir = os.path.join(os.getenv('APPDATA'), grass_config_dirname)
    else:
        grass_config_dirname = ".grass7"
        grass_config_dir = os.path.join(os.getenv('HOME'), grass_config_dirname)

I have added that in r60403.

Sandra, please try the updated version from Addons SVN.

Markus