Unverified Commit 0d9c4b97 authored by Julien Veyssier's avatar Julien Veyssier
Browse files

first attempt to make it work on windows


Signed-off-by: default avatarJulien Veyssier <eneiluj@posteo.net>
parent aabefe6b
Subproject commit aa544b714214402ba57a1c3f0d621e9fe4c5cd36
Subproject commit 8523d22dc5031077c333c1ed452f8c96d4878d9d
......@@ -506,7 +506,7 @@ class HruDelinDockWidget(QtWidgets.QDockWidget, FORM_CLASS):
def step2FinishedAuto(self):
self.step2Finished()
# launch all maps generation
self.doStep3(False, self.step3FinishedAuto)
#self.doStep3(False, self.step3FinishedAuto)
def step3FinishedAuto(self):
self.step3Finished()
......@@ -907,7 +907,8 @@ class HruDelinDockWidget(QtWidgets.QDockWidget, FORM_CLASS):
'type': 'raster',
'path': strPath,
'name': os.path.basename(strPath).replace('step1_', ''),
'tag': 'step1'
'tag': 'step1',
'zoom': (os.path.basename(strPath) == 'step1_dem_cut.tif')
})
for fPath in Path(self.cfgFilesOutPath).rglob('*step1*.shp'):
strPath = str(fPath)
......
import platform
import os, sys
from pathlib import Path
import subprocess
def isWindows():
plat = platform.system()
......@@ -33,45 +34,60 @@ def split_list(alist, wanted_parts=1):
for i in range(wanted_parts) ]
def prepareGrassEnv():
grassBasePath = None
# sys.path (to be able to import grass.script)
# find grass depending on the system
if isWindows():
pass
for grassVersion in ['74', '75', '76', '77', '78', '79']:
try:
grassBasePath = subprocess.check_output(['grass%s.bat' % grassVersion, '--config', 'path'], shell=True).decode('utf-8').rstrip(os.linesep)
break
except Exception as e:
pass
print('found winwin %s !!!'%grassBasePath)
elif isMac():
pass
else:
for grassVersion in ['74', '75', '76', '77', '78', '79']:
findRes = list(Path('/usr/lib/grass%s' % grassVersion).rglob('*r.thin*'))
if len(findRes) > 0:
thinPath = str(findRes[0])
grassBasePath = os.path.dirname(os.path.dirname(thinPath))
grassPythonPath = os.path.join(grassBasePath, 'etc', 'python')
if grassPythonPath not in sys.path:
sys.path.append(grassPythonPath)
break
os.environ['GISBASE'] = grassBasePath
grassBasePath = subprocess.check_output(['grass', '--config', 'path']).decode('utf-8').rstrip(os.linesep)
print('found first %s !!!'%grassBasePath)
if grassBasePath == None:
for grassVersion in ['74', '75', '76', '77', '78', '79']:
findRes = list(Path('/usr/lib/grass%s' % grassVersion).rglob('*r.thin*'))
if len(findRes) > 0:
thinPath = str(findRes[0])
grassBasePath = os.path.dirname(os.path.dirname(thinPath))
break
if grassBasePath == None:
print('GRASS not found on your system')
return
grassPythonPath = os.path.join(grassBasePath, 'etc', 'python')
if grassPythonPath not in sys.path:
sys.path.append(grassPythonPath)
os.environ['GISBASE'] = grassBasePath
libPathToAdd = os.path.join(grassBasePath, 'lib')
existingLdLibraryPath = ''
if 'LD_LIBRARY_PATH' in os.environ:
existingLdLibraryPath = os.environ['LD_LIBRARY_PATH']
if libPathToAdd not in existingLdLibraryPath.split(':'):
os.environ['LD_LIBRARY_PATH'] = '%s:%s' % (existingLdLibraryPath, libPathToAdd)
existingPYTHONPATH = ''
if 'PYTHONPATH' in os.environ:
existingPYTHONPATH = os.environ['PYTHONPATH']
if grassPythonPath not in existingPYTHONPATH.split(':'):
os.environ['PYTHONPATH'] = '%s:%s' % (existingPYTHONPATH, grassPythonPath)
pyPathToAdd = os.path.join(grassBasePath, 'etc', 'python')
existingPYTHONPATH = ''
if 'PYTHONPATH' in os.environ:
existingPYTHONPATH = os.environ['PYTHONPATH']
if pyPathToAdd not in existingPYTHONPATH.split(':'):
os.environ['PYTHONPATH'] = '%s:%s' % (existingPYTHONPATH, pyPathToAdd)
libPathToAdd = os.path.join(grassBasePath, 'lib')
existingLdLibraryPath = ''
if 'LD_LIBRARY_PATH' in os.environ:
existingLdLibraryPath = os.environ['LD_LIBRARY_PATH']
if libPathToAdd not in existingLdLibraryPath.split(':'):
os.environ['LD_LIBRARY_PATH'] = '%s:%s' % (existingLdLibraryPath, libPathToAdd)
grassBinPath = os.path.join(grassBasePath, 'bin')
grassScriptPath = os.path.join(grassBasePath, 'scripts')
existingPath = ''
if 'PATH' in os.environ:
existingPath = os.environ['PATH']
if grassBinPath not in existingPath.split(':'):
os.environ['PATH'] = '%s:%s' % (existingPath, grassBinPath)
existingPath = os.environ['PATH']
if grassScriptPath not in existingPath.split(':'):
os.environ['PATH'] = '%s:%s' % (existingPath, grassScriptPath)
\ No newline at end of file
grassBinPath = os.path.join(grassBasePath, 'bin')
grassScriptPath = os.path.join(grassBasePath, 'scripts')
existingPath = ''
if 'PATH' in os.environ:
existingPath = os.environ['PATH']
if grassBinPath not in existingPath.split(':'):
os.environ['PATH'] = '%s:%s' % (existingPath, grassBinPath)
existingPath = os.environ['PATH']
if grassScriptPath not in existingPath.split(':'):
os.environ['PATH'] = '%s:%s' % (existingPath, grassScriptPath)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment