浏览代码

init: provide informative message for broken MS Win APPDATA settings

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@67709 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 9 年之前
父节点
当前提交
92e80faa78
共有 1 个文件被更改,包括 14 次插入1 次删除
  1. 14 1
      lib/init/grass.py

+ 14 - 1
lib/init/grass.py

@@ -95,6 +95,11 @@ else:
 
 # Variables substituted during build process
 if 'GISBASE' in os.environ:
+    # TODO: should this be something like GRASS_PATH?
+    # GISBASE marks complete runtime, so no need to get it here when
+    # setting it up, possible scenario: existing runtime and starting
+    # GRASS in that, we want to overwrite the settings, not to take it
+    # possibly same for GRASS_PROJSHARE and others but maybe not
     gisbase = os.environ['GISBASE']
 else:
     gisbase = "@GISBASE@"
@@ -379,7 +384,15 @@ def get_grass_config_dir():
     """
     if sys.platform == 'win32':
         grass_config_dirname = "GRASS7"
-        directory = os.path.join(os.getenv('APPDATA'), grass_config_dirname)
+        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)