1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
|
@echo off
rem #########################################################################
rem
rem MODULE: GRASS Initialization
rem AUTHOR(S): Paul Kelly
rem
rem PURPOSE: The source file for this batch script is lib/init/init.bat.
rem It sets up some environment variables, default GISRC file
rem if necessary, etc. prior to starting GRASS proper.
rem It is intended to be a native Windows replacement for Init.sh,
rem but does not (yet) contain all the same functionality.
rem
rem In particular also, GUI mode prints nothing to the terminal
rem and does not expect or provide an interactive terminal
rem running in addition to the GUI display.
rem
rem COPYRIGHT: (C) 2006-2013 by the GRASS Development Team
rem
rem This program is free software under the GNU General Public
rem License (>=v2). Read the file COPYING that comes with GRASS
rem for details.
rem
rem #########################################################################
set SAVEPATH=%PATH%
rem
rem The .bat files in the \bin directory are what execute the scripts
rem on Windows. The \scripts dir is added to the PATH automatically by
rem the wxGUI; for Command Line mode and GIS.m, shell scripts called from
rem other shell scripts need to have %GISBASE%\scripts in the PATH.
rem
if exist "%APPDATA%\GRASS6\env.bat" (
call %APPDATA%\GRASS6\env.bat
)
if "%GRASS_ADDON_PATH%"=="" set GRASS_ADDON_PATH=%APPDATA%\GRASS6\addons
PATH=%GISBASE%\bin;%GISBASE%\lib;%GRASS_ADDON_PATH%;%PATH%
set GIS_LOCK=1
set GRASS_VERSION=GRASS_VERSION_NUMBER
if "%HOME%"=="" set HOME=%USERPROFILE%
set WINGISRC=%APPDATA%\GRASS6\grassrc6
rem Create missing folder
if not exist "%APPDATA%\GRASS6" (
md "%APPDATA%\GRASS6"
)
rem Make sure %GISRC% is set so g.dirseps will work
rem (not actually used)
set GISRC=junk
rem Generate GISBASE by converting dirsep characters from \ to /
FOR /F "usebackq delims==" %%i IN (`g.dirseps -g "%GISBASE%"`) DO @set GISBASE=%%i
if not "%LANG%"=="" goto langset
FOR /F "usebackq delims==" %%i IN (`"%GISBASE%\etc\winlocale"`) DO @set LANG=%%i
:langset
if "%GRASS_WISH%"=="" set GRASS_WISH=wish.exe
if "%GRASS_SH%"=="" set GRASS_SH=c:\msys\1.0\bin\sh.exe
rem Should do something with "assoc .html" and ftype here but would require
rem a new g.manual.bat too so leaving it like this for now...
if "%GRASS_HTML_BROWSER%"=="" set GRASS_HTML_BROWSER=explorer
if "%GRASS_PROJSHARE%"=="" set GRASS_PROJSHARE=CONFIG_PROJSHARE
rem Add python scripts to the PATHEXT variable
set PATHEXT=%PATHEXT%;.PY
if "%1" == "-version" goto displaylicence
if "%1" == "-v" goto displaylicence
if "%1" == "-text" goto settextmode
:aftertextcheck
if "%1" == "-tcltk" goto setguimode
if "%1" == "-wxpython" goto setwxmode
if "%1" == "-wx" goto setwxmode
if "%1" == "-gui" goto setguimode
:afterguicheck
if exist "%WINGISRC%" (
set HAVE_GISRC=true
goto aftercreategisrc
)
set HAVE_GISRC=false
rem Create an initial GISRC file based on current directory
"%GISBASE%\etc\echo" "GISDBASE: %USERPROFILE%" | g.dirseps -g > "%WINGISRC%"
"%GISBASE%\etc\echo" "LOCATION_NAME: <UNKNOWN>" >> "%WINGISRC%"
"%GISBASE%\etc\echo" "MAPSET: <UNKNOWN>" >> "%WINGISRC%"
:aftercreategisrc
rem Now set the real GISRC
FOR /F "usebackq delims==" %%i IN (`g.dirseps -g "%WINGISRC%"`) DO @set GISRC=%%i
rem Fetch the language setting from user's prefs
FOR /F "usebackq delims==" %%i IN (`g.gisenv "get=LANG"`) DO @set LANG=%%i
rem Set GRASS_GUI
if "%GRASS_GUI%" == "" (
FOR /F "usebackq delims==" %%i IN (`g.gisenv "get=GRASS_GUI"`) DO @set GRASS_GUI=%%i
) else (
g.gisenv "set=GRASS_GUI=%GRASS_GUI%"
)
rem Set wxGUI as default if not specified elsewhere
if "%GRASS_GUI%"=="" set GRASS_GUI=wxpython
rem Clean out old .tmp files from the mapset
if "%HAVE_GISRC%"=="true" (
"%GISBASE%\etc\clean_temp" > NUL:
)
set HAVE_GISRC=
rem why doesn't it like if () else ()?
if not "%PYTHONPATH%" == "" set PYTHONPATH=%PYTHONPATH%;%GISBASE%\etc\python
if "%PYTHONPATH%" == "" set PYTHONPATH=%GISBASE%\etc\python
if "%GRASS_GUI%"=="wxpython" goto wxpython
PATH=%PATH%;%GISBASE%\scripts
if "%GRASS_GUI%"=="text" goto text
rem Tcl/Tk GUI setup
if not "%GRASS_WISH%"=="" (
"%GRASS_WISH%" "%GISBASE%\etc\gis_set.tcl"
) else (
"%GISBASE%\etc\gis_set.tcl"
)
rem This doesn't seem to work; don't understand return codes from gis_set.tcl PK
rem if return ok, gis.m start:
if %errorlevel% == 2 goto exitinit
rem Does line 42 above mean that GRASS_WISH will always be set?
if not "%GRASS_WISH%"=="" (
start /b "GRASS Tcl/Tk" "%GRASS_WISH%" "%GISBASE%\etc\gm\gm.tcl"
) else (
start /b "GRASS Tcl/Tk" "%GISBASE%\etc\gm\gm.tcl"
)
rem Will redirecting output to NUL hide legitamite error messages, harming debugging?
"%GISBASE%\etc\clean_temp" > NUL:
goto exitinit
:wxpython
set PYTHONPATH=%PYTHONPATH%;%GISBASE%\etc\wxpython
if "%GRASS_PYTHON%"=="" set GRASS_PYTHON=python
"%GRASS_PYTHON%" "%GISBASE%/etc/wxpython/gis_set.py"
if %errorlevel% == 2 goto exitinit
"%GRASS_PYTHON%" "%GISBASE%/etc/wxpython/wxgui.py"
goto exitinit
:text
"%GISBASE%\etc\set_data"
if %errorlevel% == 1 goto exitinit
rem Get LOCATION_NAME to use in prompt
FOR /F "usebackq delims==" %%i IN (`g.gisenv "get=LOCATION_NAME"`) DO @set LOCATION_NAME=%%i
type "%GISBASE%\etc\welcome"
"%GISBASE%\etc\echo" ""
"%GISBASE%\etc\echo" "GRASS homepage: http://grass.osgeo.org/"
"%GISBASE%\etc\echo" "This version running thru: Windows Command Shell (cmd.exe)"
"%GISBASE%\etc\echo" "When ready to quit enter: exit"
"%GISBASE%\etc\echo" "Help is available with the command: g.manual -i"
"%GISBASE%\etc\echo" "See the licence terms with: g.version -c"
rem "Start the GUI with: g.gui wxpython"
"%GISBASE%\etc\echo" ""
prompt GRASS %GRASS_VERSION% $C%LOCATION_NAME%$F$G
cmd.exe
prompt
goto exitinit
:displaylicence
type "%GISBASE%\etc\license"
goto exitinit
:settextmode
set GRASS_GUI=text
shift
goto aftertextcheck
:setguimode
set GRASS_GUI=tcltk
shift
goto afterguicheck
:setwxmode
set GRASS_GUI=wxpython
shift
goto afterguicheck
:exitinit
rem Clean out old .tmp files from the mapset
"%GISBASE%\etc\clean_temp" > NUL:
set PATH=%SAVEPATH%
set SAVEPATH=
exit /b
|