[GRASS-dev] does GRASS need HOME to be defined?
Helmut Kudrnovsky
hellik at web.de
Wed Nov 23 12:29:50 PST 2016
Glynn Clements wrote
> Helmut Kudrnovsky wrote:
>
>> >> anyone more insight, if %HOME% is needed in winGRASS?
>> >
>> >Done by Glynn in:
>> >https://trac.osgeo.org/grass/changeset/37873
>>
>> does GRASS need HOME to be defined?
>>
>> any hints?
>
> It's used G__home() on Unix (and as a fallback on Windows) and it's
> used for G_rc_path() on Windows (for some reason, the Unix version
> uses getpwuid(), which is probably incorrect in this context).
>
> It may also be used implicitly by library functions or external
> programs looking for configuration files.
thanks for the insight.
a quick look into the trunk source:
D:\software_source\grass_trunk\lib\init\grass.py
def get_grass_config_dir():
"""Get configuration directory
Determines path of GRASS GIS user configuration directory and creates
it if it does not exist.
Configuration directory is for example used for grass env file
(the one which caries mapset settings from session to session).
"""
if sys.platform == 'win32':
grass_config_dirname = "GRASS7"
win_conf_path = os.getenv('APPDATA')
# this can happen with some strange settings
if not win_conf_path:
fatal(_("The APPDATA variable is not set, ask your operating"
" system support"))
if not os.path.exists(win_conf_path):
fatal(_("The APPDATA variable points to directory which does"
" not exist, ask your operating system support"))
directory = os.path.join(win_conf_path, grass_config_dirname)
else:
grass_config_dirname = ".grass7"
directory = os.path.join(os.getenv('HOME'), grass_config_dirname)
if not os.path.exists(directory):
os.mkdir(directory)
return directory
def ensure_home():
"""Set HOME if not set on MS Windows"""
if windows and not os.getenv('HOME'):
os.environ['HOME'] = os.path.join(os.getenv('HOMEDRIVE'),
os.getenv('HOMEPATH'))
regarding windows, the configuration directory is defined by the %APPDATA%
variable; HOME is defined by %HOMEDRIVE% and %HOMEPATH%.
it expands to:
>>> import os
>>> os.getenv('HOME')
'C:\\Users\\yourusername'
>>> os.getenv('APPDATA')
'C:\\Users\\yourusername\\AppData\\Roaming'
would it harm if %HOME% would be extended from _C:\Users\yourusername\_ to
_C:\Users\yourusername\Documents_ in windows?
as mentioned in
https://lists.osgeo.org/pipermail/grass-dev/2016-November/083122.html: the
winGRASS defined %HOME% (C:\Users\yourusername\) interferes with HOME as it
is expected by R (i.e. C:\Users\yourusername\Documents).
-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/does-GRASS-need-HOME-to-be-defined-tp5296669p5297176.html
Sent from the Grass - Dev mailing list archive at Nabble.com.
More information about the grass-dev
mailing list